Search in sources :

Example 1 with ServerCommunicationSystem

use of bftsmart.communication.ServerCommunicationSystem in project aware by bergerch.

the class ServiceReplica method init.

// this method initializes the object
private void init() {
    try {
        cs = new ServerCommunicationSystem(this.SVController, this);
    } catch (Exception ex) {
        logger.error("Failed to initialize replica-to-replica communication system", ex);
        throw new RuntimeException("Unable to build a communication system.");
    }
    if (this.SVController.isInCurrentView()) {
        logger.info("In current view: " + this.SVController.getCurrentView());
        // initiaze the TOM layer
        initTOMLayer();
    } else {
        logger.info("Not in current view: " + this.SVController.getCurrentView());
        // Not in the initial view, just waiting for the view where the join has been executed
        logger.info("Waiting for the TTP: " + this.SVController.getCurrentView());
        waitTTPJoinMsgLock.lock();
        try {
            canProceed.awaitUninterruptibly();
        } finally {
            waitTTPJoinMsgLock.unlock();
        }
    }
    initReplica();
}
Also used : ServerCommunicationSystem(bftsmart.communication.ServerCommunicationSystem)

Example 2 with ServerCommunicationSystem

use of bftsmart.communication.ServerCommunicationSystem 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

ServerCommunicationSystem (bftsmart.communication.ServerCommunicationSystem)2 MessageHandler (bftsmart.communication.MessageHandler)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 ServiceReplica (bftsmart.tom.ServiceReplica)1 IOException (java.io.IOException)1