Skip to content

Commit

Permalink
FABJ-343 Prevent peer reconnecting on shutdown.
Browse files Browse the repository at this point in the history
Change-Id: I90d668e72516dcedc29a51b660682fc00209add8
Signed-off-by: rickr <cr22rc@gmail.com>
  • Loading branch information
cr22rc committed Aug 13, 2018
1 parent ff953b0 commit d8bd082
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/hyperledger/fabric/sdk/Peer.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Peer implements Serializable {
private final String url;
private transient volatile EndorserClient endorserClent;
private transient PeerEventServiceClient peerEventingClient;
private transient boolean shutdown = false;
private transient volatile boolean shutdown = false;
private Channel channel;
private String channelName;
private transient TransactionContext transactionContext;
Expand Down Expand Up @@ -346,7 +346,7 @@ void reconnectPeerEventServiceClient(final PeerEventServiceClient failedPeerEven
final ExecutorService executorService = getExecutorService();
final PeerOptions peerOptions = null != failedPeerEventServiceClient.getPeerOptions() ? failedPeerEventServiceClient.getPeerOptions() :
PeerOptions.createPeerOptions();
if (executorService != null && !executorService.isShutdown() && !executorService.isTerminated()) {
if (!shutdown && executorService != null && !executorService.isShutdown() && !executorService.isTerminated()) {

executorService.execute(() -> ldisconnectedHandler.disconnected(new PeerEventingServiceDisconnectEvent() {
@Override
Expand Down Expand Up @@ -412,8 +412,7 @@ void setTLSCertificateKeyPair(TLSCertificateKeyPair tlsCertificateKeyPair) {
Endpoint endpoint = Endpoint.createEndpoint(url, properties);
foundClientTLSCertificateDigest = true;
clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest();
EndorserClient localEndorserClient = new EndorserClient(endpoint.getChannelBuilder());
endorserClent = localEndorserClient;
endorserClent = new EndorserClient(endpoint.getChannelBuilder());
}

void setHasConnected() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ class PeerEventServiceClient {
StreamObserver<Envelope> nso = null;
StreamObserver<DeliverResponse> so = null;
private Channel.ChannelEventQue channelEventQue;
private boolean shutdown = false;
private volatile boolean shutdown = false;
private transient ManagedChannel managedChannel = null;
private transient TransactionContext transactionContext;
private transient Peer peer;

/**
Expand Down Expand Up @@ -168,7 +167,8 @@ public void finalize() {
void connectEnvelope(Envelope envelope) throws TransactionException {

if (shutdown) {
throw new TransactionException("Peer eventing client is shutdown");
logger.warn(format("Peer %s not connecting is shutdown ", peer));
return;
}

ManagedChannel lmanagedChannel = managedChannel;
Expand Down Expand Up @@ -338,10 +338,10 @@ boolean isChannelActive() {
}

void connect(TransactionContext transactionContext) throws TransactionException {

this.transactionContext = transactionContext;
if (shutdown) {
return;
}
peerVent(transactionContext);

}

//=========================================================
Expand Down

0 comments on commit d8bd082

Please sign in to comment.