use of org.apache.accumulo.proxy.thrift.CompactionStrategyConfig in project accumulo by apache.
the class ProxyServer method compactTable.
@Override
public void compactTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow, List<org.apache.accumulo.proxy.thrift.IteratorSetting> iterators, boolean flush, boolean wait, CompactionStrategyConfig compactionStrategy) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException, TException {
try {
CompactionConfig compactionConfig = new CompactionConfig().setStartRow(ByteBufferUtil.toText(startRow)).setEndRow(ByteBufferUtil.toText(endRow)).setIterators(getIteratorSettings(iterators)).setFlush(flush).setWait(wait);
if (compactionStrategy != null) {
org.apache.accumulo.core.client.admin.CompactionStrategyConfig ccc = new org.apache.accumulo.core.client.admin.CompactionStrategyConfig(compactionStrategy.getClassName());
if (compactionStrategy.options != null)
ccc.setOptions(compactionStrategy.options);
compactionConfig.setCompactionStrategy(ccc);
}
getConnector(login).tableOperations().compact(tableName, compactionConfig);
} catch (Exception e) {
handleExceptionTNF(e);
}
}
use of org.apache.accumulo.proxy.thrift.CompactionStrategyConfig in project accumulo by apache.
the class SimpleProxyBase method testCompactionStrategy.
@Test
public void testCompactionStrategy() throws Exception {
File jarDir = new File(System.getProperty("user.dir"), "target");
assertTrue(jarDir.mkdirs() || jarDir.isDirectory());
File jarFile = new File(jarDir, "TestCompactionStrat.jar");
FileUtils.copyInputStreamToFile(Class.class.getResourceAsStream("/TestCompactionStrat.jar"), jarFile);
client.setProperty(creds, Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "context1", jarFile.toString());
client.setTableProperty(creds, tableName, Property.TABLE_CLASSPATH.getKey(), "context1");
client.addSplits(creds, tableName, Collections.singleton(s2bb("efg")));
client.updateAndFlush(creds, tableName, mutation("a", "cf", "cq", "v1"));
client.flushTable(creds, tableName, null, null, true);
client.updateAndFlush(creds, tableName, mutation("b", "cf", "cq", "v2"));
client.flushTable(creds, tableName, null, null, true);
client.updateAndFlush(creds, tableName, mutation("y", "cf", "cq", "v1"));
client.flushTable(creds, tableName, null, null, true);
client.updateAndFlush(creds, tableName, mutation("z", "cf", "cq", "v2"));
client.flushTable(creds, tableName, null, null, true);
assertEquals(4, countFiles(tableName));
CompactionStrategyConfig csc = new CompactionStrategyConfig();
// The EfgCompactionStrat will only compact tablets with and end row of efg
csc.setClassName("org.apache.accumulo.test.EfgCompactionStrat");
client.compactTable(creds, tableName, null, null, null, true, true, csc);
assertEquals(3, countFiles(tableName));
}
Aggregations