public void createAccumuloTable(String table) { try { connector.tableOperations().create(table); } catch (AccumuloException | AccumuloSecurityException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to create Accumulo table", e); } catch (TableExistsException e) { throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Accumulo table already exists", e); } }
@Test public void testRealWrite() throws Exception { Connector c = getConnector(); c.tableOperations().create(TEST_TABLE); BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig()); Mutation m = new Mutation("Key"); m.put("", "", ""); bw.addMutation(m); bw.close(); handleWriteTests(true); }
@Test public void createTableInDefaultNamespace() throws Exception { String tableName = "1"; c.tableOperations().create(tableName); assertTrue(c.tableOperations().exists(tableName)); }
@Test public void createTable() throws TableExistsException, AccumuloException, AccumuloSecurityException, TableNotFoundException { String tableName = getUniqueNames(1)[0]; connector.tableOperations().create(tableName); Iterable<Map.Entry<String,String>> itrProps = connector.tableOperations() .getProperties(tableName); Map<String,String> props = propsToMap(itrProps); assertEquals(DefaultKeySizeConstraint.class.getName(), props.get(Property.TABLE_CONSTRAINT_PREFIX.toString() + "1")); connector.tableOperations().delete(tableName); }
@Test public void testNoFiles() throws Exception { Connector conn = getConnector(); String tableName = getUniqueNames(1)[0]; conn.tableOperations().create(tableName); KeyExtent ke = new KeyExtent("0", null, null); Mutation mut = ke.getPrevRowUpdateMutation(); TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes())); TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes())); BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig()); bw1.addMutation(mut); bw1.close(); BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig()); MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2); int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2); assertEquals(0, rc); // scan tables metadata entries and confirm the same }
private void testDropNone(Map<String,String> options) throws Exception { Connector c = getConnector(); String tableName = getUniqueNames(1)[0]; c.tableOperations().create(tableName); writeFlush(c, tableName, "a"); writeFlush(c, tableName, "b"); CompactionStrategyConfig csConfig = new CompactionStrategyConfig( TestCompactionStrategy.class.getName()); csConfig.setOptions(options); c.tableOperations().compact(tableName, new CompactionConfig().setWait(true).setCompactionStrategy(csConfig)); Assert.assertEquals(ImmutableSet.of("a", "b"), getRows(c, tableName)); }
public EntityKeyValueIndex(Connector connector, String indexTable, ShardBuilder<Entity> shardBuilder, StoreConfig config, TypeRegistry<String> typeRegistry) throws TableNotFoundException, TableExistsException, AccumuloSecurityException, AccumuloException { this.shardBuilder = shardBuilder; this.typeRegistry = typeRegistry; if(!connector.tableOperations().exists(indexTable)) connector.tableOperations().create(indexTable); writer = connector.createBatchWriter(indexTable, config.getMaxMemory(), config.getMaxLatency(), config.getMaxWriteThreads()); }
private void writeData(String tableName, Connector conn) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, MutationsRejectedException { TreeSet<Text> splits = new TreeSet<>(); for (int i = 1; i < 100; i++) { splits.add(new Text(String.format("%06d", i * 100))); } conn.tableOperations().create(tableName); conn.tableOperations().addSplits(tableName, splits); BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { String row = String.format("%06d", i * 100 + 3); Mutation m = new Mutation(row); m.put("cf1", "cq1", "1"); bw.addMutation(m); } bw.close(); }
@Test public void testCompactEmptyTableWithGeneratorIterator() throws TableExistsException, AccumuloException, AccumuloSecurityException, TableNotFoundException { String tableName = getUniqueNames(1)[0]; connector.tableOperations().create(tableName); List<IteratorSetting> list = new ArrayList<>(); list.add(new IteratorSetting(15, HardListIterator.class)); connector.tableOperations().compact(tableName, null, null, list, true, true); Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY); Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ for (Map.Entry<Key,Value> entry : scanner) actual.put(entry.getKey(), entry.getValue()); assertEquals(HardListIterator.allEntriesToInject, actual); connector.tableOperations().delete(tableName); }
@Test(expected = AccumuloException.class) public void createTableInAccumuloNamespace() throws Exception { String tableName = Namespaces.ACCUMULO_NAMESPACE + ".1"; assertFalse(c.tableOperations().exists(tableName)); c.tableOperations().create(tableName); // should fail }
@Before public void setupInstance() throws Exception { tableName = getUniqueNames(1)[0]; conn = getConnector(); conn.tableOperations().create(tableName); BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig()); ColumnVisibility cv = new ColumnVisibility(); // / has 1 dir // /local has 2 dirs 1 file // /local/user1 has 2 files bw.addMutation(Ingest.buildMutation(cv, "/local", true, false, true, 272, 12345, null)); bw.addMutation(Ingest.buildMutation(cv, "/local/user1", true, false, true, 272, 12345, null)); bw.addMutation(Ingest.buildMutation(cv, "/local/user2", true, false, true, 272, 12345, null)); bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 12345, null)); bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 23456, null)); bw.addMutation( Ingest.buildMutation(cv, "/local/user1/file1", false, false, false, 2024, 12345, null)); bw.addMutation( Ingest.buildMutation(cv, "/local/user1/file2", false, false, false, 1028, 23456, null)); bw.close(); }
conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName()); conn.tableOperations().create(table.getMetricsTableName());
ExportTask(String instanceName, String zookeepers, String user, String password, String table) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { ZooKeeperInstance zki = new ZooKeeperInstance( new ClientConfiguration().withInstance(instanceName).withZkHosts(zookeepers)); // TODO need to close batch writer Connector conn = zki.getConnector(user, new PasswordToken(password)); try { bw = conn.createBatchWriter(table, new BatchWriterConfig()); } catch (TableNotFoundException tnfe) { try { conn.tableOperations().create(table); } catch (TableExistsException e) { // nothing to do } bw = conn.createBatchWriter(table, new BatchWriterConfig()); } }
@Test public void testMapWithBatchScanner() throws Exception { final String TEST_TABLE_2 = getUniqueNames(1)[0]; Connector c = getConnector(); c.tableOperations().create(TEST_TABLE_2); BatchWriter bw = c.createBatchWriter(TEST_TABLE_2, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { Mutation m = new Mutation(new Text(String.format("%09x", i + 1))); m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes())); bw.addMutation(m); } bw.close(); Assert.assertEquals(0, MRTester .main(new String[] {TEST_TABLE_2, AccumuloInputFormat.class.getName(), "True", "False"})); assertEquals(1, assertionErrors.get(TEST_TABLE_2 + "_map").size()); assertEquals(1, assertionErrors.get(TEST_TABLE_2 + "_cleanup").size()); }
@Test public void testCompactEmptyTableWithGeneratorIterator_Splits() throws TableExistsException, AccumuloException, AccumuloSecurityException, TableNotFoundException { String tableName = getUniqueNames(1)[0]; connector.tableOperations().create(tableName); SortedSet<Text> splitset = new TreeSet<>(); splitset.add(new Text("f")); connector.tableOperations().addSplits(tableName, splitset); List<IteratorSetting> list = new ArrayList<>(); list.add(new IteratorSetting(15, HardListIterator.class)); connector.tableOperations().compact(tableName, null, null, list, true, true); Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY); Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ for (Map.Entry<Key,Value> entry : scanner) actual.put(entry.getKey(), entry.getValue()); assertEquals(HardListIterator.allEntriesToInject, actual); connector.tableOperations().delete(tableName); }
@Test public void run() throws Exception { Connector c = getConnector(); String[] tableNames = getUniqueNames(2); String bwft = tableNames[0]; c.tableOperations().create(bwft); String bwlt = tableNames[1]; c.tableOperations().create(bwlt); runFlushTest(bwft); runLatencyTest(bwlt); }
@Test public void testMerge() throws Exception { // create a fake metadata table String metadataTableName = getUniqueNames(1)[0]; getConnector().tableOperations().create(metadataTableName); KeyExtent ke1 = new KeyExtent("0", new Text("m"), null); Mutation mut1 = ke1.getPrevRowUpdateMutation(); TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut1, new Value("/d1".getBytes())); KeyExtent ke2 = new KeyExtent("0", null, null); Mutation mut2 = ke2.getPrevRowUpdateMutation(); TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut2, new Value("/d2".getBytes())); BatchWriter bw1 = getConnector().createBatchWriter(metadataTableName, new BatchWriterConfig()); bw1.addMutation(mut1); bw1.addMutation(mut2); bw1.close(); TestTabletIterator tabIter = new TestTabletIterator(getConnector(), metadataTableName); exception.expect(TabletDeletedException.class); while (tabIter.hasNext()) { tabIter.next(); } } }
conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName()); conn.tableOperations().create(table.getMetricsTableName());
@Test public void testMap() throws Exception { final String TEST_TABLE_1 = getUniqueNames(1)[0]; Connector c = getConnector(); c.tableOperations().create(TEST_TABLE_1); BatchWriter bw = c.createBatchWriter(TEST_TABLE_1, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { Mutation m = new Mutation(new Text(String.format("%09x", i + 1))); m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes())); bw.addMutation(m); } bw.close(); Assert.assertEquals(0, MRTester.main(new String[] {TEST_TABLE_1, AccumuloInputFormat.class.getName()})); assertEquals(1, assertionErrors.get(TEST_TABLE_1 + "_map").size()); assertEquals(1, assertionErrors.get(TEST_TABLE_1 + "_cleanup").size()); }
@SuppressWarnings("deprecation") @Test public void tableNameOnly() throws Exception { log.info("Starting tableNameOnly"); // Create a table with the initial properties Connector connector = getConnector(); String tableName = getUniqueNames(2)[0]; connector.tableOperations().create(tableName, new NewTableConfiguration()); String tableNameOrig = "original"; connector.tableOperations().create(tableNameOrig, true); int countNew = numProperties(connector, tableName); int countOrig = compareProperties(connector, tableNameOrig, tableName, null); Assert.assertEquals("Extra properties using the new create method", countOrig, countNew); Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS)); }