Move stresstest logs to static Log method

This commit is contained in:
Manfred Karrer 2016-06-12 14:25:15 +02:00
parent 775227b902
commit 11e50ae3bc
5 changed files with 20 additions and 26 deletions

View file

@ -1,11 +1,9 @@
package io.bitsquare.p2p.peers;
import io.bitsquare.app.DevFlags;
import io.bitsquare.app.Log;
import io.bitsquare.common.Clock;
import io.bitsquare.common.Timer;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.util.Profiler;
import io.bitsquare.p2p.NodeAddress;
import io.bitsquare.p2p.network.*;
import io.bitsquare.p2p.peers.peerexchange.Peer;
@ -15,7 +13,6 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
@ -158,6 +155,7 @@ 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"));
if (isSeedNode(connection))
connection.setPeerType(Connection.PeerType.SEED_NODE);
@ -172,6 +170,7 @@ 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"));
handleConnectionFault(connection);
lostAllConnections = networkNode.getAllConnections().isEmpty();
@ -214,8 +213,6 @@ public class PeerManager implements ConnectionListener {
Set<Connection> allConnections = networkNode.getAllConnections();
int size = allConnections.size();
log.info("We have {} connections open. Our limit is {}", size, limit);
if (DevFlags.STRESS_TEST_MODE)
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) + " - Connections = " + size + " / Memory(MB): " + Profiler.getUsedMemory());
if (size > limit) {
log.info("We have too many connections open.\n\t" +

View file

@ -1,7 +1,6 @@
package io.bitsquare.p2p.storage;
import com.google.common.annotations.VisibleForTesting;
import io.bitsquare.app.DevFlags;
import io.bitsquare.app.Log;
import io.bitsquare.app.Version;
import io.bitsquare.common.Timer;
@ -10,7 +9,6 @@ import io.bitsquare.common.crypto.CryptoException;
import io.bitsquare.common.crypto.Hash;
import io.bitsquare.common.crypto.Sig;
import io.bitsquare.common.persistance.Persistable;
import io.bitsquare.common.util.Profiler;
import io.bitsquare.common.wire.Payload;
import io.bitsquare.p2p.Message;
import io.bitsquare.p2p.NodeAddress;
@ -34,7 +32,6 @@ import java.io.File;
import java.io.Serializable;
import java.security.KeyPair;
import java.security.PublicKey;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
@ -162,17 +159,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
if (containsKey) {
log.info("We remove the data as the data owner got disconnected with " +
"closeConnectionReason=" + closeConnectionReason);
if (DevFlags.STRESS_TEST_MODE)
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) +
" - We remove the data as the data owner got disconnected with " +
"closeConnectionReason=" + closeConnectionReason +
" / isIntended=" + closeConnectionReason.isIntended +
" / Memory(MB): " + Profiler.getUsedMemory());
Log.logIfStressTests("We remove the data as the data owner got disconnected with " +
"closeConnectionReason=" + closeConnectionReason +
" / isIntended=" + closeConnectionReason.isIntended);
// TODO We get closeConnectionReason TERMINATED which removes offers which should not be removed
// TODO investigate why EOFException happens
doRemoveProtectedExpirableData(protectedData, hashOfPayload);
} else {
log.debug("Remove data ignored as we don't have an entry for that data.");
}