use of com.jd.blockchain.consensus.raft.rpc.QueryManagerInfoRequest in project jdchain-core by blockchain-jd-com.
the class RaftMessageService method queryPeersManagerInfo.
private List<MonitorNodeNetwork> queryPeersManagerInfo(List<PeerId> peerIds) throws InterruptedException {
if (!isReloadMonitorNode) {
return monitorNodeNetworks;
}
synchronized (monitorLock) {
if (!isReloadMonitorNode) {
return monitorNodeNetworks;
}
final List<MonitorNodeNetwork> nodeNetworkList = Collections.synchronizedList(new ArrayList<>(peerIds.size()));
CountDownLatch countDownLatch = new CountDownLatch(peerIds.size());
QueryManagerInfoRequest infoRequest = new QueryManagerInfoRequest();
for (PeerId peerId : peerIds) {
try {
clientService.getRpcClient().invokeAsync(peerId.getEndpoint(), infoRequest, (o, e) -> {
try {
if (e != null) {
LoggerUtils.errorIfEnabled(LOGGER, "queryPeersManagerInfo response error, peer id: {}", peerId, e);
} else {
RpcResponse response = (RpcResponse) o;
QueryManagerInfoRequestProcessor.ManagerInfoResponse managerInfoResponse = QueryManagerInfoRequestProcessor.ManagerInfoResponse.fromBytes(response.getResult());
MonitorNodeNetwork monitorNodeNetwork = new MonitorNodeNetwork(managerInfoResponse.getHost(), managerInfoResponse.getConsensusPort(), managerInfoResponse.getManagerPort(), managerInfoResponse.isConsensusSSLEnabled(), managerInfoResponse.isManagerSSLEnabled());
nodeNetworkList.add(monitorNodeNetwork);
}
} catch (Exception exception) {
LoggerUtils.errorIfEnabled(LOGGER, "handle queryPeersManagerInfo response error", e);
} finally {
countDownLatch.countDown();
}
}, this.rpcTimeoutMs);
} catch (Exception e) {
LOGGER.error("queryPeersManagerInfo error", e);
countDownLatch.countDown();
}
}
countDownLatch.await(this.rpcTimeoutMs * peerIds.size(), TimeUnit.MILLISECONDS);
monitorNodeNetworks.clear();
monitorNodeNetworks.addAll(nodeNetworkList);
isReloadMonitorNode = false;
}
return monitorNodeNetworks;
}
use of com.jd.blockchain.consensus.raft.rpc.QueryManagerInfoRequest in project jdchain-core by blockchain-jd-com.
the class BlockSyncService method getConsensusNodeManagerInfo.
private ServiceEndpoint getConsensusNodeManagerInfo(Endpoint remoteEndpoint) {
try {
QueryManagerInfoRequest request = new QueryManagerInfoRequest();
RpcResponse response = (RpcResponse) rpcClient.invokeSync(remoteEndpoint, request, requestTimeoutMs);
QueryManagerInfoRequestProcessor.ManagerInfoResponse infoResponse = QueryManagerInfoRequestProcessor.ManagerInfoResponse.fromBytes(response.getResult());
return new ServiceEndpoint(remoteEndpoint.getIp(), infoResponse.getManagerPort(), infoResponse.isManagerSSLEnabled());
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}
Aggregations