Improce logging

This commit is contained in:
Manfred Karrer 2016-06-12 14:50:06 +02:00
parent 807f5f2e50
commit 67a3c5d502
3 changed files with 10 additions and 4 deletions

View file

@ -113,7 +113,7 @@ public class Log {
public static void logIfStressTests(String msg) { public static void logIfStressTests(String msg) {
if (DevFlags.STRESS_TEST_MODE) if (DevFlags.STRESS_TEST_MODE)
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) + System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) +
msg + " - " + msg +
" / Memory(MB): " + Profiler.getUsedMemory()); " / Memory(MB): " + Profiler.getUsedMemory());
} }
} }

View file

@ -155,7 +155,9 @@ public class PeerManager implements ConnectionListener {
@Override @Override
public void onConnection(Connection connection) { public void onConnection(Connection connection) {
Log.logIfStressTests("onConnection to peer " + networkNode.getAllConnections().size() + (connection.getPeersNodeAddressOptional().isPresent() ? connection.getPeersNodeAddressOptional().get() : "PeersNode unknown")); Log.logIfStressTests("onConnection to peer " +
(connection.getPeersNodeAddressOptional().isPresent() ? connection.getPeersNodeAddressOptional().get() : "PeersNode unknown") +
" / Nr. of connections: " + networkNode.getAllConnections().size());
if (isSeedNode(connection)) if (isSeedNode(connection))
connection.setPeerType(Connection.PeerType.SEED_NODE); connection.setPeerType(Connection.PeerType.SEED_NODE);
@ -170,7 +172,9 @@ public class PeerManager implements ConnectionListener {
@Override @Override
public void onDisconnect(CloseConnectionReason closeConnectionReason, Connection connection) { public void onDisconnect(CloseConnectionReason closeConnectionReason, Connection connection) {
Log.logIfStressTests("onDisconnect of peer " + networkNode.getAllConnections().size() + (connection.getPeersNodeAddressOptional().isPresent() ? connection.getPeersNodeAddressOptional().get() : "PeersNode unknown")); Log.logIfStressTests("onDisconnect of peer " +
(connection.getPeersNodeAddressOptional().isPresent() ? connection.getPeersNodeAddressOptional().get() : "PeersNode unknown") +
" / Nr. of connections: " + networkNode.getAllConnections().size());
handleConnectionFault(connection); handleConnectionFault(connection);
lostAllConnections = networkNode.getAllConnections().isEmpty(); lostAllConnections = networkNode.getAllConnections().isEmpty();

View file

@ -159,9 +159,11 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
if (containsKey) { if (containsKey) {
log.info("We remove the data as the data owner got disconnected with " + log.info("We remove the data as the data owner got disconnected with " +
"closeConnectionReason=" + closeConnectionReason); "closeConnectionReason=" + closeConnectionReason);
Log.logIfStressTests("We remove the data as the data owner got disconnected with " + Log.logIfStressTests("We remove the data as the data owner got disconnected with " +
"closeConnectionReason=" + closeConnectionReason + "closeConnectionReason=" + closeConnectionReason +
" / isIntended=" + closeConnectionReason.isIntended); " / isIntended=" + closeConnectionReason.isIntended +
" / peer=" + (connection.getPeersNodeAddressOptional().isPresent() ? connection.getPeersNodeAddressOptional().get() : "PeersNode unknown"));
// TODO We get closeConnectionReason TERMINATED which removes offers which should not be removed // TODO We get closeConnectionReason TERMINATED which removes offers which should not be removed
// TODO investigate why EOFException happens // TODO investigate why EOFException happens