Search in sources :

Example 1 with CompactionStrategyConfig

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);
    }
}
Also used : CompactionStrategyConfig(org.apache.accumulo.proxy.thrift.CompactionStrategyConfig) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TException(org.apache.thrift.TException) NoMoreEntriesException(org.apache.accumulo.proxy.thrift.NoMoreEntriesException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NamespaceNotEmptyException(org.apache.accumulo.core.client.NamespaceNotEmptyException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Example 2 with CompactionStrategyConfig

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));
}
Also used : CompactionStrategyConfig(org.apache.accumulo.proxy.thrift.CompactionStrategyConfig) AfterClass(org.junit.AfterClass) File(java.io.File) Test(org.junit.Test)

Aggregations

CompactionStrategyConfig (org.apache.accumulo.proxy.thrift.CompactionStrategyConfig)2 File (java.io.File)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)1 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)1 NamespaceNotEmptyException (org.apache.accumulo.core.client.NamespaceNotEmptyException)1 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)1 TableExistsException (org.apache.accumulo.core.client.TableExistsException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)1 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)1 NoMoreEntriesException (org.apache.accumulo.proxy.thrift.NoMoreEntriesException)1 TException (org.apache.thrift.TException)1 AfterClass (org.junit.AfterClass)1 Test (org.junit.Test)1