Exemplo n.º 1
0
 /** Check for the the proper number of afterRemoteRegionCrashEvents */
 public static void checkAfterRemoteRegionCrashEvents() {
   long numCrashEvents =
       ListenerBB.getBB().getSharedCounters().read(ListenerBB.numAfterRemoteRegionCrashEvents);
   long numVMsInDS = SplitBrainBB.getBB().getSharedCounters().read(SplitBrainBB.NumVMsInDS);
   long numVMsStopped = SplitBrainBB.getBB().getSharedCounters().read(SplitBrainBB.NumVMsStopped);
   // the number of expected crash events is: each vm that did not receive a forced disconnect gets
   // an event for the vm(s) that did receive a forced disconnect, plus the vm(s) that received
   // that
   // forced disconnect get an event for each of the surviving vms that have that region defined.
   // lynn - waiting for specification as to how many crash events to expect
   //   long numExpectedCrashEvents = 2 * (numVMsInDS - numVMsStopped);
   long numExpectedCrashEvents = numVMsInDS - numVMsStopped;
   Log.getLogWriter()
       .info(
           "numVMsInDS: "
               + numVMsInDS
               + ", numVMsStopped: "
               + numVMsStopped
               + ", numExpectedCrashEvents: "
               + numExpectedCrashEvents);
   TestHelper.waitForCounter(
       ListenerBB.getBB(),
       "ListenerBB.numAfterRemoteRegionCrashEvents",
       ListenerBB.numAfterRemoteRegionCrashEvents,
       numExpectedCrashEvents,
       true,
       -1,
       2000);
 }
  /** One thread imports ... everyone validates against blackboard snapshot */
  protected static void importAndVerify(RecoveryTest testInstance) {
    long counter =
        RecoveryBB.getBB().getSharedCounters().incrementAndRead(RecoveryBB.importSnapshot);
    if (counter == 1) {
      Log.getLogWriter().info("This thread is the leader; it will import the snapshot");
      long executionNumber =
          RecoveryBB.getBB().getSharedCounters().read(RecoveryBB.executionNumber);
      String currDirName = System.getProperty("user.dir");
      String snapshotDirName = currDirName + File.separator + "cacheSnapshotDir_" + executionNumber;
      CacheSnapshotService snapshot = CacheHelper.getCache().getSnapshotService();
      long startTime = System.currentTimeMillis();
      try {
        if (SnapshotPrms.useFilterOnImport()) {
          SnapshotOptions options = snapshot.createOptions();
          options.setFilter(getSnapshotFilter());

          File dir = new File(snapshotDirName);
          File[] files = dir.listFiles();
          StringBuffer aStr = new StringBuffer();
          aStr.append("Invoking snapshot.load() with files:\n");
          for (int i = 0; i < files.length; i++) {
            aStr.append("   " + files[i] + "\n");
          }
          aStr.append("Options.getFilter() = " + options.getFilter().getClass().getName());
          Log.getLogWriter().info(aStr.toString());
          snapshot.load(files, SnapshotFormat.GEMFIRE, options);
        } else {
          Log.getLogWriter().info("Starting CacheSnapshotService.load() from " + snapshotDirName);
          snapshot.load(new File(snapshotDirName), SnapshotFormat.GEMFIRE);
        }
      } catch (IOException ioe) {
        throw new TestException(
            "Caught "
                + ioe
                + " while importing region snapshot from "
                + snapshotDirName
                + " "
                + TestHelper.getStackTrace(ioe));
      } catch (ClassNotFoundException e) {
        throw new TestException(
            "Caught "
                + e
                + " while importing region snapshot from "
                + snapshotDirName
                + " "
                + TestHelper.getStackTrace(e));
      }
      long endTime = System.currentTimeMillis();
      Log.getLogWriter()
          .info(
              "CacheSnapshotService.load() of "
                  + snapshotDirName
                  + " took "
                  + (endTime - startTime)
                  + " ms.");
      Log.getLogWriter().info(testInstance.regionHierarchyToString());
      RecoveryBB.getBB().getSharedCounters().increment(RecoveryBB.snapshotImported);
    } else {
      TestHelper.waitForCounter(
          RecoveryBB.getBB(),
          "RecoveryBB.snapshotImported",
          RecoveryBB.snapshotImported,
          1,
          true,
          -1,
          2000);
      testInstance.verifyFromSnapshot();
      RecoveryBB.getBB().getSharedCounters().increment(RecoveryBB.doneVerifyingCounter);
    }
    TestHelper.waitForCounter(
        RecoveryBB.getBB(),
        "RecoveryBB.doneVerifyingCounter",
        RecoveryBB.doneVerifyingCounter,
        RemoteTestModule.getCurrentThread().getCurrentTask().getTotalThreads() - 1,
        true,
        -1,
        2000);
  }