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) {
if (DevFlags.STRESS_TEST_MODE)
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) +
msg +
" - " + msg +
" / Memory(MB): " + Profiler.getUsedMemory());
}
}

View File

@ -155,7 +155,9 @@ public class PeerManager implements ConnectionListener {
@Override
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))
connection.setPeerType(Connection.PeerType.SEED_NODE);
@ -170,7 +172,9 @@ public class PeerManager implements ConnectionListener {
@Override
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);
lostAllConnections = networkNode.getAllConnections().isEmpty();

View File

@ -159,9 +159,11 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
if (containsKey) {
log.info("We remove the data as the data owner got disconnected with " +
"closeConnectionReason=" + closeConnectionReason);
Log.logIfStressTests("We remove the data as the data owner got disconnected with " +
"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 investigate why EOFException happens