Search in sources :

Example 36 with Connector

use of org.apache.accumulo.core.client.Connector in project accumulo by apache.

the class DeleteEverythingIT method updateMajcDelay.

@Before
public void updateMajcDelay() throws Exception {
    Connector c = getConnector();
    majcDelay = c.instanceOperations().getSystemConfiguration().get(Property.TSERV_MAJC_DELAY.getKey());
    c.instanceOperations().setProperty(Property.TSERV_MAJC_DELAY.getKey(), "1s");
    if (getClusterType() == ClusterType.STANDALONE) {
        // Gotta wait for the cluster to get out of the default sleep value
        Thread.sleep(ConfigurationTypeHelper.getTimeInMillis(majcDelay));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Before(org.junit.Before)

Example 37 with Connector

use of org.apache.accumulo.core.client.Connector in project accumulo by apache.

the class DeleteEverythingIT method run.

@Test
public void run() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
    Mutation m = new Mutation(new Text("foo"));
    m.put(new Text("bar"), new Text("1910"), new Value("5".getBytes(UTF_8)));
    bw.addMutation(m);
    bw.flush();
    getConnector().tableOperations().flush(tableName, null, null, true);
    FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 1, 1);
    m = new Mutation(new Text("foo"));
    m.putDelete(new Text("bar"), new Text("1910"));
    bw.addMutation(m);
    bw.flush();
    try (Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
        scanner.setRange(new Range());
        int count = Iterators.size(scanner.iterator());
        assertEquals("count == " + count, 0, count);
        getConnector().tableOperations().flush(tableName, null, null, true);
        getConnector().tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "1.0");
        sleepUninterruptibly(4, TimeUnit.SECONDS);
        FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
        bw.close();
        count = Iterables.size(scanner);
        if (count != 0) {
            throw new Exception("count == " + count);
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) Text(org.apache.hadoop.io.Text) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 38 with Connector

use of org.apache.accumulo.core.client.Connector in project accumulo by apache.

the class DeleteEverythingIT method resetMajcDelay.

@After
public void resetMajcDelay() throws Exception {
    Connector c = getConnector();
    c.instanceOperations().setProperty(Property.TSERV_MAJC_DELAY.getKey(), majcDelay);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) After(org.junit.After)

Example 39 with Connector

use of org.apache.accumulo.core.client.Connector in project accumulo by apache.

the class DeleteIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    AuthenticationToken token = getAdminToken();
    if (token instanceof KerberosToken) {
        deleteTest(c, getCluster(), getAdminPrincipal(), null, tableName, getAdminUser().getKeytab().getAbsolutePath());
    } else if (token instanceof PasswordToken) {
        PasswordToken passwdToken = (PasswordToken) token;
        deleteTest(c, getCluster(), getAdminPrincipal(), new String(passwdToken.getPassword(), UTF_8), tableName, null);
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) AuthenticationToken(org.apache.accumulo.core.client.security.tokens.AuthenticationToken) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) Test(org.junit.Test)

Example 40 with Connector

use of org.apache.accumulo.core.client.Connector in project accumulo by apache.

the class DeleteRowsIT method testDeleteAllRows.

@Test(timeout = 5 * 60 * 1000)
public void testDeleteAllRows() throws Exception {
    Connector c = getConnector();
    String[] tableNames = this.getUniqueNames(20);
    for (String tableName : tableNames) {
        c.tableOperations().create(tableName);
        c.tableOperations().deleteRows(tableName, null, null);
        try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
            assertEquals(0, Iterators.size(scanner.iterator()));
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) Test(org.junit.Test)

Aggregations

Connector (org.apache.accumulo.core.client.Connector)622 Test (org.junit.Test)415 BatchWriter (org.apache.accumulo.core.client.BatchWriter)171 Value (org.apache.accumulo.core.data.Value)162 Text (org.apache.hadoop.io.Text)160 Scanner (org.apache.accumulo.core.client.Scanner)158 Mutation (org.apache.accumulo.core.data.Mutation)152 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)143 Key (org.apache.accumulo.core.data.Key)139 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)101 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)87 AccumuloException (org.apache.accumulo.core.client.AccumuloException)83 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)75 Range (org.apache.accumulo.core.data.Range)74 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)65 Authorizations (org.apache.accumulo.core.security.Authorizations)60 HashSet (java.util.HashSet)57 Instance (org.apache.accumulo.core.client.Instance)55 ArrayList (java.util.ArrayList)53 Entry (java.util.Map.Entry)53