Search in sources :

Example 1 with TestContext

use of org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext in project hbase by apache.

the class TestHRegionServerBulkLoadWithOldClient method runAtomicBulkloadTest.

void runAtomicBulkloadTest(TableName tableName, int millisToRun, int numScanners) throws Exception {
    setupTable(tableName, 10);
    TestContext ctx = new TestContext(UTIL.getConfiguration());
    AtomicHFileLoader loader = new AtomicHFileLoader(tableName, ctx, null);
    ctx.addThread(loader);
    List<AtomicScanReader> scanners = Lists.newArrayList();
    for (int i = 0; i < numScanners; i++) {
        AtomicScanReader scanner = new AtomicScanReader(tableName, ctx, families);
        scanners.add(scanner);
        ctx.addThread(scanner);
    }
    ctx.startThreads();
    ctx.waitFor(millisToRun);
    ctx.stop();
    LOG.info("Loaders:");
    LOG.info("  loaded " + loader.numBulkLoads.get());
    LOG.info("  compations " + loader.numCompactions.get());
    LOG.info("Scanners:");
    for (AtomicScanReader scanner : scanners) {
        LOG.info("  scanned " + scanner.numScans.get());
        LOG.info("  verified " + scanner.numRowsScanned.get() + " rows");
    }
}
Also used : TestContext(org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext)

Example 2 with TestContext

use of org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext in project hbase by apache.

the class TestAcidGuarantees method runTestAtomicity.

public void runTestAtomicity(long millisToRun, int numWriters, int numGetters, int numScanners, int numUniqueRows, final boolean systemTest, final boolean useMob) throws Exception {
    createTableIfMissing(useMob);
    TestContext ctx = new TestContext(util.getConfiguration());
    byte[][] rows = new byte[numUniqueRows][];
    for (int i = 0; i < numUniqueRows; i++) {
        rows[i] = Bytes.toBytes("test_row_" + i);
    }
    List<AtomicityWriter> writers = Lists.newArrayList();
    for (int i = 0; i < numWriters; i++) {
        AtomicityWriter writer = new AtomicityWriter(ctx, rows, FAMILIES, getSharedThreadPool());
        writers.add(writer);
        ctx.addThread(writer);
    }
    // Add a flusher
    ctx.addThread(new RepeatingTestThread(ctx) {

        Admin admin = util.getAdmin();

        public void doAnAction() throws Exception {
            try {
                admin.flush(TABLE_NAME);
            } catch (IOException ioe) {
                LOG.warn("Ignoring exception while flushing: " + StringUtils.stringifyException(ioe));
            }
            // the running cluster.
            if (systemTest)
                Thread.sleep(60000);
        }
    });
    List<AtomicGetReader> getters = Lists.newArrayList();
    for (int i = 0; i < numGetters; i++) {
        AtomicGetReader getter = new AtomicGetReader(ctx, rows[i % numUniqueRows], FAMILIES, getSharedThreadPool());
        getters.add(getter);
        ctx.addThread(getter);
    }
    List<AtomicScanReader> scanners = Lists.newArrayList();
    for (int i = 0; i < numScanners; i++) {
        AtomicScanReader scanner = new AtomicScanReader(ctx, FAMILIES, getSharedThreadPool());
        scanners.add(scanner);
        ctx.addThread(scanner);
    }
    ctx.startThreads();
    ctx.waitFor(millisToRun);
    ctx.stop();
    LOG.info("Finished test. Writers:");
    for (AtomicityWriter writer : writers) {
        LOG.info("  wrote " + writer.numWritten.get());
    }
    LOG.info("Readers:");
    for (AtomicGetReader reader : getters) {
        LOG.info("  read " + reader.numRead.get());
    }
    LOG.info("Scanners:");
    for (AtomicScanReader scanner : scanners) {
        LOG.info("  scanned " + scanner.numScans.get());
        LOG.info("  verified " + scanner.numRowsScanned.get() + " rows");
    }
}
Also used : TestContext(org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext) IOException(java.io.IOException) Admin(org.apache.hadoop.hbase.client.Admin) IOException(java.io.IOException) RepeatingTestThread(org.apache.hadoop.hbase.MultithreadedTestUtil.RepeatingTestThread)

Example 3 with TestContext

use of org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext in project hbase by apache.

the class TestHRegionServerBulkLoadWithOldSecureEndpoint method runAtomicBulkloadTest.

void runAtomicBulkloadTest(TableName tableName, int millisToRun, int numScanners) throws Exception {
    setupTable(tableName, 10);
    TestContext ctx = new TestContext(UTIL.getConfiguration());
    AtomicHFileLoader loader = new AtomicHFileLoader(tableName, ctx, null);
    ctx.addThread(loader);
    List<AtomicScanReader> scanners = Lists.newArrayList();
    for (int i = 0; i < numScanners; i++) {
        AtomicScanReader scanner = new AtomicScanReader(tableName, ctx, families);
        scanners.add(scanner);
        ctx.addThread(scanner);
    }
    ctx.startThreads();
    ctx.waitFor(millisToRun);
    ctx.stop();
    LOG.info("Loaders:");
    LOG.info("  loaded " + loader.numBulkLoads.get());
    LOG.info("  compations " + loader.numCompactions.get());
    LOG.info("Scanners:");
    for (AtomicScanReader scanner : scanners) {
        LOG.info("  scanned " + scanner.numScans.get());
        LOG.info("  verified " + scanner.numRowsScanned.get() + " rows");
    }
}
Also used : TestContext(org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext)

Example 4 with TestContext

use of org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext in project hbase by apache.

the class TestHRegionServerBulkLoad method runAtomicBulkloadTest.

void runAtomicBulkloadTest(TableName tableName, int millisToRun, int numScanners) throws Exception {
    setupTable(tableName, 10);
    TestContext ctx = new TestContext(UTIL.getConfiguration());
    AtomicHFileLoader loader = new AtomicHFileLoader(tableName, ctx, null);
    ctx.addThread(loader);
    List<AtomicScanReader> scanners = Lists.newArrayList();
    for (int i = 0; i < numScanners; i++) {
        AtomicScanReader scanner = new AtomicScanReader(tableName, ctx, families);
        scanners.add(scanner);
        ctx.addThread(scanner);
    }
    ctx.startThreads();
    ctx.waitFor(millisToRun);
    ctx.stop();
    LOG.info("Loaders:");
    LOG.info("  loaded " + loader.numBulkLoads.get());
    LOG.info("  compations " + loader.numCompactions.get());
    LOG.info("Scanners:");
    for (AtomicScanReader scanner : scanners) {
        LOG.info("  scanned " + scanner.numScans.get());
        LOG.info("  verified " + scanner.numRowsScanned.get() + " rows");
    }
}
Also used : TestContext(org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext)

Aggregations

TestContext (org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext)4 IOException (java.io.IOException)1 RepeatingTestThread (org.apache.hadoop.hbase.MultithreadedTestUtil.RepeatingTestThread)1 Admin (org.apache.hadoop.hbase.client.Admin)1