Search in sources :

Example 1 with ServiceReplica

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;
        }
    }
}
Also used : ServiceReplica(bftsmart.tom.ServiceReplica)

Example 2 with ServiceReplica

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;
}
Also used : ClientCommunicationServerSide(bftsmart.communication.client.ClientCommunicationServerSide) ServiceReplica(bftsmart.tom.ServiceReplica) ServerCommunicationSystemImpl(bftsmart.communication.ServerCommunicationSystemImpl) MessageHandler(bftsmart.communication.MessageHandler) ServerCommunicationSystem(bftsmart.communication.ServerCommunicationSystem) MemoryBasedViewStorage(bftsmart.reconfiguration.views.MemoryBasedViewStorage) TOMConfiguration(bftsmart.reconfiguration.util.TOMConfiguration) ServerViewController(bftsmart.reconfiguration.ServerViewController) IOException(java.io.IOException)

Aggregations

ServiceReplica (bftsmart.tom.ServiceReplica)2 MessageHandler (bftsmart.communication.MessageHandler)1 ServerCommunicationSystem (bftsmart.communication.ServerCommunicationSystem)1 ServerCommunicationSystemImpl (bftsmart.communication.ServerCommunicationSystemImpl)1 ClientCommunicationServerSide (bftsmart.communication.client.ClientCommunicationServerSide)1 ServerViewController (bftsmart.reconfiguration.ServerViewController)1 TOMConfiguration (bftsmart.reconfiguration.util.TOMConfiguration)1 MemoryBasedViewStorage (bftsmart.reconfiguration.views.MemoryBasedViewStorage)1 IOException (java.io.IOException)1