Removed STRESS_TEST flag

This commit is contained in:
Manfred Karrer 2016-05-25 17:13:53 +02:00
parent ff2c9d619f
commit 8dd9069ecb
14 changed files with 23 additions and 25 deletions

View file

@ -3,8 +3,6 @@ package io.bitsquare.common;
import java.time.Duration; import java.time.Duration;
public interface Timer { public interface Timer {
boolean STRESS_TEST = false;
Timer runLater(java.time.Duration delay, Runnable action); Timer runLater(java.time.Duration delay, Runnable action);
Timer runPeriodically(Duration interval, Runnable runnable); Timer runPeriodically(Duration interval, Runnable runnable);

View file

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.function.Consumer; import java.util.function.Consumer;
// TODO use https://github.com/timmolter/XChange // TODO use https://github.com/timmolter/XChange
@ -45,9 +46,9 @@ public class PriceFeed {
} }
} }
private static final long PERIOD_FIAT_SEC = 90; private static final long PERIOD_FIAT_SEC = new Random().nextInt(5) + 90;
private static final long PERIOD_ALL_FIAT_SEC = 60 * 3; private static final long PERIOD_ALL_FIAT_SEC = new Random().nextInt(5) + 180;
private static final long PERIOD_ALL_CRYPTO_SEC = 60 * 3; private static final long PERIOD_ALL_CRYPTO_SEC = new Random().nextInt(5) + 180;
private final Map<String, MarketPrice> cache = new HashMap<>(); private final Map<String, MarketPrice> cache = new HashMap<>();
private final PriceProvider fiatPriceProvider = new BitcoinAveragePriceProvider(); private final PriceProvider fiatPriceProvider = new BitcoinAveragePriceProvider();

View file

@ -65,10 +65,10 @@ import static io.bitsquare.util.Validator.nonEmptyStringOf;
public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMessageListener { public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMessageListener {
private static final Logger log = LoggerFactory.getLogger(OpenOfferManager.class); private static final Logger log = LoggerFactory.getLogger(OpenOfferManager.class);
private static final long RETRY_REPUBLISH_DELAY_SEC = Timer.STRESS_TEST ? 1 : 10; private static final long RETRY_REPUBLISH_DELAY_SEC = 10;
private static final long REPUBLISH_AGAIN_AT_STARTUP_DELAY_SEC = Timer.STRESS_TEST ? 1 : 10; private static final long REPUBLISH_AGAIN_AT_STARTUP_DELAY_SEC = 10;
private static final long REPUBLISH_INTERVAL_MS = Timer.STRESS_TEST ? 3000 : TimeUnit.MINUTES.toMillis(15); private static final long REPUBLISH_INTERVAL_MS = TimeUnit.MINUTES.toMillis(15);
private static final long REFRESH_INTERVAL_MS = Timer.STRESS_TEST ? 1000 : TimeUnit.MINUTES.toMillis(4); private static final long REFRESH_INTERVAL_MS = TimeUnit.MINUTES.toMillis(4);
private final KeyRing keyRing; private final KeyRing keyRing;
private final User user; private final User user;

View file

@ -27,8 +27,7 @@ public class BroadcastHandler implements PeerManager.Listener {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private static final Logger log = LoggerFactory.getLogger(BroadcastHandler.class); private static final Logger log = LoggerFactory.getLogger(BroadcastHandler.class);
private static final long TIMEOUT_PER_PEER_SEC = Timer.STRESS_TEST ? 5 : 30; private static final long TIMEOUT_PER_PEER_SEC = 30;
private static final long DELAY_MS = Timer.STRESS_TEST ? 100 : 500;
interface ResultHandler { interface ResultHandler {
void onCompleted(BroadcastHandler broadcastHandler); void onCompleted(BroadcastHandler broadcastHandler);

View file

@ -24,9 +24,9 @@ public class PeerManager implements ConnectionListener {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private static final Logger log = LoggerFactory.getLogger(PeerManager.class); private static final Logger log = LoggerFactory.getLogger(PeerManager.class);
private static final long CHECK_MAX_CONN_DELAY_SEC = Timer.STRESS_TEST ? 1 : 5; private static final long CHECK_MAX_CONN_DELAY_SEC = 5;
// Use a long delay as the bootstrapping peer might need a while until it knows its onion address // Use a long delay as the bootstrapping peer might need a while until it knows its onion address
private static final long REMOVE_ANONYMOUS_PEER_SEC = Timer.STRESS_TEST ? 10 : 120; private static final long REMOVE_ANONYMOUS_PEER_SEC = 120;
private static final int MAX_REPORTED_PEERS = 1000; private static final int MAX_REPORTED_PEERS = 1000;
private static final int MAX_PERSISTED_PEERS = 500; private static final int MAX_PERSISTED_PEERS = 500;

View file

@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
public class GetDataRequestHandler { public class GetDataRequestHandler {
private static final Logger log = LoggerFactory.getLogger(GetDataRequestHandler.class); private static final Logger log = LoggerFactory.getLogger(GetDataRequestHandler.class);
private static final long TIME_OUT_SEC = Timer.STRESS_TEST ? 5 : 20; private static final long TIME_OUT_SEC = 20;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -30,7 +30,7 @@ import static com.google.common.base.Preconditions.checkArgument;
public class RequestDataHandler implements MessageListener { public class RequestDataHandler implements MessageListener {
private static final Logger log = LoggerFactory.getLogger(RequestDataHandler.class); private static final Logger log = LoggerFactory.getLogger(RequestDataHandler.class);
private static final long TIME_OUT_SEC = Timer.STRESS_TEST ? 5 : 20; private static final long TIME_OUT_SEC = 20;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkArgument;
public class RequestDataManager implements MessageListener, ConnectionListener, PeerManager.Listener { public class RequestDataManager implements MessageListener, ConnectionListener, PeerManager.Listener {
private static final Logger log = LoggerFactory.getLogger(RequestDataManager.class); private static final Logger log = LoggerFactory.getLogger(RequestDataManager.class);
private static final long RETRY_DELAY_SEC = Timer.STRESS_TEST ? 3 : 10; private static final long RETRY_DELAY_SEC = 10;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
class KeepAliveHandler implements MessageListener { class KeepAliveHandler implements MessageListener {
private static final Logger log = LoggerFactory.getLogger(KeepAliveHandler.class); private static final Logger log = LoggerFactory.getLogger(KeepAliveHandler.class);
private static int DELAY_MS = Timer.STRESS_TEST ? 1000 : 10_000; private static int DELAY_MS = 10_000;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -22,7 +22,7 @@ import java.util.Random;
public class KeepAliveManager implements MessageListener, ConnectionListener, PeerManager.Listener { public class KeepAliveManager implements MessageListener, ConnectionListener, PeerManager.Listener {
private static final Logger log = LoggerFactory.getLogger(KeepAliveManager.class); private static final Logger log = LoggerFactory.getLogger(KeepAliveManager.class);
private static final int INTERVAL_SEC = Timer.STRESS_TEST ? 2 : new Random().nextInt(5) + 20; private static final int INTERVAL_SEC = new Random().nextInt(5) + 20;
private static final long LAST_ACTIVITY_AGE_MS = INTERVAL_SEC / 2; private static final long LAST_ACTIVITY_AGE_MS = INTERVAL_SEC / 2;
private final NetworkNode networkNode; private final NetworkNode networkNode;

View file

@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkArgument;
class GetPeersRequestHandler { class GetPeersRequestHandler {
private static final Logger log = LoggerFactory.getLogger(GetPeersRequestHandler.class); private static final Logger log = LoggerFactory.getLogger(GetPeersRequestHandler.class);
private static final long TIME_OUT_SEC = Timer.STRESS_TEST ? 5 : 20; private static final long TIME_OUT_SEC = 20;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -26,8 +26,8 @@ import java.util.concurrent.TimeUnit;
class PeerExchangeHandler implements MessageListener { class PeerExchangeHandler implements MessageListener {
private static final Logger log = LoggerFactory.getLogger(PeerExchangeHandler.class); private static final Logger log = LoggerFactory.getLogger(PeerExchangeHandler.class);
private static final long TIME_OUT_SEC = Timer.STRESS_TEST ? 5 : 20; private static final long TIME_OUT_SEC = 20;
private static int DELAY_MS = Timer.STRESS_TEST ? 1000 : 1000; private static int DELAY_MS = 1000;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -21,9 +21,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class PeerExchangeManager implements MessageListener, ConnectionListener, PeerManager.Listener { public class PeerExchangeManager implements MessageListener, ConnectionListener, PeerManager.Listener {
private static final Logger log = LoggerFactory.getLogger(PeerExchangeManager.class); private static final Logger log = LoggerFactory.getLogger(PeerExchangeManager.class);
private static final long RETRY_DELAY_SEC = Timer.STRESS_TEST ? 2 : 10; private static final long RETRY_DELAY_SEC = 10;
private static final long RETRY_DELAY_AFTER_ALL_CON_LOST_SEC = Timer.STRESS_TEST ? 1 : 3; private static final long RETRY_DELAY_AFTER_ALL_CON_LOST_SEC = 3;
private static final long REQUEST_PERIODICALLY_INTERVAL_SEC = Timer.STRESS_TEST ? 5 : 10 * 60; private static final long REQUEST_PERIODICALLY_INTERVAL_SEC = 10 * 60;
private final NetworkNode networkNode; private final NetworkNode networkNode;
private final PeerManager peerManager; private final PeerManager peerManager;

View file

@ -47,7 +47,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
public static final int PURGE_AGE_DAYS = 10; public static final int PURGE_AGE_DAYS = 10;
@VisibleForTesting @VisibleForTesting
public static int CHECK_TTL_INTERVAL_SEC = Timer.STRESS_TEST ? 5 : 60; public static int CHECK_TTL_INTERVAL_SEC = 60;
private final Broadcaster broadcaster; private final Broadcaster broadcaster;
private final Map<ByteArray, ProtectedStorageEntry> map = new ConcurrentHashMap<>(); private final Map<ByteArray, ProtectedStorageEntry> map = new ConcurrentHashMap<>();