mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Move stresstest logs to static Log method
This commit is contained in:
parent
775227b902
commit
11e50ae3bc
5 changed files with 20 additions and 26 deletions
|
@ -9,5 +9,4 @@ public class DevFlags {
|
|||
public static final boolean STRESS_TEST_MODE = true;
|
||||
public static final boolean DEV_MODE = STRESS_TEST_MODE || false;
|
||||
public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true;
|
||||
|
||||
}
|
||||
|
|
|
@ -24,8 +24,12 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
|
|||
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
|
||||
import ch.qos.logback.core.rolling.RollingFileAppender;
|
||||
import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
|
||||
import io.bitsquare.common.util.Profiler;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class Log {
|
||||
private static SizeBasedTriggeringPolicy triggeringPolicy;
|
||||
private static Logger logbackLogger;
|
||||
|
@ -105,4 +109,11 @@ public class Log {
|
|||
LoggerFactory.getLogger(className).trace("Called: {} [{}]", methodName, message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void logIfStressTests(String msg) {
|
||||
if (DevFlags.STRESS_TEST_MODE)
|
||||
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) +
|
||||
msg +
|
||||
" / Memory(MB): " + Profiler.getUsedMemory());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.offer.offerbook;
|
||||
|
||||
import io.bitsquare.app.DevFlags;
|
||||
import io.bitsquare.common.util.Profiler;
|
||||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import io.bitsquare.trade.offer.OfferBookService;
|
||||
|
@ -28,8 +27,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
@ -63,8 +60,7 @@ public class OfferBook {
|
|||
if (!offerBookListItems.contains(offerBookListItem)) {
|
||||
offerBookListItems.add(offerBookListItem);
|
||||
|
||||
if (DevFlags.STRESS_TEST_MODE)
|
||||
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) + " - Offer added: Nr. of offers = " + offerBookListItems.size() + " / Memory(MB): " + Profiler.getUsedMemory());
|
||||
Log.logIfStressTests("Offer added: Nr. of offers = " + offerBookListItems.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,8 +79,7 @@ public class OfferBook {
|
|||
if (offerBookListItems.contains(item)) {
|
||||
offerBookListItems.remove(item);
|
||||
|
||||
if (DevFlags.STRESS_TEST_MODE)
|
||||
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) + " - Offer removed: Nr. of offers = " + offerBookListItems.size() + " / Memory(MB): " + Profiler.getUsedMemory());
|
||||
Log.logIfStressTests("Offer removed: Nr. of offers = " + offerBookListItems.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +102,7 @@ public class OfferBook {
|
|||
|
||||
offerBookListItems.addAll(list);
|
||||
|
||||
if (DevFlags.STRESS_TEST_MODE)
|
||||
System.err.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()) + " - Offer filled: Nr. of offers = " + offerBookListItems.size() + " / Memory(MB): " + Profiler.getUsedMemory());
|
||||
Log.logIfStressTests("Offer filled: Nr. of offers = " + offerBookListItems.size());
|
||||
|
||||
log.debug("offerBookListItems " + offerBookListItems.size());
|
||||
}
|
||||
|
|
|
@ -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" +
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue