@Before
public void setUp() throws Exception {
client = new ReplicationClientAdapter(rpcClient, config.getInetSocketAddress());
RequestHandler rqHandler = new ReplicationRequestHandler(new StatesManipulation() {
@Override
public void update(InetSocketAddress participant, LSN acknowledgedLSN, long receiveTime)
throws UnknownParticipantException {
fail("Operation should not have been accessed by this test!");
}
@Override
public void requestFinished(SlaveClient slave) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void markAsDead(ClientInterface slave) {
fail("Operation should not have been accessed by this test!");
}
},
new ControlLayerInterface() {
@Override
public void updateLeaseHolder(InetSocketAddress leaseholder) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void receive(FleaseMessage message) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void driftDetected() {
fail("Operation should not have been accessed by this test!");
}
@Override
public void unlockUser() {
fail("Operation should not have been accessed by this test!");
}
@Override
public void unlockReplication() {
fail("Operation should not have been accessed by this test!");
}
@Override
public void registerUserInterface(LockableService service) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void registerReplicationControl(LockableService service) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void registerProxyRequestControl(RequestControl control) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void notifyForSuccessfulFailover(InetSocketAddress master) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void lockAll() throws InterruptedException {
fail("Operation should not have been accessed by this test!");
}
@Override
public boolean isItMe(InetSocketAddress address) {
fail("Operation should not have been accessed by this test!");
return false;
}
@Override
public InetSocketAddress getLeaseHolder(int timeout) {
fail("Operation should not have been accessed by this test!");
return null;
}
}, new BabuDBInterface(new BabuDBMock("BabuDBMock", conf0, testLSN)), new RequestManagement() {
@Override
public void finalizeRequest(StageRequest op) {
fail("Operation should not have been accessed by this test!");
}
@Override
public void enqueueOperation(Object[] args) throws BusyServerException, ServiceLockedException {
assertTrue(args.length == 2);
LSN receivedLSN = (LSN) args[0];
assertEquals(testLSN, receivedLSN);
LogEntry receivedEntry = (LogEntry) args[1];
assertEquals(testEntry.getPayloadType(), receivedEntry.getPayloadType());
assertEquals(testType, receivedEntry.getPayloadType());
assertEquals(testEntry.getPayload().capacity(), receivedEntry.getPayload().capacity());
assertEquals(testEntry.getPayload().remaining(), receivedEntry.getPayload().remaining());
assertEquals(testEntry.getPayload().position(), receivedEntry.getPayload().position());
assertEquals(new String(testEntry.getPayload().array()),
new String(receivedEntry.getPayload().array()));
// clean up
receivedEntry.free();
}
@Override
public void createStableState(LSN lastOnView, InetSocketAddress master) {
fail("Operation should not have been accessed by this test!");
}
}, lastOnView, config.getChunkSize(), new FileIO(config), MAX_Q);
rqHandler.processQueue();
dispatcher = new RequestDispatcher(config);
dispatcher.setLifeCycleListener(this);
dispatcher.addHandler(rqHandler);
dispatcher.start();
dispatcher.waitForStartup();