BootstrapCheckpointHandler { public void resetForServerChange(Checkpoint ckpt) { ckpt.resetForServerChange(); final int snapshotSourceIndex = ckpt.getBootstrapSnapshotSourceIndex(); final int catchupSourceIndex = ckpt.getBootstrapCatchupSourceIndex(); setSnapshotSource(ckpt, snapshotSourceIndex); setCatchupSource(ckpt, catchupSourceIndex); } BootstrapCheckpointHandler(List<String> sourceNames);  BootstrapCheckpointHandler(String... sourceNames); void setSourceNames(List<String> sourceNames); boolean needsMoreCatchup(Checkpoint ckpt); boolean needsMoreSnapshot(Checkpoint ckpt); Checkpoint createInitialBootstrapCheckpoint(Checkpoint ckpt, Long sinceScn); boolean needsMoreCowbell(Checkpoint ckpt); void finalizeSnapshotPhase(Checkpoint ckpt); void finalizeCatchupPhase(Checkpoint ckpt); void advanceAfterSnapshotPhase(Checkpoint ckpt); void advanceAfterCatchupPhase(Checkpoint ckpt); void advanceAfterTargetScn(Checkpoint ckpt); boolean assertBootstrapCheckpoint(Checkpoint ckpt); void resetForServerChange(Checkpoint ckpt); void setStartScnAfterServerChange(Checkpoint ckpt, Long startScn);  }
@Test public void testBootstrapResetNewServers() throws Exception { List<String> sourceNames = new ArrayList<String>(); final String firstSourceName = "com.linkedin.events.example.Person"; final int firstSourceIndex = 0; sourceNames.add(firstSourceName); final String catchupSourceName = "com.linkedin.events.example.Place"; final int catchupSourceIndex = 1; sourceNames.add(catchupSourceName); final String snapshotSourceName = "com.linkedin.events.example.Thing"; final int snapshotSourceIndex = 2; sourceNames.add(snapshotSourceName); BootstrapCheckpointHandler ckptHandler = new BootstrapCheckpointHandler(sourceNames); final long targetScn = 129971; final long sinceScn = 0; final long windowOffset = 0; final long prevScn = -1; final long windowScn = 123456; final long startScn = 123456; final long snapshotOffset = -1; Checkpoint ckpt = new Checkpoint(); ckpt.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT); ckpt.setBootstrapStartScn(startScn); ckpt.setConsumptionMode(DbusClientMode.BOOTSTRAP_CATCHUP); ckpt.setBootstrapTargetScn(targetScn); ckpt.setBootstrapSinceScn(sinceScn); ckpt.setWindowOffset(windowOffset); ckpt.setPrevScn(prevScn); ckpt.setWindowScn(windowScn); ckpt.setSnapshotOffset(snapshotOffset); Class[] params = new Class[2]; params[0] = Integer.TYPE; params[1] = String.class; Method setSnapshotSourceMethod = Checkpoint.class.getDeclaredMethod("setSnapshotSource", params); Method setCatchupSourceMethod = Checkpoint.class.getDeclaredMethod("setCatchupSource", params); setSnapshotSourceMethod.setAccessible(true); setCatchupSourceMethod.setAccessible(true); setSnapshotSourceMethod.invoke(ckpt, snapshotSourceIndex, snapshotSourceName); setCatchupSourceMethod.invoke(ckpt, catchupSourceIndex, catchupSourceName); ckptHandler.resetForServerChange(ckpt); Assert.assertEquals(ckpt.getConsumptionMode(), DbusClientMode.BOOTSTRAP_SNAPSHOT); Assert.assertEquals(ckpt.getBootstrapSinceScn().longValue(), sinceScn); Assert.assertEquals(ckpt.getBootstrapStartScn().longValue(), -1); Assert.assertEquals(ckpt.getBootstrapTargetScn().longValue(), -1); Assert.assertEquals(ckpt.getSnapshotOffset().longValue(), 0); Assert.assertEquals(ckpt.getBootstrapSnapshotSourceIndex().intValue(), firstSourceIndex); Assert.assertEquals(ckpt.getBootstrapCatchupSourceIndex().intValue(), firstSourceIndex); Assert.assertEquals(ckpt.getSnapshotSource(), firstSourceName); Assert.assertEquals(ckpt.getCatchupSource(), firstSourceName); }