rs1 = createReplicationServer(testCase, DEGRADED_STATUS_THRESHOLD);
/**
* DS2 starts and connects to RS1
*/
ds2 = createReplicationBroker(DS2_ID, new ServerState(), EMPTY_DN_GENID);
br = new BrokerReader(ds2, DS2_ID);
checkConnection(30, DS2_ID);
/**
* DS2 starts sending a lot of changes
*/
bw = new BrokerWriter(ds2, DS2_ID, false);
bw.follow();
sleep(1000); // Let some messages being queued in RS
/**
* DS1 starts and connects to RS1, server state exchange should lead to
* start in degraded status as some changes should be in queued in the RS
* and the threshold value is 1 change in queue.
*/
ds1 = createReplicationDomain(DS1_ID);
checkConnection(30, DS1_ID);
sleepAssertStatusEquals(30, ds1, ServerStatus.DEGRADED_STATUS);
/**
* DS2 stops sending changes: DS1 should replay pending changes and should
* enter the normal status
*/
bw.pause();
// Sleep enough so that replay can be done and analyzer has time
// to see that the queue length is now under the threshold value.
sleepAssertStatusEquals(30, ds1, ServerStatus.NORMAL_STATUS);
/**
* RS1 stops to make DS1 go to not connected status (from normal status)
*/
rs1.remove();
sleepAssertStatusEquals(30, ds1, ServerStatus.NOT_CONNECTED_STATUS);
/**
* DS2 restarts with up to date server state (this allows to have
* restarting RS1 not sending him some updates he already sent)
*/
ds2.stop();
bw.shutdown();
br.shutdown();
ServerState curState = ds1.getServerState();
ds2 = createReplicationBroker(DS2_ID, curState, EMPTY_DN_GENID);
br = new BrokerReader(ds2, DS2_ID);
/**
* RS1 restarts, DS1 should get back to normal status