Search in sources :

Example 1 with IngestParams

use of org.apache.accumulo.test.TestIngest.IngestParams in project accumulo by apache.

the class WriteLotsIT method writeLots.

@Test
public void writeLots() throws Exception {
    BatchWriterConfig bwConfig = new BatchWriterConfig();
    bwConfig.setMaxMemory(1024L * 1024);
    bwConfig.setMaxWriteThreads(2);
    try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).batchWriterConfig(bwConfig).build()) {
        final String tableName = getUniqueNames(1)[0];
        c.tableOperations().create(tableName);
        final AtomicReference<Exception> ref = new AtomicReference<>();
        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 = () -> {
                try {
                    IngestParams ingestParams = new IngestParams(getClientProps(), tableName, 10_000);
                    ingestParams.startRow = index * 10000;
                    TestIngest.ingest(c, ingestParams);
                } catch (Exception ex) {
                    ref.set(ex);
                }
            };
            tpe.execute(r);
        }
        tpe.shutdown();
        tpe.awaitTermination(90, TimeUnit.SECONDS);
        if (ref.get() != null) {
            throw ref.get();
        }
        VerifyParams params = new VerifyParams(getClientProps(), tableName, 10_000 * THREADS);
        VerifyIngest.verifyIngest(c, params);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) VerifyParams(org.apache.accumulo.test.VerifyIngest.VerifyParams) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) IngestParams(org.apache.accumulo.test.TestIngest.IngestParams) AtomicReference(java.util.concurrent.atomic.AtomicReference) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Test(org.junit.Test)

Example 2 with IngestParams

use of org.apache.accumulo.test.TestIngest.IngestParams in project accumulo by apache.

the class RestartIT method killedTabletServerDuringShutdown.

@Test
public void killedTabletServerDuringShutdown() throws Exception {
    try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
        String tableName = getUniqueNames(1)[0];
        c.tableOperations().create(tableName);
        IngestParams params = new IngestParams(getClientProps(), tableName, 10_000);
        TestIngest.ingest(c, params);
        try {
            getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
            getCluster().getClusterControl().adminStopAll();
        } finally {
            // make sure processes are cleaned up before we restart clean for other tests
            getCluster().stop();
            getCluster().start();
        }
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) IngestParams(org.apache.accumulo.test.TestIngest.IngestParams) Test(org.junit.Test)

Example 3 with IngestParams

use of org.apache.accumulo.test.TestIngest.IngestParams in project accumulo by apache.

the class FateStarvationIT method run.

@Test
public void run() throws Exception {
    String tableName = getUniqueNames(1)[0];
    try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
        var ntc = new NewTableConfiguration().withSplits(TestIngest.getSplitPoints(0, 100000, 50));
        c.tableOperations().create(tableName, ntc);
        IngestParams params = new IngestParams(getClientProps(), tableName, 100_000);
        params.random = 89;
        params.timestamp = 7;
        params.dataSize = 50;
        params.cols = 1;
        TestIngest.ingest(c, params);
        c.tableOperations().flush(tableName, null, null, true);
        List<Text> splits = new ArrayList<>(TestIngest.getSplitPoints(0, 100000, 67));
        for (int i = 0; i < 100; i++) {
            int idx1 = random.nextInt(splits.size() - 1);
            int idx2 = random.nextInt(splits.size() - (idx1 + 1)) + idx1 + 1;
            c.tableOperations().compact(tableName, splits.get(idx1), splits.get(idx2), false, false);
        }
        c.tableOperations().offline(tableName);
        FunctionalTestUtils.assertNoDanglingFateLocks((ClientContext) c, getCluster());
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) ArrayList(java.util.ArrayList) IngestParams(org.apache.accumulo.test.TestIngest.IngestParams) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 4 with IngestParams

use of org.apache.accumulo.test.TestIngest.IngestParams in project accumulo by apache.

the class MaxOpenIT method run.

@Test
public void run() throws Exception {
    try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
        final String tableName = getUniqueNames(1)[0];
        HashMap<String, String> props = new HashMap<>();
        props.put(Property.TABLE_MAJC_RATIO.getKey(), "10");
        NewTableConfiguration ntc = new NewTableConfiguration().setProperties(props).withSplits(TestIngest.getSplitPoints(0, NUM_TO_INGEST, NUM_TABLETS));
        c.tableOperations().create(tableName, ntc);
        // the following loop should create three tablets in each map file
        for (int i = 0; i < 3; i++) {
            IngestParams params = new IngestParams(getClientProps(), tableName, NUM_TO_INGEST);
            params.timestamp = i;
            params.dataSize = 50;
            params.rows = NUM_TO_INGEST;
            params.cols = 1;
            params.random = i;
            TestIngest.ingest(c, params);
            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 : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) HashMap(java.util.HashMap) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) ArrayList(java.util.ArrayList) IngestParams(org.apache.accumulo.test.TestIngest.IngestParams) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 5 with IngestParams

use of org.apache.accumulo.test.TestIngest.IngestParams in project accumulo by apache.

the class ReadWriteIT method ingest.

public static void ingest(AccumuloClient accumuloClient, ClientInfo info, int rows, int cols, int width, int offset, String colf, String tableName) throws Exception {
    IngestParams params = new IngestParams(info.getProperties(), tableName, rows);
    params.cols = cols;
    params.dataSize = width;
    params.startRow = offset;
    params.columnFamily = colf;
    params.createTable = true;
    TestIngest.ingest(accumuloClient, params);
}
Also used : IngestParams(org.apache.accumulo.test.TestIngest.IngestParams)

Aggregations

IngestParams (org.apache.accumulo.test.TestIngest.IngestParams)6 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)2 VerifyParams (org.apache.accumulo.test.VerifyIngest.VerifyParams)2 HashMap (java.util.HashMap)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 Range (org.apache.accumulo.core.data.Range)1 Path (org.apache.hadoop.fs.Path)1 Text (org.apache.hadoop.io.Text)1