Search in sources :

Example 91 with Connector

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

the class LogicalTimeIT method run.

@Test
public void run() throws Exception {
    int tc = 0;
    String tableName = getUniqueNames(1)[0];
    Connector c = getConnector();
    runMergeTest(c, tableName + tc++, new String[] { "m" }, new String[] { "a" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "m" }, new String[] { "z" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "m" }, new String[] { "a", "z" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "m" }, new String[] { "a", "c", "z" }, null, null, "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "m" }, new String[] { "a", "y", "z" }, null, null, "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "h" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "s" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a", "h", "s" }, null, null, "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a", "c", "h", "s" }, null, null, "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a", "h", "s", "i" }, null, null, "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "t", "a", "h", "s" }, null, null, "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a" }, null, "h", "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "h" }, null, "h", "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "s" }, null, "h", "b", 1l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a", "h", "s" }, null, "h", "b", 2l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a", "c", "h", "s" }, null, "h", "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "a", "h", "s", "i" }, null, "h", "b", 3l);
    runMergeTest(c, tableName + tc++, new String[] { "g", "r" }, new String[] { "t", "a", "h", "s" }, null, "h", "b", 2l);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Test(org.junit.Test)

Example 92 with Connector

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

the class MasterAssignmentIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String tableName = super.getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    String tableId = c.tableOperations().tableIdMap().get(tableName);
    // wait for the table to be online
    TabletLocationState newTablet;
    do {
        UtilWaitThread.sleep(250);
        newTablet = getTabletLocationState(c, tableId);
    } while (newTablet.current == null);
    assertNull(newTablet.last);
    assertNull(newTablet.future);
    // put something in it
    BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
    Mutation m = new Mutation("a");
    m.put("b", "c", "d");
    bw.addMutation(m);
    bw.close();
    // give it a last location
    c.tableOperations().flush(tableName, null, null, true);
    TabletLocationState flushed = getTabletLocationState(c, tableId);
    assertEquals(newTablet.current, flushed.current);
    assertEquals(flushed.current, flushed.last);
    assertNull(newTablet.future);
    // take the tablet offline
    c.tableOperations().offline(tableName, true);
    TabletLocationState offline = getTabletLocationState(c, tableId);
    assertNull(offline.future);
    assertNull(offline.current);
    assertEquals(flushed.current, offline.last);
    // put it back online
    c.tableOperations().online(tableName, true);
    TabletLocationState online = getTabletLocationState(c, tableId);
    assertNull(online.future);
    assertNotNull(online.current);
    assertEquals(online.current, online.last);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) TabletLocationState(org.apache.accumulo.server.master.state.TabletLocationState) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Test(org.junit.Test)

Example 93 with Connector

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

the class MasterFailoverIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String[] names = getUniqueNames(2);
    c.tableOperations().create(names[0]);
    TestIngest.Opts opts = new TestIngest.Opts();
    opts.setTableName(names[0]);
    ClientConfiguration clientConf = cluster.getClientConfig();
    if (clientConf.hasSasl()) {
        opts.updateKerberosCredentials(clientConf);
    } else {
        opts.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    ClusterControl control = cluster.getClusterControl();
    control.stopAllServers(ServerType.MASTER);
    // start up a new one
    control.startAllServers(ServerType.MASTER);
    // talk to it
    c.tableOperations().rename(names[0], names[1]);
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    vopts.setTableName(names[1]);
    if (clientConf.hasSasl()) {
        vopts.updateKerberosCredentials(clientConf);
    } else {
        vopts.setPrincipal(getAdminPrincipal());
    }
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) TestIngest(org.apache.accumulo.test.TestIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) VerifyIngest(org.apache.accumulo.test.VerifyIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) ClusterControl(org.apache.accumulo.cluster.ClusterControl) Test(org.junit.Test)

Example 94 with Connector

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

the class MaxOpenIT method run.

@Test
public void run() throws Exception {
    final Connector c = getConnector();
    final String tableName = getUniqueNames(1)[0];
    final ClientConfiguration clientConf = cluster.getClientConfig();
    c.tableOperations().create(tableName);
    c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "10");
    c.tableOperations().addSplits(tableName, TestIngest.getSplitPoints(0, NUM_TO_INGEST, NUM_TABLETS));
    // the following loop should create three tablets in each map file
    for (int i = 0; i < 3; i++) {
        TestIngest.Opts opts = new TestIngest.Opts();
        opts.timestamp = i;
        opts.dataSize = 50;
        opts.rows = NUM_TO_INGEST;
        opts.cols = 1;
        opts.random = i;
        opts.setTableName(tableName);
        if (clientConf.hasSasl()) {
            opts.updateKerberosCredentials(clientConf);
        } else {
            opts.setPrincipal(getAdminPrincipal());
        }
        TestIngest.ingest(c, opts, new BatchWriterOpts());
        c.tableOperations().flush(tableName, null, null, true);
        FunctionalTestUtils.checkRFiles(c, tableName, NUM_TABLETS, NUM_TABLETS, i + 1, i + 1);
    }
    List<Range> ranges = new ArrayList<>(NUM_TO_INGEST);
    for (int i = 0; i < NUM_TO_INGEST; i++) {
        ranges.add(new Range(TestIngest.generateRow(i, 0)));
    }
    long time1 = batchScan(c, tableName, ranges, 1);
    // run it again, now that stuff is cached on the client and sever
    time1 = batchScan(c, tableName, ranges, 1);
    long time2 = batchScan(c, tableName, ranges, NUM_TABLETS);
    System.out.printf("Single thread scan time   %6.2f %n", time1 / 1000.0);
    System.out.printf("Multiple thread scan time %6.2f %n", time2 / 1000.0);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) TestIngest(org.apache.accumulo.test.TestIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ArrayList(java.util.ArrayList) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) Range(org.apache.accumulo.core.data.Range) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 95 with Connector

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

the class MergeIT method merge.

@Test
public void merge() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    c.tableOperations().addSplits(tableName, splits("a b c d e f g h i j k".split(" ")));
    BatchWriter bw = c.createBatchWriter(tableName, null);
    for (String row : "a b c d e f g h i j k".split(" ")) {
        Mutation m = new Mutation(row);
        m.put("cf", "cq", "value");
        bw.addMutation(m);
    }
    bw.close();
    c.tableOperations().flush(tableName, null, null, true);
    c.tableOperations().merge(tableName, new Text("c1"), new Text("f1"));
    assertEquals(8, c.tableOperations().listSplits(tableName).size());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Text(org.apache.hadoop.io.Text) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) 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