Skip to content

Commit

Permalink
FAB-11283 Minor logging issues.
Browse files Browse the repository at this point in the history
Change-Id: I495fa1224bb1b9a48e882a657c952622113cfae1
Signed-off-by: rickr <cr22rc@gmail.com>
  • Loading branch information
cr22rc committed Jul 24, 2018
1 parent 6607f60 commit 015c142
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/hyperledger/fabric/sdk/Peer.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class Peer implements Serializable {
private transient PeerEventServiceClient peerEventingClient;
private transient boolean shutdown = false;
private Channel channel;
private String channelName;
private transient TransactionContext transactionContext;
private transient long lastConnectTime;
private transient long reconnectCount;
Expand Down Expand Up @@ -115,6 +116,7 @@ public Properties getProperties() {

void unsetChannel() {
channel = null;
channelName = null;
}

BlockEvent getLastBlockEvent() {
Expand Down Expand Up @@ -168,6 +170,7 @@ void setChannel(Channel channel) throws InvalidArgumentException {
}

this.channel = channel;
this.channelName = channel.getName();

}

Expand Down Expand Up @@ -368,7 +371,7 @@ public Throwable getExceptionThrown() {

@Override
public void reconnect(Long startBLockNumber) throws TransactionException {
logger.trace("reconnecting startBLockNumber: " + startBLockNumber == null ? "newest" : startBLockNumber);
logger.trace(format("Channel %s %s reconnecting. Starting block number: %s", channelName, toString(), startBLockNumber == null ? "newest" : startBLockNumber));
++reconnectCount;

if (startBLockNumber == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ SDNetwork networkDiscovery(TransactionContext ltransactionContext, boolean force
break;

} catch (Exception e) {
logger.warn(format("Channel %s peer %s service discovery error %s", channelName, serviceDiscoveryPeer, e));

logger.warn(format("Channel %s peer %s service discovery error %s", channelName, serviceDiscoveryPeer, e.getMessage()));
}
}

Expand Down Expand Up @@ -948,6 +947,7 @@ void run() {
return t;
}).scheduleAtFixedRate(() -> {

logger.debug(format("Channel %s starting service rediscovery after %d seconds.", channelName, SERVICE_DISCOVER_FREQ_SECONDS));
fullNetworkDiscovery(true);

}, SERVICE_DISCOVER_FREQ_SECONDS, SERVICE_DISCOVER_FREQ_SECONDS, TimeUnit.SECONDS);
Expand All @@ -959,7 +959,7 @@ SDNetwork fullNetworkDiscovery(boolean force) {
if (channel.isShutdown()) {
return null;
}
logger.trace(format("Full network discovery force %b", force));
logger.trace(format("Full network discovery force: %b", force));
try {
SDNetwork osdNetwork = sdNetwork;
SDNetwork lsdNetwork = networkDiscovery(transactionContext.retryTransactionSameContext(), force);
Expand All @@ -981,7 +981,7 @@ SDNetwork fullNetworkDiscovery(boolean force) {
} catch (Exception e) {
logger.warn("Service discovery got error:" + e.getMessage(), e);
} finally {
logger.trace("Full network discovery completed.");
logger.trace("Full network rediscovery completed.");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ public PrivateKey bytesToPrivateKey(byte[] pemKey) throws CryptoException {
PemReader pr = new PemReader(new StringReader(new String(pemKey)));
PemObject po = pr.readPemObject();
PEMParser pem = new PEMParser(new StringReader(new String(pemKey)));
logger.debug("found private key with type " + po.getType());

if (po.getType().equals("PRIVATE KEY")) {
pk = new JcaPEMKeyConverter().getPrivateKey((PrivateKeyInfo) pem.readObject());
} else {
logger.trace("Found private key with type " + po.getType());
PEMKeyPair kp = (PEMKeyPair) pem.readObject();
pk = new JcaPEMKeyConverter().getPrivateKey(kp.getPrivateKeyInfo());
}
Expand Down

0 comments on commit 015c142

Please sign in to comment.