Search in sources :

Example 6 with ScannerOpts

use of org.apache.accumulo.core.cli.ScannerOpts in project accumulo by apache.

the class DeleteIT method deleteTest.

public static void deleteTest(Connector c, AccumuloCluster cluster, String user, String password, String tableName, String keytab) throws Exception {
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    TestIngest.Opts opts = new TestIngest.Opts();
    vopts.setTableName(tableName);
    opts.setTableName(tableName);
    vopts.rows = opts.rows = 1000;
    vopts.cols = opts.cols = 1;
    vopts.random = opts.random = 56;
    assertTrue("Expected one of password or keytab", null != password || null != keytab);
    if (null != password) {
        assertNull("Given password, expected null keytab", keytab);
        Password passwd = new Password(password);
        opts.setPassword(passwd);
        opts.setPrincipal(user);
        vopts.setPassword(passwd);
        vopts.setPrincipal(user);
    }
    if (null != keytab) {
        assertNull("Given keytab, expect null password", password);
        ClientConfiguration clientConfig = cluster.getClientConfig();
        opts.updateKerberosCredentials(clientConfig);
        vopts.updateKerberosCredentials(clientConfig);
    }
    BatchWriterOpts BWOPTS = new BatchWriterOpts();
    TestIngest.ingest(c, opts, BWOPTS);
    String[] args = null;
    assertTrue("Expected one of password or keytab", null != password || null != keytab);
    if (null != password) {
        assertNull("Given password, expected null keytab", keytab);
        args = new String[] { "-u", user, "-p", password, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--table", tableName };
    }
    if (null != keytab) {
        assertNull("Given keytab, expect null password", password);
        args = new String[] { "-u", user, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--table", tableName, "--keytab", keytab };
    }
    assertEquals(0, cluster.getClusterControl().exec(TestRandomDeletes.class, args));
    TestIngest.ingest(c, opts, BWOPTS);
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
}
Also used : ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) VerifyIngest(org.apache.accumulo.test.VerifyIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) TestIngest(org.apache.accumulo.test.TestIngest) TestRandomDeletes(org.apache.accumulo.test.TestRandomDeletes) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Password(org.apache.accumulo.core.cli.ClientOpts.Password)

Example 7 with ScannerOpts

use of org.apache.accumulo.core.cli.ScannerOpts 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 8 with ScannerOpts

use of org.apache.accumulo.core.cli.ScannerOpts in project accumulo by apache.

the class ReadWriteIT method verify.

private static void verify(Connector connector, ClientConfiguration clientConfig, String principal, int rows, int cols, int width, int offset, String colf, String tableName) throws Exception {
    ScannerOpts scannerOpts = new ScannerOpts();
    VerifyIngest.Opts opts = new VerifyIngest.Opts();
    opts.rows = rows;
    opts.cols = cols;
    opts.dataSize = width;
    opts.startRow = offset;
    opts.columnFamily = colf;
    opts.setTableName(tableName);
    if (clientConfig.hasSasl()) {
        opts.updateKerberosCredentials(clientConfig);
    } else {
        opts.setPrincipal(principal);
    }
    VerifyIngest.verifyIngest(connector, opts, scannerOpts);
}
Also used : ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) VerifyIngest(org.apache.accumulo.test.VerifyIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts)

Example 9 with ScannerOpts

use of org.apache.accumulo.core.cli.ScannerOpts in project accumulo by apache.

the class TableIT method test.

@Test
public void test() throws Exception {
    Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
    AccumuloCluster cluster = getCluster();
    MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) cluster;
    String rootPath = mac.getConfig().getDir().getAbsolutePath();
    Connector c = getConnector();
    TableOperations to = c.tableOperations();
    String tableName = getUniqueNames(1)[0];
    to.create(tableName);
    TestIngest.Opts opts = new TestIngest.Opts();
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    ClientConfiguration clientConfig = getCluster().getClientConfig();
    if (clientConfig.hasSasl()) {
        opts.updateKerberosCredentials(clientConfig);
        vopts.updateKerberosCredentials(clientConfig);
    } else {
        opts.setPrincipal(getAdminPrincipal());
        vopts.setPrincipal(getAdminPrincipal());
    }
    opts.setTableName(tableName);
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    to.flush(tableName, null, null, true);
    vopts.setTableName(tableName);
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
    Table.ID id = Table.ID.of(to.tableIdMap().get(tableName));
    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
        s.setRange(new KeyExtent(id, null, null).toMetadataRange());
        s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
        assertTrue(Iterators.size(s.iterator()) > 0);
        FileSystem fs = getCluster().getFileSystem();
        assertTrue(fs.listStatus(new Path(rootPath + "/accumulo/tables/" + id)).length > 0);
        to.delete(tableName);
        assertEquals(0, Iterators.size(s.iterator()));
        try {
            assertEquals(0, fs.listStatus(new Path(rootPath + "/accumulo/tables/" + id)).length);
        } catch (FileNotFoundException ex) {
        // that's fine, too
        }
        assertNull(to.tableIdMap().get(tableName));
        to.create(tableName);
        TestIngest.ingest(c, opts, new BatchWriterOpts());
        VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
        to.delete(tableName);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) 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) AccumuloCluster(org.apache.accumulo.cluster.AccumuloCluster) FileNotFoundException(java.io.FileNotFoundException) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) TestIngest(org.apache.accumulo.test.TestIngest) VerifyIngest(org.apache.accumulo.test.VerifyIngest) FileSystem(org.apache.hadoop.fs.FileSystem) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) MiniAccumuloClusterImpl(org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 10 with ScannerOpts

use of org.apache.accumulo.core.cli.ScannerOpts in project accumulo by apache.

the class WriteAheadLogIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "750K");
    TestIngest.Opts opts = new TestIngest.Opts();
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    opts.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, new BatchWriterOpts());
    vopts.setTableName(tableName);
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
    getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
    getCluster().getClusterControl().startAllServers(ServerType.TABLET_SERVER);
    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) Test(org.junit.Test)

Aggregations

ScannerOpts (org.apache.accumulo.core.cli.ScannerOpts)25 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)16 Connector (org.apache.accumulo.core.client.Connector)14 VerifyIngest (org.apache.accumulo.test.VerifyIngest)14 Test (org.junit.Test)13 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)11 TestIngest (org.apache.accumulo.test.TestIngest)11 ArrayList (java.util.ArrayList)4 ExecutorService (java.util.concurrent.ExecutorService)3 Password (org.apache.accumulo.core.cli.ClientOpts.Password)3 Scanner (org.apache.accumulo.core.client.Scanner)3 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)3 Credentials (org.apache.accumulo.core.client.impl.Credentials)3 Table (org.apache.accumulo.core.client.impl.Table)3 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)3 Value (org.apache.accumulo.core.data.Value)3 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 Path (org.apache.hadoop.fs.Path)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2