use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class BinaryIT method testPreSplit.
@Test
public void testPreSplit() throws Exception {
String tableName = getUniqueNames(1)[0];
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
SortedSet<Text> splits = new TreeSet<>();
splits.add(new Text("8"));
splits.add(new Text("256"));
NewTableConfiguration ntc = new NewTableConfiguration().withSplits(splits);
c.tableOperations().create(tableName, ntc);
runTest(c, tableName);
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class UserCompactionStrategyIT method testDropNone.
private void testDropNone(Map<String, String> options) throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
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));
assertEquals(Set.of("a", "b"), getRows(c, tableName));
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class UserCompactionStrategyIT method testPerTableClasspath.
@Test
public void testPerTableClasspath() throws Exception {
// Can't assume that a test-resource will be on the server's classpath
assumeTrue(getClusterType() == ClusterType.MINI);
// test per-table classpath + user specified compaction strategy
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
final String tableName = getUniqueNames(1)[0];
File target = new File(System.getProperty("user.dir"), "target");
assertTrue(target.mkdirs() || target.isDirectory());
var destFile = initJar("/org/apache/accumulo/test/TestCompactionStrat.jar", "TestCompactionStrat", target.getAbsolutePath());
c.instanceOperations().setProperty(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "context1", destFile.toString());
HashMap<String, String> props = new HashMap<>();
props.put(Property.TABLE_CLASSLOADER_CONTEXT.getKey(), "context1");
SortedSet<Text> splits = new TreeSet<>(Arrays.asList(new Text("efg")));
var ntc = new NewTableConfiguration().setProperties(props).withSplits(splits);
c.tableOperations().create(tableName, ntc);
writeFlush(c, tableName, "a");
writeFlush(c, tableName, "b");
writeFlush(c, tableName, "h");
writeFlush(c, tableName, "i");
assertEquals(4, FunctionalTestUtils.countRFiles(c, tableName));
// EfgCompactionStrat will only compact a tablet w/ end row of 'efg'. No other tablets are
// compacted.
CompactionStrategyConfig csConfig = new CompactionStrategyConfig("org.apache.accumulo.test.EfgCompactionStrat");
c.tableOperations().compact(tableName, new CompactionConfig().setWait(true).setCompactionStrategy(csConfig));
assertEquals(3, FunctionalTestUtils.countRFiles(c, tableName));
c.tableOperations().compact(tableName, new CompactionConfig().setWait(true));
assertEquals(2, FunctionalTestUtils.countRFiles(c, tableName));
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class GarbageCollectorCommunicatesWithTServersIT method getFilesForTable.
/**
* Fetch all of the rfiles referenced by tablets in the metadata table for this table
*/
private Set<String> getFilesForTable(String tableName) throws Exception {
final AccumuloClient client = Accumulo.newClient().from(getClientProperties()).build();
final TableId tableId = TableId.of(client.tableOperations().tableIdMap().get(tableName));
assertNotNull("Could not determine table ID for " + tableName, tableId);
Set<String> rfiles = new HashSet<>();
try (Scanner s = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
Range r = TabletsSection.getRange(tableId);
s.setRange(r);
s.fetchColumnFamily(DataFileColumnFamily.NAME);
for (Entry<Key, Value> entry : s) {
log.debug("Reading RFiles: {}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
// uri://path/to/wal
String cq = entry.getKey().getColumnQualifier().toString();
String path = new Path(cq).toString();
log.debug("Normalize path to rfile: {}", path);
rfiles.add(path);
}
}
return rfiles;
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class GarbageCollectorCommunicatesWithTServersIT method getMetadataStatusForTable.
/**
* Get the replication status messages for the given table that exist in the metadata table (~repl
* entries)
*/
private Map<String, Status> getMetadataStatusForTable(String tableName) throws Exception {
final AccumuloClient client = Accumulo.newClient().from(getClientProperties()).build();
final String tableId = client.tableOperations().tableIdMap().get(tableName);
assertNotNull("Could not determine table ID for " + tableName, tableId);
Map<String, Status> fileToStatus = new HashMap<>();
try (Scanner s = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
Range r = ReplicationSection.getRange();
s.setRange(r);
s.fetchColumn(ReplicationSection.COLF, new Text(tableId));
for (Entry<Key, Value> entry : s) {
Text file = new Text();
ReplicationSection.getFile(entry.getKey(), file);
Status status = Status.parseFrom(entry.getValue().get());
log.info("Got status for {}: {}", file, ProtobufUtil.toString(status));
fileToStatus.put(file.toString(), status);
}
}
return fileToStatus;
}
Aggregations