Examples of TestThread


Examples of com.hazelcast.test.TestThread

    @Test(timeout = 15000)
    public void testAwait() throws InterruptedException {
        HazelcastInstance instance = createHazelcastInstance();
        final ICountDownLatch latch = instance.getCountDownLatch(randomString());
        latch.trySetCount(1);
        TestThread thread = new TestThread() {
            public void doRun() {
                latch.countDown();
            }
        };
        thread.start();
        assertOpenEventually(latch);
    }
View Full Code Here

Examples of net.sf.jdistunit.platform.action.TestThread

        final List<ITestThread> testList = new ArrayList<ITestThread>(requestCount);
        this.resultList = new ArrayList<ITestActionResult>(requestCount);

        // Create parallel requests.
        for (int cnt = 0; cnt < requestCount; cnt++) {
            ITestThread thread = new TestThread(cnt, action);
            testList.add(thread);
        }

        // Start parallel requests.
        // If so dictated, sleep a little between starts.
        for (ITestThread thread : testList) {
            if (0 != threadTimeStep) {
                OS.sleep(threadTimeStep);
            }
            thread.getThread().start();
        }

        // Wait until all tests are finished or timeout has come.
        long timePassed = 0;
        boolean isThreadsDone = false;
        while (!isThreadsDone && timePassed < getTimeOut()) {
            logStatus("Waiting on " + getMarketPlace().getHomeId() + " for tests to finish (" + (timePassed / JDistUnitConstants.WAIT_ONE_CYCLE) + ")");

            // Sleep the next cycle.
            OS.sleep(JDistUnitConstants.WAIT_ONE_CYCLE);
            timePassed += JDistUnitConstants.WAIT_ONE_CYCLE;

            // Take results out.
            retrievePendingResults(testList);

            // Set break flag if all threads have finished.
            isThreadsDone = isTestThreadsDone(testList);
        }

        // If not all threads finished successfully, stop all remaining
        // test threads -- they are timed out, and may die peacefully.
        if (!isThreadsDone) {
            for (ITestThread thread : testList) {
                thread.stopAction();
            }
        }
    }
View Full Code Here

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

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

      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

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

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

      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

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

      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

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

    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

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

    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

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

    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
TOP
Copyright © 2018 www.massapi.com. 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.