diff --git a/router/java/src/net/i2p/router/transport/udp/DummyThrottle.java b/router/java/src/net/i2p/router/transport/udp/DummyThrottle.java new file mode 100644 index 0000000000000000000000000000000000000000..383f807c5965eba299b1a2fa970ea2c919f428ca --- /dev/null +++ b/router/java/src/net/i2p/router/transport/udp/DummyThrottle.java @@ -0,0 +1,32 @@ +package net.i2p.router.transport.udp; + +import net.i2p.data.Hash; +import net.i2p.router.OutNetMessage; + +/** + * Since the TimedWeightedPriorityMessageQueue.add() + * was disabled by jrandom in UDPTransport.java + * on 2006-02-19, and the choke/unchoke was disabled at the same time, + * all of TWPMQ is pointless, so just do this for now. + * + * It appears from his comments that it was a lock contention issue, + * so perhaps TWPMQ can be converted to concurrent and re-enabled. + * + * @since 0.7.12 + */ +public class DummyThrottle implements OutboundMessageFragments.ActiveThrottle { + + public DummyThrottle() { + } + + public void choke(Hash peer) { + } + + public void unchoke(Hash peer) { + } + + public boolean isChoked(Hash peer) { + return false; + } +} + diff --git a/router/java/src/net/i2p/router/transport/udp/OutboundRefiller.java b/router/java/src/net/i2p/router/transport/udp/OutboundRefiller.java index 1f61b896c59cc4afd5df8dcbbe74cf9b6ea2edb4..b2136ac8d670273ee28c917b38bfd68675c8fdf5 100644 --- a/router/java/src/net/i2p/router/transport/udp/OutboundRefiller.java +++ b/router/java/src/net/i2p/router/transport/udp/OutboundRefiller.java @@ -9,6 +9,8 @@ import net.i2p.util.Log; * Blocking thread to grab new messages off the outbound queue and * plopping them into our active pool. * + * WARNING - UNUSED since 0.6.1.11 + * */ public class OutboundRefiller implements Runnable { private RouterContext _context; diff --git a/router/java/src/net/i2p/router/transport/udp/TimedWeightedPriorityMessageQueue.java b/router/java/src/net/i2p/router/transport/udp/TimedWeightedPriorityMessageQueue.java index 44a26d4a4d6068275ccd1a4fc781f124812019f6..acd0bd0b532dde527703d37d13e99e25ca5d0844 100644 --- a/router/java/src/net/i2p/router/transport/udp/TimedWeightedPriorityMessageQueue.java +++ b/router/java/src/net/i2p/router/transport/udp/TimedWeightedPriorityMessageQueue.java @@ -16,6 +16,9 @@ import net.i2p.util.Log; * Weighted priority queue implementation for the outbound messages, coupled * with code to fail messages that expire. * + * WARNING - UNUSED since 0.6.1.11 + * See comments in DQAT.java and mtn history ca. 2006-02-19 + * */ public class TimedWeightedPriorityMessageQueue implements MessageQueue, OutboundMessageFragments.ActiveThrottle { private RouterContext _context; diff --git a/router/java/src/net/i2p/router/transport/udp/UDPFlooder.java b/router/java/src/net/i2p/router/transport/udp/UDPFlooder.java index ef091ff53d6965b7c4f75cbe266b61b418cdad3f..38bf62246e902d8f53d85cf9b1a0358c3352479f 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPFlooder.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPFlooder.java @@ -12,7 +12,8 @@ import net.i2p.util.I2PThread; // import net.i2p.util.Log; /** - * + * This sends random data to all UDP peers at a specified rate. + * It is for testing only! */ class UDPFlooder implements Runnable { private RouterContext _context; diff --git a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java index a7733edeef4041456b95fc190da9db3327ee4d1f..81b2e209b9fad7c2af1b2567a7c5e116f4a9f0cd 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java @@ -135,12 +135,14 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority /** how many relays offered to us will we use at a time? */ public static final int PUBLIC_RELAY_COUNT = 3; + private static final boolean USE_PRIORITY = false; + /** configure the priority queue with the given split points */ private static final int PRIORITY_LIMITS[] = new int[] { 100, 200, 300, 400, 500, 1000 }; /** configure the priority queue with the given weighting per priority group */ private static final int PRIORITY_WEIGHT[] = new int[] { 1, 1, 1, 1, 1, 2 }; - /** should we flood all UDP peers with the configured rate? */ + /** should we flood all UDP peers with the configured rate? This is for testing only! */ private static final boolean SHOULD_FLOOD_PEERS = false; private static final int MAX_CONSECUTIVE_FAILED = 5; @@ -170,9 +172,16 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority _dropList = new ArrayList(256); _endpoint = null; - TimedWeightedPriorityMessageQueue mq = new TimedWeightedPriorityMessageQueue(ctx, PRIORITY_LIMITS, PRIORITY_WEIGHT, this); - _outboundMessages = mq; - _activeThrottle = mq; + // See comments in DQAT.java + if (USE_PRIORITY) { + TimedWeightedPriorityMessageQueue mq = new TimedWeightedPriorityMessageQueue(ctx, PRIORITY_LIMITS, PRIORITY_WEIGHT, this); + _outboundMessages = mq; + _activeThrottle = mq; + } else { + DummyThrottle mq = new DummyThrottle(); + _outboundMessages = null; + _activeThrottle = mq; + } _cachedBid = new SharedBid[BID_VALUES.length]; for (int i = 0; i < BID_VALUES.length; i++) { @@ -181,7 +190,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority _fragments = new OutboundMessageFragments(_context, this, _activeThrottle); _inboundFragments = new InboundMessageFragments(_context, _fragments, this); - _flooder = new UDPFlooder(_context, this); + if (SHOULD_FLOOD_PEERS) + _flooder = new UDPFlooder(_context, this); _expireTimeout = EXPIRE_TIMEOUT; _expireEvent = new ExpirePeerEvent(); _testEvent = new PeerTestEvent(); @@ -276,10 +286,11 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority if (_handler == null) _handler = new PacketHandler(_context, this, _endpoint, _establisher, _inboundFragments, _testManager, _introManager); - if (_refiller == null) + // See comments in DQAT.java + if (USE_PRIORITY && _refiller == null) _refiller = new OutboundRefiller(_context, _fragments, _outboundMessages); - if (_flooder == null) + if (SHOULD_FLOOD_PEERS && _flooder == null) _flooder = new UDPFlooder(_context, this); // Startup the endpoint with the requested port, check the actual port, and @@ -306,8 +317,10 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority _inboundFragments.startup(); _pusher = new PacketPusher(_context, _fragments, _endpoint.getSender()); _pusher.startup(); - _refiller.startup(); - _flooder.startup(); + if (USE_PRIORITY) + _refiller.startup(); + if (SHOULD_FLOOD_PEERS) + _flooder.startup(); _expireEvent.setIsAlive(true); _testEvent.setIsAlive(true); // this queues it for 3-6 minutes in the future... SimpleTimer.getInstance().addEvent(_testEvent, 10*1000); // lets requeue it for Real Soon @@ -1150,10 +1163,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority msg.timestamp("enqueueing for an already established peer"); if (_log.shouldLog(Log.DEBUG)) _log.debug("Add to fragments for " + to.toBase64()); - if (true) // skip the priority queue and go straight to the active pool - _fragments.add(msg); - else + + // See comments in DQAT.java + if (USE_PRIORITY) _outboundMessages.add(msg); + else // skip the priority queue and go straight to the active pool + _fragments.add(msg); } else { if (_log.shouldLog(Log.DEBUG)) _log.debug("Establish new connection to " + to.toBase64());