Search in sources :

Example 16 with ClientConfiguration

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

the class WriteLotsIT method writeLots.

@Test
public void writeLots() throws Exception {
    final Connector c = getConnector();
    final String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    final AtomicReference<Exception> ref = new AtomicReference<>();
    final ClientConfiguration clientConfig = getCluster().getClientConfig();
    final int THREADS = 5;
    ThreadPoolExecutor tpe = new ThreadPoolExecutor(0, THREADS, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<>(THREADS));
    for (int i = 0; i < THREADS; i++) {
        final int index = i;
        Runnable r = new Runnable() {

            @Override
            public void run() {
                try {
                    TestIngest.Opts opts = new TestIngest.Opts();
                    opts.startRow = index * 10000;
                    opts.rows = 10000;
                    opts.setTableName(tableName);
                    if (clientConfig.hasSasl()) {
                        opts.updateKerberosCredentials(clientConfig);
                    } else {
                        opts.setPrincipal(getAdminPrincipal());
                    }
                    BatchWriterOpts bwOpts = new BatchWriterOpts();
                    bwOpts.batchMemory = 1024L * 1024;
                    bwOpts.batchThreads = 2;
                    TestIngest.ingest(c, opts, new BatchWriterOpts());
                } catch (Exception ex) {
                    ref.set(ex);
                }
            }
        };
        tpe.execute(r);
    }
    tpe.shutdown();
    tpe.awaitTermination(90, TimeUnit.SECONDS);
    if (ref.get() != null) {
        throw ref.get();
    }
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    vopts.rows = 10000 * THREADS;
    vopts.setTableName(tableName);
    if (clientConfig.hasSasl()) {
        vopts.updateKerberosCredentials(clientConfig);
    } else {
        vopts.setPrincipal(getAdminPrincipal());
    }
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) AtomicReference(java.util.concurrent.atomic.AtomicReference) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) TestIngest(org.apache.accumulo.test.TestIngest) VerifyIngest(org.apache.accumulo.test.VerifyIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 17 with ClientConfiguration

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

the class RenameIT method renameTest.

@Test
public void renameTest() throws Exception {
    String[] tableNames = getUniqueNames(2);
    String name1 = tableNames[0];
    String name2 = tableNames[1];
    BatchWriterOpts bwOpts = new BatchWriterOpts();
    ScannerOpts scanOpts = new ScannerOpts();
    TestIngest.Opts opts = new TestIngest.Opts();
    opts.createTable = true;
    opts.setTableName(name1);
    final ClientConfiguration clientConfig = cluster.getClientConfig();
    if (clientConfig.hasSasl()) {
        opts.updateKerberosCredentials(clientConfig);
    } else {
        opts.setPrincipal(getAdminPrincipal());
    }
    Connector c = getConnector();
    TestIngest.ingest(c, opts, bwOpts);
    c.tableOperations().rename(name1, name2);
    TestIngest.ingest(c, opts, bwOpts);
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    if (clientConfig.hasSasl()) {
        vopts.updateKerberosCredentials(clientConfig);
    } else {
        vopts.setPrincipal(getAdminPrincipal());
    }
    vopts.setTableName(name2);
    VerifyIngest.verifyIngest(c, vopts, scanOpts);
    c.tableOperations().delete(name1);
    c.tableOperations().rename(name2, name1);
    vopts.setTableName(name1);
    VerifyIngest.verifyIngest(c, vopts, scanOpts);
    FunctionalTestUtils.assertNoDanglingFateLocks(getConnector().getInstance(), getCluster());
}
Also used : ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) Connector(org.apache.accumulo.core.client.Connector) 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) Test(org.junit.Test)

Example 18 with ClientConfiguration

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

the class RestartIT method killedTabletServerDuringShutdown.

@Test
public void killedTabletServerDuringShutdown() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    OPTS.setTableName(tableName);
    ClientConfiguration clientConfig = cluster.getClientConfig();
    if (clientConfig.hasSasl()) {
        OPTS.updateKerberosCredentials(clientConfig);
    } else {
        OPTS.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, OPTS, BWOPTS);
    try {
        getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
        getCluster().getClusterControl().adminStopAll();
    } finally {
        getCluster().start();
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 19 with ClientConfiguration

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

the class RestartIT method restartMasterSplit.

@Test
public void restartMasterSplit() throws Exception {
    Connector c = getConnector();
    final String tableName = getUniqueNames(1)[0];
    final AuthenticationToken token = getAdminToken();
    final ClusterControl control = getCluster().getClusterControl();
    VOPTS.setTableName(tableName);
    c.tableOperations().create(tableName);
    c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "5K");
    final String[] args;
    if (token instanceof PasswordToken) {
        byte[] password = ((PasswordToken) token).getPassword();
        args = new String[] { "-u", getAdminPrincipal(), "-p", new String(password, UTF_8), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", Integer.toString(VOPTS.rows), "--table", tableName };
        OPTS.setPrincipal(getAdminPrincipal());
        VOPTS.setPrincipal(getAdminPrincipal());
    } else if (token instanceof KerberosToken) {
        ClusterUser rootUser = getAdminUser();
        args = new String[] { "-u", getAdminPrincipal(), "--keytab", rootUser.getKeytab().getAbsolutePath(), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", Integer.toString(VOPTS.rows), "--table", tableName };
        ClientConfiguration clientConfig = cluster.getClientConfig();
        OPTS.updateKerberosCredentials(clientConfig);
        VOPTS.updateKerberosCredentials(clientConfig);
    } else {
        throw new RuntimeException("Unknown token");
    }
    Future<Integer> ret = svc.submit(new Callable<Integer>() {

        @Override
        public Integer call() {
            try {
                return control.exec(TestIngest.class, args);
            } catch (Exception e) {
                log.error("Error running TestIngest", e);
                return -1;
            }
        }
    });
    control.stopAllServers(ServerType.MASTER);
    ZooReader zreader = new ZooReader(c.getInstance().getZooKeepers(), c.getInstance().getZooKeepersSessionTimeOut());
    ZooCache zcache = new ZooCache(zreader, null);
    byte[] masterLockData;
    do {
        masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null);
        if (null != masterLockData) {
            log.info("Master lock is still held");
            Thread.sleep(1000);
        }
    } while (null != masterLockData);
    cluster.start();
    assertEquals(0, ret.get().intValue());
    VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AuthenticationToken(org.apache.accumulo.core.client.security.tokens.AuthenticationToken) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache) IOException(java.io.IOException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) TestIngest(org.apache.accumulo.test.TestIngest) ClusterUser(org.apache.accumulo.cluster.ClusterUser) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) ClusterControl(org.apache.accumulo.cluster.ClusterControl) Test(org.junit.Test)

Example 20 with ClientConfiguration

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

the class RestartIT method killedTabletServer.

@Test
public void killedTabletServer() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    OPTS.setTableName(tableName);
    VOPTS.setTableName(tableName);
    ClientConfiguration clientConfig = cluster.getClientConfig();
    if (clientConfig.hasSasl()) {
        OPTS.updateKerberosCredentials(clientConfig);
        VOPTS.updateKerberosCredentials(clientConfig);
    } else {
        OPTS.setPrincipal(getAdminPrincipal());
        VOPTS.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, OPTS, BWOPTS);
    VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
    cluster.getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
    cluster.start();
    VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Aggregations

ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)78 Test (org.junit.Test)40 Connector (org.apache.accumulo.core.client.Connector)28 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)27 IOException (java.io.IOException)16 TestIngest (org.apache.accumulo.test.TestIngest)15 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)13 ScannerOpts (org.apache.accumulo.core.cli.ScannerOpts)12 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)12 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)11 VerifyIngest (org.apache.accumulo.test.VerifyIngest)11 ClusterUser (org.apache.accumulo.cluster.ClusterUser)9 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)8 Map (java.util.Map)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)6 Instance (org.apache.accumulo.core.client.Instance)6 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)6 Authorizations (org.apache.accumulo.core.security.Authorizations)6 Path (org.apache.hadoop.fs.Path)6