Search in sources :

Example 36 with ClusterUser

use of org.apache.accumulo.cluster.ClusterUser in project accumulo by apache.

the class SplitIT method tabletShouldSplit.

@Test
public void tabletShouldSplit() throws Exception {
    Connector c = getConnector();
    String table = getUniqueNames(1)[0];
    c.tableOperations().create(table);
    c.tableOperations().setProperty(table, Property.TABLE_SPLIT_THRESHOLD.getKey(), "256K");
    c.tableOperations().setProperty(table, Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "1K");
    TestIngest.Opts opts = new TestIngest.Opts();
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    opts.rows = 100000;
    opts.setTableName(table);
    ClientConfiguration clientConfig = cluster.getClientConfig();
    if (clientConfig.hasSasl()) {
        opts.updateKerberosCredentials(clientConfig);
        vopts.updateKerberosCredentials(clientConfig);
    } else {
        opts.setPrincipal(getAdminPrincipal());
        vopts.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    vopts.rows = opts.rows;
    vopts.setTableName(table);
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
    while (c.tableOperations().listSplits(table).size() < 10) {
        sleepUninterruptibly(15, TimeUnit.SECONDS);
    }
    Table.ID id = Table.ID.of(c.tableOperations().tableIdMap().get(table));
    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
        KeyExtent extent = new KeyExtent(id, null, null);
        s.setRange(extent.toMetadataRange());
        MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(s);
        int count = 0;
        int shortened = 0;
        for (Entry<Key, Value> entry : s) {
            extent = new KeyExtent(entry.getKey().getRow(), entry.getValue());
            if (extent.getEndRow() != null && extent.getEndRow().toString().length() < 14)
                shortened++;
            count++;
        }
        assertTrue("Shortened should be greater than zero: " + shortened, shortened > 0);
        assertTrue("Count should be cgreater than 10: " + count, count > 10);
    }
    String[] args;
    if (clientConfig.hasSasl()) {
        ClusterUser rootUser = getAdminUser();
        args = new String[] { "-i", cluster.getInstanceName(), "-u", rootUser.getPrincipal(), "--keytab", rootUser.getKeytab().getAbsolutePath(), "-z", cluster.getZooKeepers() };
    } else {
        PasswordToken token = (PasswordToken) getAdminToken();
        args = new String[] { "-i", cluster.getInstanceName(), "-u", "root", "-p", new String(token.getPassword(), UTF_8), "-z", cluster.getZooKeepers() };
    }
    assertEquals(0, getCluster().getClusterControl().exec(CheckForMetadataProblems.class, args));
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) Table(org.apache.accumulo.core.client.impl.Table) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) CheckForMetadataProblems(org.apache.accumulo.server.util.CheckForMetadataProblems) TestIngest(org.apache.accumulo.test.TestIngest) VerifyIngest(org.apache.accumulo.test.VerifyIngest) Value(org.apache.accumulo.core.data.Value) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ClusterUser(org.apache.accumulo.cluster.ClusterUser) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

ClusterUser (org.apache.accumulo.cluster.ClusterUser)36 Connector (org.apache.accumulo.core.client.Connector)22 Test (org.junit.Test)21 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)19 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)10 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)10 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)9 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)7 Before (org.junit.Before)7 Client (org.apache.accumulo.proxy.thrift.AccumuloProxy.Client)6 IOException (java.io.IOException)5 ByteBuffer (java.nio.ByteBuffer)5 Scanner (org.apache.accumulo.core.client.Scanner)5 Configuration (org.apache.hadoop.conf.Configuration)5 File (java.io.File)4 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)4 ClusterControl (org.apache.accumulo.cluster.ClusterControl)3 BatchWriter (org.apache.accumulo.core.client.BatchWriter)3 Key (org.apache.accumulo.core.data.Key)3 Mutation (org.apache.accumulo.core.data.Mutation)3