Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_SOURCES");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff Check");
// Now Response arrives
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
validateConnState(connState);
}
}
// When on SOURCES-REQUEST-SENT and SOURCES_RESPONSE_ERROR
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.SOURCES_REQUEST_SENT, "ServerSetChange while SOURCES_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while SOURCES_REQUEST_SENT");
}
// ServerSetChange when New Set excludes CurrentServer and SOURCES_RESPONSE_ERROR
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.SOURCES_REQUEST_SENT, "ServerSetChange while REQUEST_SOURCES");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_SOURCES");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
// Now Response arrives
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesResponseError();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_ERROR, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on SOURCES-REQUEST-SENT and SOURCES_REQUEST_ERROR
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.SOURCES_REQUEST_SENT, "ServerSetChange while SOURCES_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while SOURCES_REQUEST_SENT");
}
// ServerSetChange when New Set excludes CurrentServer and SOURCES_REQUEST_ERROR
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.SOURCES_REQUEST_SENT, "ServerSetChange while REQUEST_SOURCES");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_SOURCES");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
// Now Response arrives
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesRequestError();
testTransitionCase(relayPuller, StateId.SOURCES_REQUEST_ERROR, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on Request Register
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
validateConnState(connState);
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REQUEST_REGISTER, "ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [REQUEST_REGISTER]", "Queue :ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
}
// ServerSetChange when New Set excludes CurrentServer
{
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.PICK_SERVER, "ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [PICK_SERVER]", "Queue :ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on REGISTER-REQUEST-SENT and REGISTER_RESPONSE_ERROR
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
String sourcesIdListString = "1";
connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REGISTER_REQUEST_SENT, "ServerSetChange while REGISTER_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REGISTER_REQUEST_SENT");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
}
// ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REGISTER_REQUEST_SENT, "ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
connState.switchToRegisterResponseError();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_ERROR, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on REGISTER-REQUEST-SENT and REGISTER_REQUEST_ERROR
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
String sourcesIdListString = "1";
connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REGISTER_REQUEST_SENT, "ServerSetChange while REGISTER_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REGISTER_REQUEST_SENT");
}
// ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REGISTER_REQUEST_SENT, "ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
connState.switchToSourcesRequestError();
testTransitionCase(relayPuller, StateId.REGISTER_REQUEST_ERROR, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on REGISTER-REQUEST-SENT and Response Successful
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
validateConnState(connState);
relayPuller.getMessageQueue().clear();
String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
String sourcesIdListString = "1";
connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REGISTER_REQUEST_SENT, "ServerSetChange while REGISTER_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REGISTER_REQUEST_SENT");
}
// ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REGISTER_REQUEST_SENT, "ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_REGISTER");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
// Now Response arrives
MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
connState.switchToRegisterSuccess(conn.getRegisterResponse(), conn.getRegisterResponse(), conn.getRegisterMetadataResponse());
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// when on REQUEST_STREAM
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.REQUEST_STREAM, "ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [REQUEST_STREAM]", "Queue :ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
}
// ServerSetChange when New Set excludes CurrentServer
{
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.PICK_SERVER, "ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [PICK_SERVER]", "Queue :ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on STREAM_REQUEST_SENT and response successful
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
String sourcesIdListString = "1";
connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
relayPuller.getMessageQueue().clear();
MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
connState.switchToRegisterSuccess(conn.getRegisterResponse(), conn.getRegisterResponse(), conn.getRegisterMetadataResponse());
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SENT, "");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.STREAM_REQUEST_SENT, "ServerSetChange while STREAM_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while STREAM_REQUEST_SENT");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
}
// ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.STREAM_REQUEST_SENT, "ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
// Now Response arrives
conn = (MockRelayConnection)connState.getRelayConnection();
connState.switchToStreamSuccess(conn.getStreamResponse());
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on STREAM_REQUEST_SENT and STREAM_RESPONSE_ERROR
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
String sourcesIdListString = "1";
connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
relayPuller.getMessageQueue().clear();
MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
connState.switchToRegisterSuccess(conn.getRegisterResponse(), conn.getRegisterResponse(), conn.getRegisterMetadataResponse());
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SENT, "");
// ServerSetChange when New Set includes CurrentServer
{
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer() != null, true, "Current Server not Null");
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(true, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.STREAM_REQUEST_SENT, "ServerSetChange while STREAM_REQUEST_SENT");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while STREAM_REQUEST_SENT");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
}
// ServerSetChange when New Set excludes CurrentServer and StreamResponse Error
{
int oldServerIndex = relayPuller.getCurrentServerIdx();
ServerInfo oldServer = relayPuller.getCurentServer();
Assert.assertEquals(relayPuller.getServers(),expServerInfo2,"Server Set");
doExecuteAndChangeState(relayPuller,createSetServerMessage(false, relayPuller));
Assert.assertEquals(relayPuller.getCurrentServerIdx(), oldServerIndex, "Current Server Index unchanged");
Assert.assertEquals(relayPuller.getCurentServer(), oldServer, "Current Server unchanged");
Assert.assertEquals(relayPuller.getServers(),expServerInfo3,"Server Set");
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), true, "Tear Conn After Handling Response");
Assert.assertEquals(connState.getStateId(),StateId.STREAM_REQUEST_SENT, "ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while REQUEST_STREAM");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");
// Now Response arrives
connState.switchToStreamResponseError();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS, StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
Assert.assertEquals(relayPuller.getCurentServer() == null, true, "Current Server Null");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Relay FellOff CHeck");
}
}
// When on STREAM_REQUEST_SENT and STREAM_REQUEST_ERROR
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createFellOffRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
validateConnState(connState);
relayPuller.getMessageQueue().clear();