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(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 }
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 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 replicationTableCreated() throws AccumuloException, AccumuloSecurityException { Assert.assertTrue(getConnector().tableOperations().exists(ReplicationTable.NAME)); Assert.assertEquals(ReplicationTable.ID, getConnector().tableOperations().tableIdMap().get(ReplicationTable.NAME)); }
@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 }
@Test(expected = AccumuloException.class) public void testRootTableSplit() throws Exception { TableOperations opts = getConnector().tableOperations(); SortedSet<Text> splits = new TreeSet<>(); splits.add(new Text("5")); opts.addSplits(RootTable.NAME, splits); }
@Test public void testMerge() throws Exception { Connector conn = getConnector(); String tableName = getUniqueNames(1)[0]; conn.tableOperations().create(tableName); BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig()); bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1")); bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2")); bw1.flush(); BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig()); MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2); bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1")); Mutation mut = createTablet("0", null, null, "/d2", "/d2/file2"); mut.put(DataFileColumnFamily.NAME.toString(), "/d1/file1", new DataFileValue(10, 200).encodeAsString()); bw1.addMutation(mut); bw1.flush(); try { MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2); assertTrue(false); } catch (TabletIterator.TabletDeletedException tde) {} }
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()); }
@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 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 public void createTableInDefaultNamespace() throws Exception { String tableName = "1"; c.tableOperations().create(tableName); assertTrue(c.tableOperations().exists(tableName)); }
@Test public void testRootTableMerge() throws Exception { TableOperations opts = getConnector().tableOperations(); opts.merge(RootTable.NAME, null, null); }
conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName()); conn.tableOperations().create(table.getMetricsTableName()); conn.tableOperations().attachIterator(table.getMetricsTableName(), s);
@Test public void merge() throws Exception { Connector c = getConnector(); String tableName = getUniqueNames(1)[0]; c.tableOperations().create(tableName); c.tableOperations().addSplits(tableName, splits("a b c d e f g h i j k".split(" "))); BatchWriter bw = c.createBatchWriter(tableName, null); for (String row : "a b c d e f g h i j k".split(" ")) { Mutation m = new Mutation(row); m.put("cf", "cq", "value"); bw.addMutation(m); } bw.close(); c.tableOperations().flush(tableName, null, null, true); c.tableOperations().merge(tableName, new Text("c1"), new Text("f1")); assertEquals(8, c.tableOperations().listSplits(tableName).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 testPreSplit() throws Exception { String tableName = getUniqueNames(1)[0]; Connector c = getConnector(); c.tableOperations().create(tableName); SortedSet<Text> splits = new TreeSet<>(); splits.add(new Text("8")); splits.add(new Text("256")); c.tableOperations().addSplits(tableName, splits); runTest(c, tableName); }
conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName()); conn.tableOperations().create(table.getMetricsTableName()); conn.tableOperations().attachIterator(table.getMetricsTableName(), s);
private void writeFlush(Connector conn, String tablename, String row) throws Exception { BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig()); Mutation m = new Mutation(row); m.put("", "", ""); bw.addMutation(m); bw.close(); conn.tableOperations().flush(tablename, null, null, true); }