Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private String resetStub() {
Exception ex = null;
for (int i = 0; i < proxy.getHostCount(); i++) {
String host = proxy.nextHost();
close();
closeConnections();

channel = ManagedChannelBuilder.forTarget(host).usePlaintext().build();
PDBlockingStub blockingStub =
Expand All @@ -149,7 +149,7 @@ private String resetStub() {
Metapb.Member leader = members.getLeader();
leaderHost = leader.getGrpcUrl();
if (!host.equals(leaderHost)) {
close();
closeConnections();
channel = ManagedChannelBuilder.forTarget(leaderHost).usePlaintext().build();
}
proxy.setBlockingStub(setBlockingParams(createBlockingStub(), config));
Expand Down Expand Up @@ -261,20 +261,26 @@ protected <ReqT, RespT> void streamingCall(MethodDescriptor<ReqT, RespT> method,
proxy.setStub(null);
}
streamingCall(method, request, responseObserver, ++retry);
return;
}
}
throw new PDException(Pdpb.ErrorType.PD_UNREACHABLE_VALUE,
"RPC streaming call failed", e);
}
}

@Override
public void close() {
closeConnections();
}

private void closeConnections() {
closeChannel(channel);
if (stubs != null) {
for (AbstractBlockingStub stub : stubs.values()) {
closeChannel((ManagedChannel) stub.getChannel());
}
}

}

private void closeChannel(ManagedChannel channel) {
Expand Down
Loading
Loading