use of com.linkedin.databus.core.Checkpoint in project databus by linkedin.
the class TestGenericDispatcher method testBootstrapPartialWindowScnOrdering.
@Test
public void testBootstrapPartialWindowScnOrdering() throws Exception {
final Logger log = Logger.getLogger("TestGenericDispatcher.testBootstrapPartialWindowScnOrdering");
//log.setLevel(Level.DEBUG);
log.info("start");
//DDSDBUS-1889: Ensure bootstrap onCheckpoint() callback receives bootstrapSinceScn - not some scn.
int numEvents = 100;
int maxWindowSize = 25;
/* Experiment setup */
int payloadSize = 20;
int numCheckpoints = numEvents / maxWindowSize;
/* Consumer creation */
//setup consumer to fail on end of first full window
int timeTakenForDataEventInMs = 1;
int timeTakenForControlEventInMs = 1;
int numFailCheckpointEvent = 0;
int numFailDataEvent = 0;
int numFailEndWindow = 1;
int numFailures = 1;
//fail at the specified window; no retries; so the dispatcher should stop having written one window; but having checkpointed the other
//thanks to a very small checkpoint frequency threshold
TimeoutTestConsumer tConsumer = new TimeoutTestConsumer(timeTakenForDataEventInMs, timeTakenForControlEventInMs, numFailCheckpointEvent, numFailDataEvent, numFailEndWindow, numFailures);
HashMap<Long, List<RegisterResponseEntry>> schemaMap = new HashMap<Long, List<RegisterResponseEntry>>();
short srcId = 1;
List<RegisterResponseEntry> l1 = new ArrayList<RegisterResponseEntry>();
l1.add(new RegisterResponseEntry(1L, srcId, SOURCE1_SCHEMA_STR));
schemaMap.put(1L, l1);
Map<Long, IdNamePair> sourcesMap = new HashMap<Long, IdNamePair>();
List<String> sources = new ArrayList<String>();
for (int i = 1; i <= 1; ++i) {
IdNamePair sourcePair = new IdNamePair((long) i, "source" + i);
sources.add(sourcePair.getName());
sourcesMap.put(sourcePair.getId(), sourcePair);
}
long consumerTimeBudgetMs = 60 * 1000;
DatabusV2ConsumerRegistration consumerReg = new DatabusV2ConsumerRegistration(tConsumer, sources, null);
List<DatabusV2ConsumerRegistration> allRegistrations = Arrays.asList(consumerReg);
//Single threaded execution of consumer
MultiConsumerCallback mConsumer = new MultiConsumerCallback(allRegistrations, Executors.newFixedThreadPool(1), consumerTimeBudgetMs, new StreamConsumerCallbackFactory(null, null), null, null, null, null);
/* Generate events **/
Vector<DbusEvent> srcTestEvents = new Vector<DbusEvent>();
Vector<Short> srcIdList = new Vector<Short>();
srcIdList.add(srcId);
DbusEventGenerator evGen = new DbusEventGenerator(15000, srcIdList);
Assert.assertTrue(evGen.generateEvents(numEvents, maxWindowSize, 512, payloadSize, true, srcTestEvents) > 0);
int totalSize = 0;
int maxSize = 0;
for (DbusEvent e : srcTestEvents) {
totalSize += e.size();
maxSize = (e.size() > maxSize) ? e.size() : maxSize;
}
/* Source configuration */
double thresholdChkptPct = 5.0;
DatabusSourcesConnection.Config conf = new DatabusSourcesConnection.Config();
conf.setCheckpointThresholdPct(thresholdChkptPct);
conf.getDispatcherRetries().setMaxRetryNum(0);
conf.setFreeBufferThreshold(maxSize);
conf.setConsumerTimeBudgetMs(consumerTimeBudgetMs);
int freeBufferThreshold = conf.getFreeBufferThreshold();
DatabusSourcesConnection.StaticConfig connConfig = conf.build();
//make buffer large enough to hold data; the control events are large that contain checkpoints
int producerBufferSize = totalSize * 2 + numCheckpoints * 10 * maxSize * 5 + freeBufferThreshold;
int individualBufferSize = producerBufferSize;
int indexSize = producerBufferSize / 10;
int stagingBufferSize = producerBufferSize;
/*Event Buffer creation */
TestGenericDispatcherEventBuffer dataEventsBuffer = new TestGenericDispatcherEventBuffer(getConfig(producerBufferSize, individualBufferSize, indexSize, stagingBufferSize, AllocationPolicy.HEAP_MEMORY, QueuePolicy.BLOCK_ON_WRITE));
List<DatabusSubscription> subs = DatabusSubscription.createSubscriptionList(sources);
/* Generic Dispatcher creation */
InMemoryPersistenceProvider cpPersister = new InMemoryPersistenceProvider();
BootstrapDispatcher dispatcher = new BootstrapDispatcher("bootstrapPartialWindowCheckpointPersistence", connConfig, subs, cpPersister, dataEventsBuffer, mConsumer, //relaypuller
null, //mbean server
null, //ClientImpl
null, //registrationId
null, // logger
null);
dispatcher.setSchemaIdCheck(false);
BootstrapCheckpointHandler cptHandler = new BootstrapCheckpointHandler("source1");
long sinceScn = 15000L;
long startTsNsecs = System.nanoTime();
final Checkpoint initCheckpoint = cptHandler.createInitialBootstrapCheckpoint(null, sinceScn);
initCheckpoint.setBootstrapStartNsecs(startTsNsecs);
initCheckpoint.setBootstrapStartScn(0L);
/* Launch writer */
//numBootstrapCheckpoint - number of checkpoints before writing end of period
int numBootstrapCheckpoint = 4;
DbusEventAppender eventProducer = new DbusEventAppender(srcTestEvents, dataEventsBuffer, numBootstrapCheckpoint, null);
//simulate bootstrap server; use this checkpoint as init checkpoint
eventProducer.setBootstrapCheckpoint(initCheckpoint);
Thread tEmitter = new Thread(eventProducer);
//be generous ; use worst case for num control events
long waitTimeMs = (numEvents * timeTakenForDataEventInMs + numEvents * timeTakenForControlEventInMs) * 4;
tEmitter.start();
tEmitter.join(waitTimeMs);
/* Launch dispatcher */
Thread tDispatcher = new Thread(dispatcher);
tDispatcher.start();
/* Now initialize this state machine */
dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));
//expect dispatcher to fail - at end of window
tDispatcher.join(waitTimeMs);
Assert.assertFalse(tEmitter.isAlive());
Assert.assertFalse(tDispatcher.isAlive());
LOG.info("tConsumer: " + tConsumer);
HashMap<List<String>, Checkpoint> cps = cpPersister.getCheckpoints();
Assert.assertTrue(cps.size() > 0);
for (Map.Entry<List<String>, Checkpoint> i : cps.entrySet()) {
Checkpoint cp = i.getValue();
LOG.info("checkpoint=" + cp);
Assert.assertEquals(cp.getConsumptionMode(), DbusClientMode.BOOTSTRAP_SNAPSHOT);
//check if progress has been made during bootstrap
Assert.assertTrue(cp.getSnapshotOffset() > 0);
//these two values should be unchanged during the course of bootstrap
Assert.assertEquals(sinceScn, cp.getBootstrapSinceScn().longValue());
Assert.assertEquals(startTsNsecs, cp.getBootstrapStartNsecs());
//the tsNsec normally udpdated by client at end of window should be a no-op during bootstrap
Assert.assertEquals(Checkpoint.UNSET_TS_NSECS, cp.getTsNsecs());
//the scn passed to consumers during onCheckpoint should be the sinceSCN and not any other interim value
Assert.assertEquals(cp.getBootstrapSinceScn().longValue(), tConsumer.getLastSeenCheckpointScn());
}
log.info("end\n");
}
use of com.linkedin.databus.core.Checkpoint in project databus by linkedin.
the class TestGenericDispatcher method runDispatcherRollback.
/**
*
* @param numEvents number of events that will be written out in the test
* @param maxWindowSize size of window expressed as #events
* @param numFailDataEvent the nth data event at which failure occurs; 0 == no failures
* @param numFailCheckpointEvent the nth checkpoint event at which failure occurs; 0 == no failures
* @param numFailEndWindow the nth end-of-window at which failure occurs; 0 == no failures
* @param thresholdPct checkpointThresholdPct - forcible checkpoint before end-of-window
* @param negativeTest is this test supposed to fail
* @param numFailures number of failures expected (across all error types); in effect controls number of rollbacks
* @param bootstrapCheckpointsPerWindow k bootstrap checkpoint events are written for every one end-of-window event
* @param timeTakenForDataEventInMs time taken for processing data events
* @param timeTakenForControlEventInMs time taken for processing control events
* @param wrapAround use a smaller producer buffer so that events will wrap around
*/
protected void runDispatcherRollback(int numEvents, int maxWindowSize, int numFailDataEvent, int numFailCheckpointEvent, int numFailEndWindow, double thresholdPct, boolean negativeTest, int numFailures, int bootstrapCheckpointsPerWindow, long timeTakenForDataEventInMs, long timeTakenForControlEventInMs, boolean wrapAround) throws Exception {
LOG.info("Running dispatcher rollback with: " + "numEvents=" + numEvents + " maxWindowSize=" + maxWindowSize + " numFailDataEvent=" + numFailDataEvent + " numFailCheckpoint=" + numFailCheckpointEvent + " numFailEndWindow=" + numFailEndWindow + " thresholdPct=" + thresholdPct + " negativeTest=" + negativeTest + " numFailures=" + numFailures + " bootstrapCheckpointsPerWindow=" + bootstrapCheckpointsPerWindow + " timeTakenForDataEventsInMs=" + timeTakenForDataEventInMs + " timeTakenForControlEventsInMs=" + timeTakenForControlEventInMs + " wrapAround=" + wrapAround);
/* Experiment setup */
int payloadSize = 20;
int numCheckpoints = numEvents / maxWindowSize;
/* Consumer creation */
// set up consumer to fail on data callback at the nth event
TimeoutTestConsumer tConsumer = new TimeoutTestConsumer(timeTakenForDataEventInMs, timeTakenForControlEventInMs, numFailCheckpointEvent, numFailDataEvent, numFailEndWindow, numFailures);
HashMap<Long, List<RegisterResponseEntry>> schemaMap = new HashMap<Long, List<RegisterResponseEntry>>();
short srcId = 1;
List<RegisterResponseEntry> l1 = new ArrayList<RegisterResponseEntry>();
l1.add(new RegisterResponseEntry(1L, srcId, SOURCE1_SCHEMA_STR));
schemaMap.put(1L, l1);
Map<Long, IdNamePair> sourcesMap = new HashMap<Long, IdNamePair>();
List<String> sources = new ArrayList<String>();
for (int i = 1; i <= 1; ++i) {
IdNamePair sourcePair = new IdNamePair((long) i, "source" + i);
sources.add(sourcePair.getName());
sourcesMap.put(sourcePair.getId(), sourcePair);
}
long consumerTimeBudgetMs = 60 * 1000;
DatabusV2ConsumerRegistration consumerReg = new DatabusV2ConsumerRegistration(tConsumer, sources, null);
List<DatabusV2ConsumerRegistration> allRegistrations = Arrays.asList(consumerReg);
final UnifiedClientStats unifiedStats = new UnifiedClientStats(0, "test", "test.unified");
// single-threaded execution of consumer
MultiConsumerCallback mConsumer = new MultiConsumerCallback(allRegistrations, Executors.newFixedThreadPool(1), consumerTimeBudgetMs, new StreamConsumerCallbackFactory(null, unifiedStats), null, unifiedStats, null, null);
/* Generate events */
Vector<DbusEvent> srcTestEvents = new Vector<DbusEvent>();
Vector<Short> srcIdList = new Vector<Short>();
srcIdList.add(srcId);
DbusEventGenerator evGen = new DbusEventGenerator(0, srcIdList);
Assert.assertTrue(evGen.generateEvents(numEvents, maxWindowSize, 512, payloadSize, srcTestEvents) > 0);
int totalSize = 0;
int maxSize = 0;
for (DbusEvent e : srcTestEvents) {
totalSize += e.size();
maxSize = (e.size() > maxSize) ? e.size() : maxSize;
}
/* Source configuration */
double thresholdChkptPct = thresholdPct;
DatabusSourcesConnection.Config conf = new DatabusSourcesConnection.Config();
conf.setCheckpointThresholdPct(thresholdChkptPct);
conf.getDispatcherRetries().setMaxRetryNum(10);
conf.setFreeBufferThreshold(maxSize);
conf.setConsumerTimeBudgetMs(consumerTimeBudgetMs);
int freeBufferThreshold = conf.getFreeBufferThreshold();
DatabusSourcesConnection.StaticConfig connConfig = conf.build();
// make buffer large enough to hold data; the control events are large that contain checkpoints
int producerBufferSize = wrapAround ? totalSize : totalSize * 2 + numCheckpoints * 10 * maxSize * 5 + freeBufferThreshold;
int individualBufferSize = producerBufferSize;
int indexSize = producerBufferSize / 10;
int stagingBufferSize = producerBufferSize;
/* Event Buffer creation */
TestGenericDispatcherEventBuffer dataEventsBuffer = new TestGenericDispatcherEventBuffer(getConfig(producerBufferSize, individualBufferSize, indexSize, stagingBufferSize, AllocationPolicy.HEAP_MEMORY, QueuePolicy.BLOCK_ON_WRITE));
List<DatabusSubscription> subs = DatabusSubscription.createSubscriptionList(sources);
/* Generic Dispatcher creation */
TestDispatcher<DatabusCombinedConsumer> dispatcher = new TestDispatcher<DatabusCombinedConsumer>("rollBackcheck", connConfig, subs, new InMemoryPersistenceProvider(), dataEventsBuffer, mConsumer, bootstrapCheckpointsPerWindow == 0);
/* Launch writer */
DbusEventAppender eventProducer = new DbusEventAppender(srcTestEvents, dataEventsBuffer, bootstrapCheckpointsPerWindow, null);
Thread tEmitter = new Thread(eventProducer);
tEmitter.start();
/* Launch dispatcher */
Thread tDispatcher = new Thread(dispatcher);
tDispatcher.start();
/* Now initialize this state machine */
dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));
// be generous; use worst case for num control events
long waitTimeMs = (numEvents * timeTakenForDataEventInMs + numEvents * timeTakenForControlEventInMs) * 4;
tEmitter.join(waitTimeMs);
// wait for dispatcher to finish reading the events
tDispatcher.join(waitTimeMs);
Assert.assertFalse(tEmitter.isAlive());
System.out.println("tConsumer: " + tConsumer);
int windowBeforeDataFail = (numFailDataEvent / maxWindowSize);
int expectedDataFaults = numFailDataEvent == 0 ? 0 : numFailures;
int expectedCheckPointFaults = (numFailCheckpointEvent == 0 || (expectedDataFaults != 0 && numFailCheckpointEvent == windowBeforeDataFail)) ? 0 : numFailures;
// check if all windows were logged by dispatcher; in online case;
if (bootstrapCheckpointsPerWindow == 0) {
Assert.assertTrue(dispatcher.getNumCheckPoints() >= (numCheckpoints - expectedCheckPointFaults));
}
// Consumer prespective
// 1 or 0 faults injected in data callbacks; success (store) differs callback by 1
Assert.assertEquals("Mismatch between callbacks and stored data on consumer.", expectedDataFaults, tConsumer.getDataCallbackCount() - tConsumer.getStoredDataCount());
Assert.assertTrue(tConsumer.getStoredDataCount() >= tConsumer.getNumUniqStoredEvents());
Assert.assertEquals("Consumer failed to store expected number of checkpoints.", dispatcher.getNumCheckPoints(), tConsumer.getStoredCheckpointCount());
// it's converted to ConsumerCallbackResult.SKIP_CHECKPOINT and therefore not seen by client metrics.
if (expectedCheckPointFaults == 0 || expectedDataFaults > 0 || negativeTest) {
Assert.assertTrue("Unexpected error count in consumer metrics (" + unifiedStats.getNumConsumerErrors() + "); should be greater than or equal to numFailures (" + numFailures + ").", unifiedStats.getNumConsumerErrors() >= numFailures);
} else {
Assert.assertEquals("Unexpected error count in consumer metrics; checkpoint errors shouldn't count. ", // unless negativeTest ...
0, unifiedStats.getNumConsumerErrors());
}
// rollback behaviour; were all events re-sent?
if (!negativeTest) {
Assert.assertTrue(tConsumer.getNumUniqStoredEvents() == numEvents);
} else {
Assert.assertTrue(tConsumer.getNumUniqStoredEvents() < numEvents);
}
dispatcher.shutdown();
verifyNoLocks(null, dataEventsBuffer);
}
use of com.linkedin.databus.core.Checkpoint in project databus by linkedin.
the class MockBootstrapConnection method testTransition_NullResumeCkptWithStartScn.
@Test
public /** Test Bootstrap transition: Connection Factory returned null with resumeCkpt startScn set*/
void testTransition_NullResumeCkptWithStartScn() throws Exception {
BootstrapPullThread bsPuller = createBootstrapPullThread(true, false, false);
Checkpoint cp = _ckptHandlerSource1.createInitialBootstrapCheckpoint(null, 50L);
//TODO remove
//cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
//cp.setBootstrapSinceScn(50L);
cp.setBootstrapStartScn(100L);
bsPuller.getComponentStatus().start();
ConnectionState connState = bsPuller.getConnectionState();
connState.switchToBootstrap(cp);
testTransitionCase(bsPuller, StateId.BOOTSTRAP, StateId.BOOTSTRAP, "SUSPEND_ON_ERROR", cp);
}
use of com.linkedin.databus.core.Checkpoint in project databus by linkedin.
the class MockBootstrapConnection method testServerSetChange_StartScnResponseSuccess.
@Test
public /** Test ServerSet change when in Start_Scn_Response_Success */
void testServerSetChange_StartScnResponseSuccess() throws Exception {
BootstrapPullThread bsPuller = createBootstrapPullThread(false, false, false);
Checkpoint cp = _ckptHandlerSource1.createInitialBootstrapCheckpoint(null, 0L);
bsPuller.getComponentStatus().start();
ConnectionState connState = bsPuller.getConnectionState();
connState.switchToBootstrap(cp);
testTransitionCase(bsPuller, StateId.BOOTSTRAP, StateId.REQUEST_START_SCN, cp);
bsPuller.getMessageQueue().clear();
testTransitionCase(bsPuller, StateId.REQUEST_START_SCN, StateId.START_SCN_RESPONSE_SUCCESS, null);
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(bsPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = bsPuller.getCurentServer();
Assert.assertEquals(bsPuller.getServers(), EXP_SERVERINFO_1, "Server Set");
Map<Long, List<RegisterResponseEntry>> entries = new HashMap<Long, List<RegisterResponseEntry>>();
entries.put(1L, new ArrayList<RegisterResponseEntry>());
connState.setSourcesSchemas(entries);
doExecuteAndChangeState(bsPuller, createSetServerMessage(true, bsPuller));
Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(bsPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(bsPuller.getServers(), EXP_SERVERINFO_2, "Server Set");
Assert.assertEquals(bsPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(), StateId.START_SCN_RESPONSE_SUCCESS, "ServerSetChange while START_SCN_RESPONSE_SUCCESS");
Assert.assertEquals(bsPuller.getQueueListString(), "RelayPuller queue: [START_SCN_RESPONSE_SUCCESS]", "Queue :ServerSetChange while START_SCN_RESPONSE_SUCCESS");
}
// ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
{
int oldServerIndex = bsPuller.getCurrentServerIdx();
ServerInfo oldServer = bsPuller.getCurentServer();
Assert.assertEquals(bsPuller.getServers(), EXP_SERVERINFO_2, "Server Set");
Map<Long, List<RegisterResponseEntry>> entries = new HashMap<Long, List<RegisterResponseEntry>>();
entries.put(1L, new ArrayList<RegisterResponseEntry>());
connState.setSourcesSchemas(entries);
doExecuteAndChangeState(bsPuller, createSetServerMessage(false, bsPuller));
Assert.assertEquals(bsPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(bsPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(bsPuller.getServers(), EXP_SERVERINFO_3, "Server Set");
Assert.assertEquals(bsPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(), StateId.START_SCN_RESPONSE_SUCCESS, "ServerSetChange while START_SCN_RESPONSE_SUCCESS");
Assert.assertEquals(bsPuller.getQueueListString(), "RelayPuller queue: [START_SCN_RESPONSE_SUCCESS]", "Queue :ServerSetChange while START_SCN_RESPONSE_SUCCESS");
// Now Response arrives
connState.switchToStartScnSuccess(cp, null, null);
testTransitionCase(bsPuller, StateId.START_SCN_RESPONSE_SUCCESS, StateId.PICK_SERVER, null);
Assert.assertEquals(bsPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(bsPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(bsPuller.getCurentServer() == null, true, "Current Server Null");
}
}
use of com.linkedin.databus.core.Checkpoint in project databus by linkedin.
the class MockBootstrapConnection method testTransition_TargetScnSuccessHappyPath.
@Test
public /** Test bootstrap transition: Target_Scn_Success : Happy Path */
void testTransition_TargetScnSuccessHappyPath() throws Exception {
BootstrapPullThread bsPuller = createBootstrapPullThread(false, false, false, false, false, null, 12000, 1, true);
Checkpoint cp = _ckptHandlerSource1.createInitialBootstrapCheckpoint(null, 0L);
//TODO remove
//cp.setSnapshotSource("source1");
//cp.setCatchupSource("source1");
//cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
cp.setBootstrapServerInfo(_serverInfoName);
bsPuller.getComponentStatus().start();
ConnectionState connState = bsPuller.getConnectionState();
connState.switchToBootstrap(cp);
testTransitionCase(bsPuller, StateId.BOOTSTRAP, StateId.REQUEST_START_SCN, cp);
bsPuller.getMessageQueue().clear();
testTransitionCase(bsPuller, StateId.REQUEST_START_SCN, StateId.START_SCN_RESPONSE_SUCCESS, null);
bsPuller.getMessageQueue().clear();
Map<Long, List<RegisterResponseEntry>> entries = new HashMap<Long, List<RegisterResponseEntry>>();
entries.put(1L, new ArrayList<RegisterResponseEntry>());
connState.setSourcesSchemas(entries);
testTransitionCase(bsPuller, StateId.START_SCN_RESPONSE_SUCCESS, StateId.REQUEST_STREAM, null);
bsPuller.getMessageQueue().clear();
connState.getSourcesNameMap().put("source1", new IdNamePair(1L, "source1"));
connState.getSourceIdMap().put(1L, new IdNamePair(1L, "source1"));
testTransitionCase(bsPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS, null);
bsPuller.getMessageQueue().clear();
testTransitionCase(bsPuller, StateId.STREAM_REQUEST_SUCCESS, StateId.STREAM_RESPONSE_DONE, null);
bsPuller.getMessageQueue().clear();
cp.setSnapshotOffset(-1);
testTransitionCase(bsPuller, StateId.STREAM_RESPONSE_DONE, StateId.REQUEST_TARGET_SCN, null);
Assert.assertEquals(cp.getConsumptionMode(), DbusClientMode.BOOTSTRAP_SNAPSHOT, "Consumption Mode check");
Assert.assertFalse(cp.isBootstrapTargetScnSet());
bsPuller.getMessageQueue().clear();
testTransitionCase(bsPuller, StateId.REQUEST_TARGET_SCN, StateId.TARGET_SCN_RESPONSE_SUCCESS, null);
bsPuller.getMessageQueue().clear();
entries = new HashMap<Long, List<RegisterResponseEntry>>();
entries.put(1L, new ArrayList<RegisterResponseEntry>());
connState.setSourcesSchemas(entries);
testTransitionCase(bsPuller, StateId.TARGET_SCN_RESPONSE_SUCCESS, StateId.REQUEST_STREAM, null);
Assert.assertEquals(cp.getConsumptionMode(), DbusClientMode.BOOTSTRAP_CATCHUP, "Consumption Mode check");
Assert.assertTrue(cp.isBootstrapTargetScnSet());
Assert.assertEquals(cp.getBootstrapTargetScn().longValue(), 10L);
Assert.assertEquals(cp.getWindowScn(), cp.getBootstrapStartScn().longValue());
Assert.assertEquals(cp.getWindowOffset().longValue(), 0L);
}
Aggregations