/*
   * Provoke sufficient log cleaning to move the entire VLSN right
   * sufficiently that the new VLSN range no longer overlaps the VLSN
   * range upon entry thus guaranteeing a LogFileRefreshException.
   */
  private void shiftVLSNRight(ReplicatedEnvironment menv) {
    /* Shift the vlsn range window. */

    RepImpl menvImpl = repEnvInfo[0].getRepImpl();
    final VLSNIndex vlsnIndex = menvImpl.getRepNode().getVLSNIndex();
    VLSN masterHigh = vlsnIndex.getRange().getLast();

    CheckpointConfig checkpointConfig = new CheckpointConfig();
    checkpointConfig.setForce(true);

    do {

      /*
       * Populate just the master, leaving the replica behind Re-populate
       * with the same keys to create Cleaner fodder.
       */
      populateDB(menv, TEST_DB_NAME, 100);

      /*
       * Sleep to permit the cbvlsn on the master to be updated. It's
       * done with the period: FeederManager.MASTER_CHANGE_CHECK_TIMEOUT
       */
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        fail("unexpected interrupt");
      }
      menv.cleanLog();
      menv.checkpoint(checkpointConfig);
    } while (masterHigh.compareTo(vlsnIndex.getRange().getFirst()) > 0);
  }
  /**
   * In this test, we often want to check that the last item in the replicated stream is not a
   * matchpoint candidate (that VLSNRange.lastVLSN != VLSNRange.lastSync) There's nothing wrong
   * intrinsically with that being so, it's just that this test is trying to ensure that we test
   * partial rollbacks.
   *
   * @return lastVLSN
   * @throws InterruptedException
   */
  private VLSN ensureDistinctLastAndSyncVLSN(ReplicatedEnvironment master, RepEnvInfo[] repEnvInfo)
      throws InterruptedException {

    VLSNIndex vlsnIndex = RepInternal.getRepImpl(master).getVLSNIndex();
    VLSNRange range = vlsnIndex.getRange();
    VLSN lastVLSN = range.getLast();
    VLSN syncVLSN = range.getLastSync();
    assertFalse("lastVLSN = " + lastVLSN + " syncVLSN = " + syncVLSN, lastVLSN.equals(syncVLSN));

    return lastVLSN;
  }