Package org.apache.hadoop.hbase.MultithreadedTestUtil

Examples of org.apache.hadoop.hbase.MultithreadedTestUtil.TestThread


      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
View Full Code Here


      MultithreadedTestUtil.TestContext ctx =
        new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread =
        new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.put(puts));
        }
      };
View Full Code Here

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
View Full Code Here

      MultithreadedTestUtil.TestContext ctx =
        new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread =
        new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.put(puts));
        }
      };
View Full Code Here

      MultithreadedTestUtil.TestContext ctx =
        new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread =
        new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.put(puts));
        }
      };
View Full Code Here

    HFileBlockPair[] blocks = generateHFileBlocks(numQueries, blockSize);
    blocksToTest.addAll(Arrays.asList(blocks));

    for (int i = 0; i < numThreads; i++) {
      TestThread t = new MultithreadedTestUtil.RepeatingTestThread(ctx) {
        @Override
        public void doAnAction() throws Exception {
          if (!blocksToTest.isEmpty()) {
            HFileBlockPair ourBlock = blocksToTest.poll();
            // if we run out of blocks to test, then we should stop the tests.
            if (ourBlock == null) {
              ctx.setStopFlag(true);
              return;
            }
            toBeTested.cacheBlock(ourBlock.blockName, ourBlock.block);
            Cacheable retrievedBlock = toBeTested.getBlock(ourBlock.blockName,
                false, false);
            if (retrievedBlock != null) {
              assertEquals(ourBlock.block, retrievedBlock);
              toBeTested.evictBlock(ourBlock.blockName);
              hits.incrementAndGet();
              assertNull(toBeTested.getBlock(ourBlock.blockName, false, false));
            } else {
              miss.incrementAndGet();
            }
            totalQueries.incrementAndGet();
          }
        }
      };
      t.setDaemon(true);
      ctx.addThread(t);
    }
    ctx.startThreads();
    while (!blocksToTest.isEmpty() && ctx.shouldRun()) {
      Thread.sleep(10);
View Full Code Here

    final AtomicInteger totalQueries = new AtomicInteger();
    toBeTested.cacheBlock(key, bac);

    for (int i = 0; i < numThreads; i++) {
      TestThread t = new MultithreadedTestUtil.RepeatingTestThread(ctx) {
        @Override
        public void doAnAction() throws Exception {
          ByteArrayCacheable returned = (ByteArrayCacheable) toBeTested
              .getBlock(key, false, false);
          assertArrayEquals(buf, returned.buf);
          totalQueries.incrementAndGet();
        }
      };

      t.setDaemon(true);
      ctx.addThread(t);
    }

    ctx.startThreads();
    while (totalQueries.get() < numQueries && ctx.shouldRun()) {
View Full Code Here

    for (int i = 0; i < numThreads; i++) {
      final int finalI = i;

      final byte[] buf = new byte[5 * 1024];
      TestThread t = new MultithreadedTestUtil.RepeatingTestThread(ctx) {
        @Override
        public void doAnAction() throws Exception {
          for (int j = 0; j < 100; j++) {
            BlockCacheKey key = new BlockCacheKey("key_" + finalI + "_" + j, 0);
            Arrays.fill(buf, (byte) (finalI * j));
            final ByteArrayCacheable bac = new ByteArrayCacheable(buf);

            ByteArrayCacheable gotBack = (ByteArrayCacheable) toBeTested
                .getBlock(key, true, false);
            if (gotBack != null) {
              assertArrayEquals(gotBack.buf, bac.buf);
            } else {
              toBeTested.cacheBlock(key, bac);
            }
          }
          totalQueries.incrementAndGet();
        }
      };

      t.setDaemon(true);
      ctx.addThread(t);
    }

    ctx.startThreads();
    while (totalQueries.get() < numQueries && ctx.shouldRun()) {
View Full Code Here

    MultithreadedTestUtil.TestContext ctx =
      new MultithreadedTestUtil.TestContext(HBaseConfiguration.create());
    final AtomicReference<OperationStatusCode[]> retFromThread =
      new AtomicReference<OperationStatusCode[]>();
    TestThread putter = new TestThread(ctx) {
      @Override
      public void doWork() throws IOException {
        retFromThread.set(region.put(puts));
      }
    };
View Full Code Here

      MultithreadedTestUtil.TestContext ctx =
        new MultithreadedTestUtil.TestContext(HBaseConfiguration.create());
      final AtomicReference<OperationStatus[]> retFromThread =
        new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.put(puts));
        }
      };
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.MultithreadedTestUtil.TestThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.