private void assertNoUpdateFailures() {
    int[] increments = new int[REFERENCE_COUNT];
    for (StressThread t : stressThreads) {
      t.addIncrements(increments);
    }

    Set<Integer> failedKeys = new HashSet<Integer>();
    for (int k = 0; k < REFERENCE_COUNT; k++) {
      long expectedValue = increments[k];
      long foundValue = references[k].get();
      if (expectedValue != foundValue) {
        failedKeys.add(k);
      }
    }

    if (failedKeys.isEmpty()) {
      return;
    }

    int index = 1;
    for (Integer key : failedKeys) {
      System.err.println(
          "Failed write: "
              + index
              + " found:"
              + references[key].get()
              + " expected:"
              + increments[key]);
      index++;
    }

    fail("There are failed writes, number of failures:" + failedKeys.size());
  }
Example #2
0
 private boolean anyAliveAndAllWell(StressThread[] stressThreads) {
   for (StressThread stressThread : stressThreads) {
     if (stressThread.error != null) return false;
     if (stressThread.isAlive()) return true;
   }
   return false;
 }
  public void test(StressThreadFactory stressThreadFactory) throws Exception {
    StressThread stressThread = stressThreadFactory.create();

    stressThread.start();

    sleepAndStop(stop, runningTimeSeconds);

    stressThread.assertSucceedsEventually();

    System.out.println("Completed with asynchronous calls, waiting for everything to complete");

    assertTrueEventually(
        new AssertTask() {
          @Override
          public void run() throws Exception {
            assertEquals(
                "the number of completed calls doesn't match the number of expected calls",
                globalOperationCount.get(),
                completedCall.get());
          }
        });

    assertEquals(0, failedOperationCount.get());

    //        long count = localOperationService.backPressureService.backPressureCount();
    //        System.out.println("Backpressure count: " + count);
  }