use of bftsmart.tom.ServiceReplica in project jdchain-core by blockchain-jd-com.
the class BftsmartNodeServer method stop.
@Override
public void stop() {
if (status != Status.RUNNING) {
return;
}
synchronized (mutex) {
if (status != Status.RUNNING) {
return;
}
status = Status.STOPPING;
try {
ServiceReplica rep = this.replica;
if (rep != null) {
LOGGER.debug("Stop replica...[ID=" + rep.getId() + "]");
this.replica = null;
this.topology = null;
rep.kill();
LOGGER.debug("Replica had stopped! --[ID=" + rep.getId() + "]");
}
} finally {
status = Status.STOPPED;
}
}
}
use of bftsmart.tom.ServiceReplica in project bftsmart by blockchain-jd-com.
the class TestNodeServer method startNode.
public ServiceReplica startNode(String realmName) {
TOMConfiguration config = initConfig();
try {
// mock messsageHandler and cs
MessageHandler messageHandler = new MessageHandler();
MessageHandler mockMessageHandler = Mockito.spy(messageHandler);
ClientCommunicationServerSide clientCommunication = ClientCommunicationFactory.createServerSide(new ServerViewController(config, new MemoryBasedViewStorage(latestView)));
ServerCommunicationSystem cs = new ServerCommunicationSystemImpl(clientCommunication, mockMessageHandler, new ServerViewController(config, new MemoryBasedViewStorage(latestView)), realmName);
ServerCommunicationSystem mockCs = Mockito.spy(cs);
replica = new ServiceReplica(mockMessageHandler, mockCs, config, this, this, (int) -1, latestView, realmName);
} catch (Exception e) {
e.printStackTrace();
}
return replica;
}
Aggregations