Search in sources :

Example 11 with ScannerOpts

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

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

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

the class RemoveEntriesForMissingFiles method main.

public static void main(String[] args) throws Exception {
    Opts opts = new Opts();
    ScannerOpts scanOpts = new ScannerOpts();
    BatchWriterOpts bwOpts = new BatchWriterOpts();
    opts.parseArgs(RemoveEntriesForMissingFiles.class.getName(), args, scanOpts, bwOpts);
    checkAllTables(new ClientContext(opts.getInstance(), new Credentials(opts.getPrincipal(), opts.getToken()), ClientConfiguration.loadDefault()), opts.fix);
}
Also used : ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) ClientOpts(org.apache.accumulo.server.cli.ClientOpts) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) Credentials(org.apache.accumulo.core.client.impl.Credentials)

Example 14 with ScannerOpts

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

the class GarbageCollectorIT method gcTest.

@Test
public void gcTest() throws Exception {
    killMacGc();
    Connector c = getConnector();
    c.tableOperations().create("test_ingest");
    c.tableOperations().setProperty("test_ingest", Property.TABLE_SPLIT_THRESHOLD.getKey(), "5K");
    TestIngest.Opts opts = new TestIngest.Opts();
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    vopts.rows = opts.rows = 10000;
    vopts.cols = opts.cols = 1;
    opts.setPrincipal("root");
    vopts.setPrincipal("root");
    TestIngest.ingest(c, cluster.getFileSystem(), opts, new BatchWriterOpts());
    c.tableOperations().compact("test_ingest", null, null, true, true);
    int before = countFiles();
    while (true) {
        sleepUninterruptibly(1, TimeUnit.SECONDS);
        int more = countFiles();
        if (more <= before)
            break;
        before = more;
    }
    // restart GC
    getCluster().start();
    sleepUninterruptibly(15, TimeUnit.SECONDS);
    int after = countFiles();
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
    assertTrue(after < before);
}
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) Test(org.junit.Test)

Example 15 with ScannerOpts

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

the class QueryMetadataTable method main.

public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    Opts opts = new Opts();
    ScannerOpts scanOpts = new ScannerOpts();
    opts.parseArgs(QueryMetadataTable.class.getName(), args, scanOpts);
    Connector connector = opts.getConnector();
    HashSet<Text> rowSet = new HashSet<>();
    int count = 0;
    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, opts.auths)) {
        scanner.setBatchSize(scanOpts.scanBatchSize);
        Text mdrow = new Text(KeyExtent.getMetadataEntry(MetadataTable.ID, null));
        for (Entry<Key, Value> entry : scanner) {
            System.out.print(".");
            if (count % 72 == 0) {
                System.out.printf(" %,d%n", count);
            }
            if (entry.getKey().compareRow(mdrow) == 0 && entry.getKey().getColumnFamily().compareTo(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
                System.out.println(entry.getKey() + " " + entry.getValue());
                location = entry.getValue().toString();
            }
            if (!entry.getKey().getRow().toString().startsWith(MetadataTable.ID.canonicalID()))
                rowSet.add(entry.getKey().getRow());
            count++;
        }
    }
    System.out.printf(" %,d%n", count);
    ArrayList<Text> rows = new ArrayList<>(rowSet);
    Random r = new Random();
    ExecutorService tp = Executors.newFixedThreadPool(opts.numThreads);
    long t1 = System.currentTimeMillis();
    for (int i = 0; i < opts.numQueries; i++) {
        int index = r.nextInt(rows.size());
        MDTQuery mdtq = new MDTQuery(rows.get(index));
        tp.submit(mdtq);
    }
    tp.shutdown();
    try {
        tp.awaitTermination(1, TimeUnit.HOURS);
    } catch (InterruptedException e) {
        log.error("Failed while awaiting the ExcecutorService to terminate.", e);
        throw new RuntimeException(e);
    }
    long t2 = System.currentTimeMillis();
    double delta = (t2 - t1) / 1000.0;
    System.out.println("time : " + delta + "  queries per sec : " + (opts.numQueries / delta));
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) ClientOpts(org.apache.accumulo.server.cli.ClientOpts) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) Random(java.util.Random) Value(org.apache.accumulo.core.data.Value) ExecutorService(java.util.concurrent.ExecutorService) Key(org.apache.accumulo.core.data.Key) HashSet(java.util.HashSet)

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