Skip to content

Commit

Permalink
modify rpcClientPool indirect
Browse files Browse the repository at this point in the history
  • Loading branch information
允厥 committed Oct 10, 2023
1 parent 6ba0b67 commit 613d876
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,23 @@ private void refreshClientPool() {
});
rpcClientPool = innerClientPool;
} else {
for (TuGraphSingleRpcClient rpcClient : rpcClientPool) {
String result = rpcClient.callCypher("CALL dbms.ha.clusterInfo()", "default", 10);
ClusterInfo clusterInfo = JSON.parseObject(JSON.parseArray(result).get(0).toString(), new TypeReference<ClusterInfo>(){});
if (clusterInfo.isMaster()) {
leaderClient = rpcClient;
if (rpcClientPool.size() == 0) {
for (String url : urls) {
TuGraphSingleRpcClient rpcClient = new TuGraphSingleRpcClient("list://" + url, user, password);
String result = rpcClient.callCypher("CALL dbms.ha.clusterInfo()", "default", 10);
ClusterInfo clusterInfo = JSON.parseObject(JSON.parseArray(result).get(0).toString(), new TypeReference<ClusterInfo>(){});
if (clusterInfo.isMaster()) {
leaderClient = rpcClient;
}
rpcClientPool.add(rpcClient);
}
} else {
for (TuGraphSingleRpcClient rpcClient : rpcClientPool) {
String result = rpcClient.callCypher("CALL dbms.ha.clusterInfo()", "default", 10);
ClusterInfo clusterInfo = JSON.parseObject(JSON.parseArray(result).get(0).toString(), new TypeReference<ClusterInfo>(){});
if (clusterInfo.isMaster()) {
leaderClient = rpcClient;
}
}
}
}
Expand Down

0 comments on commit 613d876

Please sign in to comment.