Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 024c417

Browse files
committed
FAB-5290 Orderer wait time not being set properly
Change-Id: I297667775d9a0319b4ea47a5f43b0327abc33bc2 Signed-off-by: rickr <cr22rc@gmail.com>
1 parent 7ed5ebc commit 024c417

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/main/java/org/hyperledger/fabric/sdk/OrdererClient.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DTCC, Fujitsu Australia Software Technology - All Rights Reserved.
2+
* Copyright 2016, 2017 DTCC, Fujitsu Australia Software Technology, IBM - All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
3838
* Sample client code that makes gRPC calls to the server.
3939
*/
4040
class OrdererClient {
41-
private static final long ORDERER_WAIT_TIME = 2000L;
41+
private static final long ORDERER_WAIT_TIME = 3000L;
4242
private final String channelName;
4343
private final ManagedChannelBuilder channelBuilder;
4444
private boolean shutdown = false;
@@ -66,8 +66,15 @@ class OrdererClient {
6666

6767
String ordererWaitTimeMilliSecsString = properties.getProperty("ordererWaitTimeMilliSecs", Long.toString(ORDERER_WAIT_TIME));
6868

69-
ordererWaitTimeMilliSecs = Long.getLong(ordererWaitTimeMilliSecsString, ORDERER_WAIT_TIME);
69+
long tempOrdererWaitTimeMilliSecs = ORDERER_WAIT_TIME;
7070

71+
try {
72+
tempOrdererWaitTimeMilliSecs = Long.parseLong(ordererWaitTimeMilliSecsString);
73+
} catch (NumberFormatException e) {
74+
logger.warn(format("Orderer %s wait time %s not parsable.", name, ordererWaitTimeMilliSecsString), e);
75+
}
76+
77+
ordererWaitTimeMilliSecs = tempOrdererWaitTimeMilliSecs;
7178
}
7279

7380

@@ -160,13 +167,15 @@ public void onCompleted() {
160167

161168
try {
162169
if (!finishLatch.await(ordererWaitTimeMilliSecs, TimeUnit.MILLISECONDS)) {
163-
TransactionException ste = new TransactionException("Send transactions failed. Reason: timeout");
170+
TransactionException ste = new TransactionException(format("Channel %s, send transactions failed on orderer %s. Reason: timeout after %d ms.",
171+
channelName, name, ordererWaitTimeMilliSecs));
164172
logger.error("sendTransaction error " + ste.getMessage(), ste);
165173
throw ste;
166174
}
167175
if (throwable[0] != null) {
168176
//get full stack trace
169-
TransactionException ste = new TransactionException("Send transactions failed. Reason: " + throwable[0].getMessage(), throwable[0]);
177+
TransactionException ste = new TransactionException(format("Channel %s, send transaction failed on orderer %s. Reason: %s",
178+
channelName, name, throwable[0].getMessage()), throwable[0]);
170179
logger.error("sendTransaction error " + ste.getMessage(), ste);
171180
throw ste;
172181
}
@@ -271,7 +280,8 @@ public void onCompleted() {
271280

272281
try {
273282
if (!finishLatch.await(ordererWaitTimeMilliSecs, TimeUnit.MILLISECONDS)) {
274-
TransactionException ex = new TransactionException("sendDeliver time exceeded for orderer");
283+
TransactionException ex = new TransactionException(format(
284+
"Channel %s sendDeliver time exceeded for orderer %s, timed out at %d", channelName, name, ordererWaitTimeMilliSecs));
275285
logger.error(ex.getMessage(), ex);
276286
throw ex;
277287
}
@@ -283,7 +293,8 @@ public void onCompleted() {
283293

284294
if (!throwableList.isEmpty()) {
285295
Throwable throwable = throwableList.get(0);
286-
TransactionException e = new TransactionException(throwable.getMessage(), throwable);
296+
TransactionException e = new TransactionException(format(
297+
"Channel %s sendDeliver failed on orderer %s. Reason: %s", channelName, name, throwable.getMessage()), throwable);
287298
logger.error(e.getMessage(), e);
288299
throw e;
289300
}

0 commit comments

Comments
 (0)