Search in sources :

Example 1 with BftsmartReplica

use of com.jd.blockchain.consensus.bftsmart.BftsmartReplica in project jdchain-core by blockchain-jd-com.

the class BftsmartConsensusManageService method addNode.

@Override
public AsyncFuture<ConsensusView> addNode(Replica replica) {
    BftsmartServiceProxyPool serviceProxyPool = getServiceProxyPool();
    BftsmartReplica bftsmartReplica = (BftsmartReplica) replica;
    CompletableAsyncFuture<ConsensusView> asyncFuture = new CompletableAsyncFuture<>();
    AsynchServiceProxy serviceProxy = null;
    try {
        serviceProxy = serviceProxyPool.borrowObject();
        Reconfiguration reconfiguration = new Reconfiguration(serviceProxy.getProcessId(), serviceProxy);
        reconfiguration.addServer(bftsmartReplica.getId(), bftsmartReplica.getNetworkAddress());
        ReconfigureReply reply = reconfiguration.execute();
        asyncFuture.complete(new BftsmartView(reply.getView()));
    } catch (Exception e) {
        asyncFuture.error(e);
    } finally {
        if (serviceProxy != null) {
            serviceProxyPool.returnObject(serviceProxy);
        }
    }
    return asyncFuture;
}
Also used : ReconfigureReply(bftsmart.reconfiguration.ReconfigureReply) BftsmartServiceProxyPool(com.jd.blockchain.consensus.bftsmart.client.BftsmartServiceProxyPool) BftsmartReplica(com.jd.blockchain.consensus.bftsmart.BftsmartReplica) CompletableAsyncFuture(utils.concurrent.CompletableAsyncFuture) ConsensusView(com.jd.blockchain.consensus.manage.ConsensusView) AsynchServiceProxy(bftsmart.tom.AsynchServiceProxy) Reconfiguration(bftsmart.reconfiguration.Reconfiguration)

Aggregations

Reconfiguration (bftsmart.reconfiguration.Reconfiguration)1 ReconfigureReply (bftsmart.reconfiguration.ReconfigureReply)1 AsynchServiceProxy (bftsmart.tom.AsynchServiceProxy)1 BftsmartReplica (com.jd.blockchain.consensus.bftsmart.BftsmartReplica)1 BftsmartServiceProxyPool (com.jd.blockchain.consensus.bftsmart.client.BftsmartServiceProxyPool)1 ConsensusView (com.jd.blockchain.consensus.manage.ConsensusView)1 CompletableAsyncFuture (utils.concurrent.CompletableAsyncFuture)1