use of com.jd.blockchain.consensus.bftsmart.client.BftsmartServiceProxyPool 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;
}
use of com.jd.blockchain.consensus.bftsmart.client.BftsmartServiceProxyPool in project jdchain-core by blockchain-jd-com.
the class BftsmartConsensusManageService method removeNode.
@Override
public AsyncFuture<ConsensusView> removeNode(Replica replica) {
BftsmartServiceProxyPool serviceProxyPool = getServiceProxyPool();
CompletableAsyncFuture<ConsensusView> asyncFuture = new CompletableAsyncFuture<>();
AsynchServiceProxy serviceProxy = null;
try {
serviceProxy = serviceProxyPool.borrowObject();
Reconfiguration reconfiguration = new Reconfiguration(serviceProxy.getProcessId(), serviceProxy);
reconfiguration.removeServer(replica.getId());
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;
}
Aggregations