Search in sources :

Example 26 with Connector

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

the class BadIteratorMincIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    IteratorSetting is = new IteratorSetting(30, BadIterator.class);
    c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
    BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
    Mutation m = new Mutation(new Text("r1"));
    m.put(new Text("acf"), new Text(tableName), new Value("1".getBytes(UTF_8)));
    bw.addMutation(m);
    bw.close();
    c.tableOperations().flush(tableName, null, null, false);
    sleepUninterruptibly(1, TimeUnit.SECONDS);
    // minc should fail, so there should be no files
    FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
    // try to scan table
    try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
        int count = Iterators.size(scanner.iterator());
        assertEquals("Did not see expected # entries " + count, 1, count);
        // remove the bad iterator
        c.tableOperations().removeIterator(tableName, BadIterator.class.getSimpleName(), EnumSet.of(IteratorScope.minc));
        sleepUninterruptibly(5, TimeUnit.SECONDS);
        // minc should complete
        FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 1, 1);
        count = Iterators.size(scanner.iterator());
        if (count != 1)
            throw new Exception("Did not see expected # entries " + count);
        // now try putting bad iterator back and deleting the table
        c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
        bw = c.createBatchWriter(tableName, new BatchWriterConfig());
        m = new Mutation(new Text("r2"));
        m.put(new Text("acf"), new Text(tableName), new Value("1".getBytes(UTF_8)));
        bw.addMutation(m);
        bw.close();
        // make sure property is given time to propagate
        sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
        c.tableOperations().flush(tableName, null, null, false);
        // make sure the flush has time to start
        sleepUninterruptibly(1, TimeUnit.SECONDS);
        // this should not hang
        c.tableOperations().delete(tableName);
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) 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) Test(org.junit.Test)

Example 27 with Connector

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

the class BalanceAfterCommsFailureIT method test.

@Test
public void test() throws Exception {
    Connector c = this.getConnector();
    c.tableOperations().create("test");
    Collection<ProcessReference> tservers = getCluster().getProcesses().get(ServerType.TABLET_SERVER);
    ArrayList<Integer> tserverPids = new ArrayList<>(tservers.size());
    for (ProcessReference tserver : tservers) {
        Process p = tserver.getProcess();
        if (!p.getClass().getName().equals("java.lang.UNIXProcess")) {
            log.info("Found process that was not UNIXProcess, exiting test");
            return;
        }
        Field f = p.getClass().getDeclaredField("pid");
        f.setAccessible(true);
        tserverPids.add(f.getInt(p));
    }
    for (int pid : tserverPids) {
        assertEquals(0, Runtime.getRuntime().exec(new String[] { "kill", "-SIGSTOP", Integer.toString(pid) }).waitFor());
    }
    UtilWaitThread.sleep(20 * 1000);
    for (int pid : tserverPids) {
        assertEquals(0, Runtime.getRuntime().exec(new String[] { "kill", "-SIGCONT", Integer.toString(pid) }).waitFor());
    }
    SortedSet<Text> splits = new TreeSet<>();
    for (String split : "a b c d e f g h i j k l m n o p q r s t u v w x y z".split(" ")) {
        splits.add(new Text(split));
    }
    c.tableOperations().addSplits("test", splits);
    // Ensure all of the tablets are actually assigned
    assertEquals(0, Iterables.size(c.createScanner("test", Authorizations.EMPTY)));
    UtilWaitThread.sleep(30 * 1000);
    checkBalance(c);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ProcessReference(org.apache.accumulo.minicluster.impl.ProcessReference) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) Field(java.lang.reflect.Field) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 28 with Connector

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

the class BalanceInPresenceOfOfflineTableIT method setupTables.

@Before
public void setupTables() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    Connector conn = getConnector();
    // Need at least two tservers
    Assume.assumeTrue("Not enough tservers to run test", conn.instanceOperations().getTabletServers().size() >= 2);
    // set up splits
    final SortedSet<Text> splits = new TreeSet<>();
    for (int i = 0; i < NUM_SPLITS; i++) {
        splits.add(new Text(String.format("%08x", i * 1000)));
    }
    String[] names = getUniqueNames(2);
    UNUSED_TABLE = names[0];
    TEST_TABLE = names[1];
    // load into a table we won't use
    connector = getConnector();
    connector.tableOperations().create(UNUSED_TABLE);
    connector.tableOperations().addSplits(UNUSED_TABLE, splits);
    // mark the table offline before it can rebalance.
    connector.tableOperations().offline(UNUSED_TABLE);
    // actual test table
    connector.tableOperations().create(TEST_TABLE);
    connector.tableOperations().setProperty(TEST_TABLE, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K");
}
Also used : Connector(org.apache.accumulo.core.client.Connector) TreeSet(java.util.TreeSet) Text(org.apache.hadoop.io.Text) Before(org.junit.Before)

Example 29 with Connector

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

the class BatchWriterFlushIT method run.

@Test
public void run() throws Exception {
    Connector c = getConnector();
    String[] tableNames = getUniqueNames(2);
    String bwft = tableNames[0];
    c.tableOperations().create(bwft);
    String bwlt = tableNames[1];
    c.tableOperations().create(bwlt);
    runFlushTest(bwft);
    runLatencyTest(bwlt);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Test(org.junit.Test)

Example 30 with Connector

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

the class DeletedTablesDontFlushIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    IteratorSetting setting = new IteratorSetting(100, SlowIterator.class);
    SlowIterator.setSleepTime(setting, 1000);
    c.tableOperations().attachIterator(tableName, setting, EnumSet.of(IteratorScope.minc));
    // let the configuration change propagate through zookeeper
    UtilWaitThread.sleep(1000);
    Mutation m = new Mutation("xyzzy");
    for (int i = 0; i < 100; i++) {
        m.put("cf", "" + i, new Value(new byte[] {}));
    }
    BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
    bw.addMutation(m);
    bw.close();
    // should go fast
    c.tableOperations().delete(tableName);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) Mutation(org.apache.accumulo.core.data.Mutation) BatchWriter(org.apache.accumulo.core.client.BatchWriter) 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