Changeset 9030b64
- Timestamp:
- Mar 2, 2011 6:24:18 PM (10 years ago)
- Branches:
- master
- Children:
- b2d4a79
- Parents:
- cacd0f8 (diff), cb70778 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 7 deleted
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java
rcacd0f8 r9030b64 135 135 136 136 /** 137 * @param KBps137 * @param limit KBps 138 138 */ 139 139 public void setMaxUpBW(int limit) { -
apps/i2psnark/java/src/org/klomp/snark/MagnetState.java
rcacd0f8 r9030b64 58 58 59 59 /** 60 * @param call this for a new magnet when you have the size60 * Call this for a new magnet when you have the size 61 61 * @throws IllegalArgumentException 62 62 */ … … 78 78 79 79 /** 80 * @paramCall this for a new magnet when the download is complete.80 * Call this for a new magnet when the download is complete. 81 81 * @throws IllegalArgumentException 82 82 */ -
apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
rcacd0f8 r9030b64 645 645 * @param ih 20 byte info hash 646 646 * @param trackerURL may be null 647 * @param u dpateStatus should we add this magnet to the config file,647 * @param updateStatus should we add this magnet to the config file, 648 648 * to save it across restarts, in case we don't get 649 649 * the metadata before shutdown? -
apps/i2psnark/java/src/org/klomp/snark/dht/DHT.java
rcacd0f8 r9030b64 55 55 * 56 56 * @param ih the Info Hash (torrent) 57 * @param peer the peer's Hash57 * @param peerHash the peer's Hash 58 58 */ 59 59 public void announce(byte[] ih, byte[] peerHash); -
apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
rcacd0f8 r9030b64 354 354 ua.startsWith("ELinks") || ua.startsWith("Dillo")); 355 355 356 boolean noThinsp = isDegraded || ua.startsWith("Opera");356 boolean noThinsp = isDegraded || (ua != null && ua.startsWith("Opera")); 357 357 if (_manager.util().connected()) { 358 358 if (isDegraded) … … 1884 1884 if (mime.equals("text/html")) 1885 1885 icon = "html"; 1886 else if (mime.equals("text/plain") || plc.endsWith(".nfo")) 1886 else if (mime.equals("text/plain") || plc.endsWith(".nfo") || 1887 mime.equals("application/rtf")) 1887 1888 icon = "page"; 1888 1889 else if (mime.equals("application/java-archive") || plc.endsWith(".war") || -
apps/routerconsole/java/build.xml
rcacd0f8 r9030b64 64 64 </target> 65 65 66 <target name="jar" depends="compile, jarUpToDate" unless="jar.uptodate" > 66 <!-- the jar with the latest message classes from the jsps, and the war too --> 67 <target name="jar" depends="jar1, war, bundle" /> 68 69 <!-- the jar without the latest message classes from the jsps --> 70 <target name="jar1" depends="compile, jarUpToDate" unless="jar.uptodate" > 67 71 <exec executable="mtn" outputproperty="workspace.changes.j" errorproperty="mtn.error2" failifexecutionfails="false" > 68 72 <arg value="list" /> 69 73 <arg value="changed" /> 70 74 <arg value="." /> 75 <arg value="../locale" /> 71 76 </exec> 72 77 <!-- \n in an attribute value generates an invalid manifest --> … … 86 91 </manifest> 87 92 </jar> 93 <!-- jrobin taken out of routerconsole.jar in 0.7.12 88 94 <delete dir="./tmpextract" /> 89 <!-- jrobin taken out of routerconsole.jar in 0.7.1290 95 <unjar src="../../jrobin/jrobin-1.4.0.jar" dest="./tmpextract" /> 91 96 <jar destfile="./build/routerconsole.jar" basedir="./tmpextract" update="true" /> 92 97 <delete dir="./tmpextract" /> 93 98 --> 94 95 <ant target="war" /> 96 99 </target> 100 101 <!-- this is tricky because the message classes go in the jar, not in the war --> 102 <target name="bundle" depends="jar1, precompilejsp" > 97 103 <!-- Update the messages_*.po files. 98 104 We need to supply the bat file for windows, and then change the fail property to true --> … … 118 124 </target> 119 125 120 <target name="poupdate" depends="build"> 121 <ant target="war" /> 126 <target name="poupdate" depends="precompilejsp"> 122 127 <!-- Update the messages_*.po files. 123 128 We need to supply the bat file for windows, and then change the fail property to true --> … … 136 141 </target> 137 142 143 <!-- does NOT update the message classes, as those go in the jar --> 138 144 <target name="war" depends="precompilejsp, warUpToDate" unless="war.uptodate" > 139 145 <exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" > … … 165 171 </target> 166 172 167 <target name="precompilejsp" unless="precompilejsp.uptodate">173 <target name="precompilejsp" depends="jar1" unless="precompilejsp.uptodate"> 168 174 <delete dir="../jsp/WEB-INF/" /> 169 175 <delete file="../jsp/web-fragment.xml" /> … … 266 272 267 273 <uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml"> 268 <srcfiles dir= "../jsp" includes="**/*.jsp, * */*.html, *.css, susimail/susimail, web.xml"/>274 <srcfiles dir= "../jsp" includes="**/*.jsp, *.jsi, **/*.html, *.css, susimail/susimail, web.xml"/> 269 275 </uptodate> 270 276 -
core/java/src/net/i2p/CoreVersion.java
rcacd0f8 r9030b64 17 17 /** deprecated */ 18 18 public final static String ID = "Monotone"; 19 public final static String VERSION = "0.8. 3";19 public final static String VERSION = "0.8.4"; 20 20 21 21 public static void main(String args[]) { -
core/java/src/net/i2p/stat/StatManager.java
rcacd0f8 r9030b64 55 55 "prng.bufferFillTime,prng.bufferWaitTime,router.memoryUsed," + 56 56 "transport.receiveMessageSize,transport.sendMessageSize,transport.sendProcessingTime," + 57 "tunnel.acceptLoad,tunnel.buildRequestTime,tunnel.rejectOverloaded,tunnel.rejectTimeout " +57 "tunnel.acceptLoad,tunnel.buildRequestTime,tunnel.rejectOverloaded,tunnel.rejectTimeout," + 58 58 "tunnel.buildClientExpire,tunnel.buildClientReject,tunnel.buildClientSuccess," + 59 59 "tunnel.buildExploratoryExpire,tunnel.buildExploratoryReject,tunnel.buildExploratorySuccess," + -
history.txt
rcacd0f8 r9030b64 1 2011-03-02 zzz 2 * BuildHandler: 3 - Limit request queue size 4 - Concurrent request queue 5 - Remove dead code for queued rely handling 6 * OutNetMessage: Remove dead code 7 * Tunnel cleanups, final, javadoc 8 9 * 2011-03-02 0.8.4 released 10 1 11 2011-02-27 zzz 2 12 * Console: -
installer/install.xml
rcacd0f8 r9030b64 5 5 <info> 6 6 <appname>i2p</appname> 7 <appversion>0.8. 3</appversion>7 <appversion>0.8.4</appversion> 8 8 <authors> 9 9 <author name="I2P" email="http://forum.i2p2.de/"/> -
installer/resources/news.xml
rcacd0f8 r9030b64 1 1 <!-- 2 <i2p.news date="$Date: 2011-0 1-2400:00:00 $">3 <i2p.release version="0.8. 3" date="2011/01/24" minVersion="0.6" />2 <i2p.news date="$Date: 2011-03-02 00:00:00 $"> 3 <i2p.release version="0.8.4" date="2011/03/02" minVersion="0.6" /> 4 4 --> 5 5 <div lang="en"> 6 <h3>2011-0 1-24: <b>0.8.3 <a href="http://www.i2p2.i2p/release-0.8.3.html">Released</a></b></h3>6 <h3>2011-03-02: <b>0.8.4 <a href="http://www.i2p2.i2p/release-0.8.4.html">Released</a></b></h3> 7 7 <p> 8 The 0.8.3 release contains several performance improvements, including reduction of threads and 9 memory usage, and faster I2CP (client-router) communication. 10 </p><p> 11 There is also new SSL router console support 12 (<a href="http://zzz.i2p/topics/800">instructions here</a>), 13 a new <a href="/configreseed">reseed configuration page</a> including HTTP proxy support for those behind restrictive firewalls, 14 a new <a href="/configclients#i2cp">I2CP configuration section</a> including I2CP-over-SSL support for remote clients, 15 a new <a href="/i2ptunnel/edit?tunnel=3">server connection limits and blacklist configuration section</a> for enhanced DoS protection, 16 and a new 17 <a href="/i2ptunnel/edit?tunnel=0">HTTP proxy jump server configuration section</a> so you may easily add alternative jump servers. 18 Statistics are now limited by default to reduce memory usage; the full set of statistics may be re-enabled on the 19 <a href="/configstats">stats configuration page</a>. 20 There are also bug fixes, of course, so 21 as usual, upgrading is recommended. 8 The 0.8.4 release contains some performance improvements and important bug fixes. 9 Also, i2psnark now supports magnet links. 10 As usual, upgrading is recommended. 22 11 </p><p> 23 12 Please help grow the network. … … 28 17 If you find a bug, please enter a report on <a href="http://trac.i2p2.i2p/report/1">trac</a>. 29 18 We are still looking for volunteers to work on new and existing translations. 30 Please volunteer on <a href="irc://127.0.0.1:6668/i2p">IRC #i2p </a>.19 Please volunteer on <a href="irc://127.0.0.1:6668/i2p">IRC #i2p-dev</a>. 31 20 </p> 32 21 </div> -
router/java/src/net/i2p/router/InNetMessagePool.java
rcacd0f8 r9030b64 82 82 } 83 83 _log = _context.logManager().getLog(InNetMessagePool.class); 84 _alive = false;85 84 _context.statManager().createRateStat("inNetPool.dropped", "How often do we drop a message", "InNetPool", new long[] { 60*60*1000l }); 86 85 _context.statManager().createRateStat("inNetPool.droppedDeliveryStatusDelay", "How long after a delivery status message is created do we receive it back again (for messages that are too slow to be handled)", "InNetPool", new long[] { 60*60*1000l }); … … 90 89 } 91 90 91 /** 92 * @return previous builder for this message type, or null 93 * @throws AIOOBE if i2npMessageType is greater than MAX_I2NP_MESSAGE_TYPE 94 */ 92 95 public HandlerJobBuilder registerHandlerJobBuilder(int i2npMessageType, HandlerJobBuilder builder) { 93 96 HandlerJobBuilder old = _handlerJobBuilders[i2npMessageType]; … … 96 99 } 97 100 101 /** 102 * @return previous builder for this message type, or null 103 * @throws AIOOBE if i2npMessageType is greater than MAX_I2NP_MESSAGE_TYPE 104 */ 98 105 public HandlerJobBuilder unregisterHandlerJobBuilder(int i2npMessageType) { 99 106 HandlerJobBuilder old = _handlerJobBuilders[i2npMessageType]; … … 103 110 104 111 /** 105 * Add a new message to the pool , returning the number of messages in the106 * pool so that the comm system can throttle inbound messages.If there is112 * Add a new message to the pool. 113 * If there is 107 114 * a HandlerJobBuilder for the inbound message type, the message is loaded 108 115 * into a job created by that builder and queued up for processing instead 109 116 * (though if the builder doesn't create a job, it is added to the pool) 110 117 * 118 * @return -1 for some types of errors but not all; 0 otherwise 119 * (was queue length, long ago) 111 120 */ 112 121 public int add(I2NPMessage messageBody, RouterIdentity fromRouter, Hash fromRouterHash) { -
router/java/src/net/i2p/router/OutNetMessage.java
rcacd0f8 r9030b64 30 30 */ 31 31 public class OutNetMessage { 32 private Log _log;33 private RouterContext _context;32 private final Log _log; 33 private final RouterContext _context; 34 34 private RouterInfo _target; 35 35 private I2NPMessage _message; … … 51 51 private long _transmitBegin; 52 52 private Exception _createdBy; 53 private long _created;53 private final long _created; 54 54 /** for debugging, contains a mapping of even name to Long (e.g. "begin sending", "handleOutbound", etc) */ 55 55 private HashMap<String, Long> _timestamps; -
router/java/src/net/i2p/router/OutNetMessagePool.java
rcacd0f8 r9030b64 19 19 * retrieves messages for delivery. 20 20 * 21 * Actually, this doesn't 'pool' anything, it calls the comm system directly. 22 * Nor does it organize by priority. But perhaps it could someday. 21 23 */ 22 24 public class OutNetMessagePool { 23 private Log _log;24 private RouterContext _context;25 private final Log _log; 26 private final RouterContext _context; 25 27 26 28 public OutNetMessagePool(RouterContext context) { 27 29 _context = context; 28 30 _log = _context.logManager().getLog(OutNetMessagePool.class); 29 }30 31 /**32 * Remove the highest priority message, or null if none are available.33 *34 */35 public OutNetMessage getNext() {36 return null;37 31 } 38 32 … … 48 42 } 49 43 50 if (_log.shouldLog(Log. INFO))51 _log. info("Adding outbound message to "44 if (_log.shouldLog(Log.DEBUG)) 45 _log.debug("Adding outbound message to " 52 46 + msg.getTarget().getIdentity().getHash().toBase64().substring(0,6) 53 47 + " with id " + msg.getMessage().getUniqueId() … … 71 65 } 72 66 if (msg.getTarget() == null) { 73 _log.error("No target in the OutNetMessage: " + msg, new Exception( "Definitely a fuckup"));67 _log.error("No target in the OutNetMessage: " + msg, new Exception()); 74 68 return false; 75 69 } … … 84 78 return true; 85 79 } 86 87 /**88 * Clear any messages that have expired, enqueuing any appropriate jobs89 *90 */91 public void clearExpired() {92 // noop93 }94 95 /**96 * Retrieve the number of messages, regardless of priority.97 *98 */99 public int getCount() { return 0; }100 101 /**102 * Retrieve the number of messages at the given priority. This can be used for103 * subsystems that maintain a pool of messages to be sent whenever there is spare time,104 * where all of these 'spare' messages are of the same priority.105 *106 */107 public int getCount(int priority) { return 0; }108 109 public void dumpPoolInfo() { return; }110 111 private static class ReverseIntegerComparator implements Comparator {112 public int compare(Object lhs, Object rhs) {113 if ( (lhs == null) || (rhs == null) ) return 0; // invalid, but never used114 if ( !(lhs instanceof Integer) || !(rhs instanceof Integer)) return 0;115 Integer lv = (Integer)lhs;116 Integer rv = (Integer)rhs;117 return - (lv.compareTo(rv));118 }119 }120 80 } -
router/java/src/net/i2p/router/RouterVersion.java
rcacd0f8 r9030b64 19 19 public final static String ID = "Monotone"; 20 20 public final static String VERSION = CoreVersion.VERSION; 21 public final static long BUILD = 21;21 public final static long BUILD = 1; 22 22 23 23 /** for example "-test" */ 24 public final static String EXTRA = " -rc";24 public final static String EXTRA = ""; 25 25 public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; 26 26 public static void main(String args[]) { -
router/java/src/net/i2p/router/transport/TransportManager.java
rcacd0f8 r9030b64 460 460 _log.debug("I2NPMessage received: " + message.getClass().getName(), new Exception("Where did I come from again?")); 461 461 try { 462 int num =_context.inNetMessagePool().add(message, fromRouter, fromRouterHash);462 _context.inNetMessagePool().add(message, fromRouter, fromRouterHash); 463 463 if (_log.shouldLog(Log.DEBUG)) 464 _log.debug("Added to in pool : "+ num);464 _log.debug("Added to in pool"); 465 465 } catch (IllegalArgumentException iae) { 466 466 if (_log.shouldLog(Log.WARN)) -
router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java
rcacd0f8 r9030b64 710 710 } 711 711 712 private static int getShareBandwidth(RouterContext ctx) { 712 /** @return in KBps */ 713 public static int getShareBandwidth(RouterContext ctx) { 713 714 int irateKBps = ctx.bandwidthLimiter().getInboundKBytesPerSecond(); 714 715 int orateKBps = ctx.bandwidthLimiter().getOutboundKBytesPerSecond(); -
router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java
rcacd0f8 r9030b64 28 28 class BuildExecutor implements Runnable { 29 29 private final ArrayList<Long> _recentBuildIds = new ArrayList(100); 30 private RouterContext _context;31 private Log _log;32 private TunnelPoolManager _manager;30 private final RouterContext _context; 31 private final Log _log; 32 private final TunnelPoolManager _manager; 33 33 /** list of TunnelCreatorConfig elements of tunnels currently being built */ 34 34 private final Object _currentlyBuilding; … … 38 38 private final ConcurrentHashMap<Long, PooledTunnelCreatorConfig> _recentlyBuildingMap; 39 39 private boolean _isRunning; 40 private BuildHandler _handler;40 private final BuildHandler _handler; 41 41 private boolean _repoll; 42 42 private static final int MAX_CONCURRENT_BUILDS = 10; … … 249 249 250 250 //long loopBegin = 0; 251 //long beforeHandleInboundReplies = 0;252 //long afterHandleInboundReplies = 0;253 251 //long afterBuildZeroHop = 0; 254 252 long afterBuildReal = 0; … … 269 267 } 270 268 271 //beforeHandleInboundReplies = System.currentTimeMillis();272 _handler.handleInboundReplies();273 //afterHandleInboundReplies = System.currentTimeMillis();274 275 269 // allowed() also expires timed out requests (for new style requests) 276 270 int allowed = allowed(); … … 328 322 buildTunnel(pool, cfg); 329 323 realBuilt++; 330 331 // we want replies to go to the top of the queue332 _handler.handleInboundReplies();333 324 } else { 334 325 i--; … … 392 383 * 393 384 */ 394 private static class TunnelPoolComparator implements Comparator { 395 public int compare(Object l, Object r) { 396 TunnelPool tpl = (TunnelPool) l; 397 TunnelPool tpr = (TunnelPool) r; 385 private static class TunnelPoolComparator implements Comparator<TunnelPool> { 386 public int compare(TunnelPool tpl, TunnelPool tpr) { 398 387 if (tpl.getSettings().isExploratory() && !tpr.getSettings().isExploratory()) 399 388 return -1; -
router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java
rcacd0f8 r9030b64 1 1 package net.i2p.router.tunnel.pool; 2 2 3 import java.util.ArrayList;4 3 import java.util.List; 4 import java.util.concurrent.LinkedBlockingQueue; 5 5 6 6 import net.i2p.data.Base64; … … 28 28 import net.i2p.router.tunnel.BuildReplyHandler; 29 29 import net.i2p.router.tunnel.HopConfig; 30 import net.i2p.router.tunnel.TunnelDispatcher; 30 31 import net.i2p.stat.Rate; 31 32 import net.i2p.stat.RateStat; … … 33 34 34 35 /** 36 * Handle the received tunnel build message requests and replies, 37 * including sending responsses to requests, updating the 38 * lists of our tunnels and participating tunnels, 39 * and updating stats. 40 * 41 * Replies are handled immediately on reception; requests are queued. 35 42 * 36 43 * Note that 10 minute tunnel expiration is hardcoded in here. 37 *38 44 */ 39 45 class BuildHandler { … … 43 49 private final Job _buildMessageHandlerJob; 44 50 private final Job _buildReplyMessageHandlerJob; 45 /** list of BuildMessageState, oldest first */ 46 private final List<BuildMessageState> _inboundBuildMessages; 47 /** list of BuildReplyMessageState, oldest first - unused unless HANDLE_REPLIES_INLINE == false */ 48 private final List<BuildReplyMessageState> _inboundBuildReplyMessages; 49 /** list of BuildEndMessageState, oldest first - unused unless HANDLE_REPLIES_INLINE == false */ 50 private final List<BuildEndMessageState> _inboundBuildEndMessages; 51 private final LinkedBlockingQueue<BuildMessageState> _inboundBuildMessages; 51 52 private final BuildMessageProcessor _processor; 52 53 private final ParticipatingThrottler _throttler; 53 54 54 private static final boolean HANDLE_REPLIES_INLINE = true; 55 55 /** TODO these may be too high, review and adjust */ 56 private static final int MIN_QUEUE = 12; 57 private static final int MAX_QUEUE = 96; 58 56 59 public BuildHandler(RouterContext ctx, BuildExecutor exec) { 57 60 _context = ctx; 58 61 _log = ctx.logManager().getLog(getClass()); 59 62 _exec = exec; 60 _inboundBuildMessages = new ArrayList(16); 61 if (HANDLE_REPLIES_INLINE) { 62 _inboundBuildEndMessages = null; 63 _inboundBuildReplyMessages = null; 64 } else { 65 _inboundBuildEndMessages = new ArrayList(16); 66 _inboundBuildReplyMessages = new ArrayList(16); 67 } 63 // Queue size = 12 * share BW / 48K 64 int sz = Math.min(MAX_QUEUE, Math.max(MIN_QUEUE, TunnelDispatcher.getShareBandwidth(ctx) * MIN_QUEUE / 48)); 65 _inboundBuildMessages = new LinkedBlockingQueue(sz); 68 66 69 67 _context.statManager().createRateStat("tunnel.reject.10", "How often we reject a tunnel probabalistically", "Tunnels", new long[] { 60*1000, 10*60*1000 }); … … 95 93 96 94 _processor = new BuildMessageProcessor(ctx); 95 _throttler = new ParticipatingThrottler(ctx); 97 96 _buildMessageHandlerJob = new TunnelBuildMessageHandlerJob(ctx); 98 97 _buildReplyMessageHandlerJob = new TunnelBuildReplyMessageHandlerJob(ctx); … … 103 102 ctx.inNetMessagePool().registerHandlerJobBuilder(VariableTunnelBuildMessage.MESSAGE_TYPE, tbmhjb); 104 103 ctx.inNetMessagePool().registerHandlerJobBuilder(VariableTunnelBuildReplyMessage.MESSAGE_TYPE, tbrmhjb); 105 _throttler = new ParticipatingThrottler(ctx);106 104 } 107 105 … … 111 109 /** 112 110 * Blocking call to handle a few of the pending inbound requests, returning how many 113 * requests remain after this pass 111 * requests remain after this pass. This is called by BuildExecutor. 114 112 */ 115 113 int handleInboundRequests() { 116 int dropExpired = 0; 117 int remaining = 0; 118 List handled = null; 119 long beforeFindHandled = System.currentTimeMillis(); 120 synchronized (_inboundBuildMessages) { 121 int toHandle = _inboundBuildMessages.size(); 122 if (toHandle > 0) { 123 if (toHandle > MAX_HANDLE_AT_ONCE) 124 toHandle = MAX_HANDLE_AT_ONCE; 125 handled = new ArrayList(toHandle); 126 //if (false) { 127 // for (int i = 0; i < toHandle; i++) // LIFO for lower response time (should we RED it for DoS?) 128 // handled.add(_inboundBuildMessages.remove(_inboundBuildMessages.size()-1)); 129 //} else { 130 // drop any expired messages 131 long dropBefore = System.currentTimeMillis() - (BuildRequestor.REQUEST_TIMEOUT/4); 132 do { 133 BuildMessageState state = (BuildMessageState)_inboundBuildMessages.get(0); 134 if (state.recvTime <= dropBefore) { 135 _inboundBuildMessages.remove(0); 136 dropExpired++; 137 if (_log.shouldLog(Log.WARN)) 138 _log.warn("Not even trying to handle/decrypt the request " + state.msg.getUniqueId() 139 + ", since we received it a long time ago: " + (System.currentTimeMillis() - state.recvTime)); 140 _context.statManager().addRateData("tunnel.dropLoadDelay", System.currentTimeMillis() - state.recvTime, 0); 141 } else { 142 break; 143 } 144 } while (!_inboundBuildMessages.isEmpty()); 145 146 if (dropExpired > 0) 147 _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Too slow")); 148 149 // now pull off the oldest requests first (we're doing a tail-drop 150 // when adding) 151 for (int i = 0; i < toHandle && !_inboundBuildMessages.isEmpty(); i++) 152 handled.add(_inboundBuildMessages.remove(0)); 153 //} 154 } 155 remaining = _inboundBuildMessages.size(); 156 } 157 if (handled != null) { 114 for (int i = 0; i < MAX_HANDLE_AT_ONCE; ) { 115 BuildMessageState state = _inboundBuildMessages.poll(); 116 if (state == null) 117 return 0; 118 long dropBefore = System.currentTimeMillis() - (BuildRequestor.REQUEST_TIMEOUT/4); 119 if (state.recvTime <= dropBefore) { 120 if (_log.shouldLog(Log.WARN)) 121 _log.warn("Not even trying to handle/decrypt the request " + state.msg.getUniqueId() 122 + ", since we received it a long time ago: " + (System.currentTimeMillis() - state.recvTime)); 123 _context.statManager().addRateData("tunnel.dropLoadDelay", System.currentTimeMillis() - state.recvTime, 0); 124 _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Too slow")); 125 continue; 126 } 127 128 i++; 129 long beforeHandle = System.currentTimeMillis(); 130 long actualTime = handleRequest(state); 158 131 if (_log.shouldLog(Log.DEBUG)) 159 _log.debug("Handling " + handled.size() + " requests (took " + (System.currentTimeMillis()-beforeFindHandled) + "ms to find them)"); 160 161 for (int i = 0; i < handled.size(); i++) { 162 BuildMessageState state = (BuildMessageState)handled.get(i); 163 long beforeHandle = System.currentTimeMillis(); 164 long actualTime = handleRequest(state); 165 if (_log.shouldLog(Log.DEBUG)) 166 _log.debug("Handle took " + (System.currentTimeMillis()-beforeHandle) + "/" + actualTime + " (" + i + " out of " + handled.size() + " with " + remaining + " remaining)"); 167 } 168 handled.clear(); 169 } 170 if (!HANDLE_REPLIES_INLINE) { 171 synchronized (_inboundBuildEndMessages) { 172 int toHandle = _inboundBuildEndMessages.size(); 173 if (toHandle > 0) { 174 if (handled == null) 175 handled = new ArrayList(_inboundBuildEndMessages); 176 else 177 handled.addAll(_inboundBuildEndMessages); 178 _inboundBuildEndMessages.clear(); 179 } 180 } 181 } 182 if (handled != null) { 183 if (_log.shouldLog(Log.DEBUG)) 184 _log.debug("Handling " + handled.size() + " requests that are actually replies"); 185 // these are inbound build messages that actually contain the full replies, since 186 // they are for inbound tunnels we have created 187 for (int i = 0; i < handled.size(); i++) { 188 BuildEndMessageState state = (BuildEndMessageState)handled.get(i); 189 handleRequestAsInboundEndpoint(state); 190 } 191 } 192 193 // anything else? 194 /* 195 synchronized (_inboundBuildMessages) { 196 int remaining = _inboundBuildMessages.size(); 197 return remaining; 198 } 199 */ 132 _log.debug("Handle took " + (System.currentTimeMillis()-beforeHandle) + "/" + actualTime + 133 " (" + i + " with " + _inboundBuildMessages.size() + " remaining)"); 134 } 135 136 int remaining = _inboundBuildMessages.size(); 200 137 if (remaining > 0) 201 138 _context.statManager().addRateData("tunnel.handleRemaining", remaining, 0); 202 139 return remaining; 203 }204 205 /** Warning - noop if HANDLE_REPLIES_INLINE == true */206 void handleInboundReplies() {207 if (HANDLE_REPLIES_INLINE)208 return;209 List handled = null;210 synchronized (_inboundBuildReplyMessages) {211 int toHandle = _inboundBuildReplyMessages.size();212 if (toHandle > 0) {213 // always handle all of them - they're replies that we were waiting for!214 handled = new ArrayList(_inboundBuildReplyMessages);215 _inboundBuildReplyMessages.clear();216 }217 }218 if (handled != null) {219 if (_log.shouldLog(Log.DEBUG))220 _log.debug("Handling " + handled.size() + " replies");221 222 for (int i = 0; i < handled.size(); i++) {223 BuildReplyMessageState state = (BuildReplyMessageState)handled.get(i);224 handleReply(state);225 }226 }227 140 } 228 141 … … 344 257 } 345 258 346 /** @return handle time or -1 */259 /** @return handle time or -1 if it wasn't completely handled */ 347 260 private long handleRequest(BuildMessageState state) { 348 261 long timeSinceReceived = System.currentTimeMillis()-state.recvTime; … … 366 279 long decryptTime = System.currentTimeMillis() - beforeDecrypt; 367 280 _context.statManager().addRateData("tunnel.decryptRequestTime", decryptTime, decryptTime); 368 if (decryptTime > 500 )281 if (decryptTime > 500 && _log.shouldLog(Log.WARN)) 369 282 _log.warn("Took too long to decrypt the request: " + decryptTime + " for message " + state.msg.getUniqueId() + " received " + (timeSinceReceived+decryptTime) + " ago"); 370 283 if (req == null) { … … 380 293 RouterInfo nextPeerInfo = _context.netDb().lookupRouterInfoLocally(nextPeer); 381 294 long lookupTime = System.currentTimeMillis()-beforeLookup; 382 if (lookupTime > 500 )295 if (lookupTime > 500 && _log.shouldLog(Log.WARN)) 383 296 _log.warn("Took too long to lookup the request: " + lookupTime + "/" + readPeerTime + " for message " + state.msg.getUniqueId() + " received " + (timeSinceReceived+decryptTime) + " ago"); 384 297 if (nextPeerInfo == null) { … … 417 330 418 331 private class HandleReq extends JobImpl { 419 private BuildMessageState _state;420 private BuildRequestRecord _req;421 private Hash _nextPeer;332 private final BuildMessageState _state; 333 private final BuildRequestRecord _req; 334 private final Hash _nextPeer; 422 335 HandleReq(RouterContext ctx, BuildMessageState state, BuildRequestRecord req, Hash nextPeer) { 423 336 super(ctx); … … 440 353 441 354 private static class TimeoutReq extends JobImpl { 442 private BuildMessageState _state;443 private BuildRequestRecord _req;444 private Hash _nextPeer;355 private final BuildMessageState _state; 356 private final BuildRequestRecord _req; 357 private final Hash _nextPeer; 445 358 TimeoutReq(RouterContext ctx, BuildMessageState state, BuildRequestRecord req, Hash nextPeer) { 446 359 super(ctx); … … 581 494 if (from == null) 582 495 from = state.from.calculateHash(); 583 if ( _throttler.shouldThrottle(from)) {496 if (from != null && _throttler.shouldThrottle(from)) { 584 497 if (_log.shouldLog(Log.WARN)) 585 498 _log.warn("Rejecting tunnel (hop throttle), previous hop: " + from); … … 732 645 733 646 public int getInboundBuildQueueSize() { 734 synchronized (_inboundBuildMessages) {735 647 return _inboundBuildMessages.size(); 736 }737 648 } 738 649 … … 757 668 } 758 669 BuildEndMessageState state = new BuildEndMessageState(cfg, receivedMessage); 759 if (HANDLE_REPLIES_INLINE) { 760 handleRequestAsInboundEndpoint(state); 761 } else { 762 synchronized (_inboundBuildEndMessages) { 763 _inboundBuildEndMessages.add(state); 764 } 765 _exec.repoll(); 766 } 670 handleRequestAsInboundEndpoint(state); 767 671 } else { 768 672 if (_exec.wasRecentlyBuilding(reqId)) { … … 772 676 _context.statManager().addRateData("tunnel.buildReplyTooSlow", 1, 0); 773 677 } else { 774 synchronized (_inboundBuildMessages) { 775 boolean removed = false; 776 int dropped = 0; 777 for (int i = 0; i < _inboundBuildMessages.size(); i++) { 778 BuildMessageState cur = (BuildMessageState)_inboundBuildMessages.get(i); 779 long age = System.currentTimeMillis() - cur.recvTime; 780 if (age >= BuildRequestor.REQUEST_TIMEOUT/4) { 781 _inboundBuildMessages.remove(i); 782 i--; 783 dropped++; 784 _context.statManager().addRateData("tunnel.dropLoad", age, _inboundBuildMessages.size()); 785 } 786 } 787 if (dropped > 0) { 678 int sz = _inboundBuildMessages.size(); 679 BuildMessageState cur = _inboundBuildMessages.peek(); 680 boolean accept = true; 681 if (cur != null) { 682 long age = System.currentTimeMillis() - cur.recvTime; 683 if (age >= BuildRequestor.REQUEST_TIMEOUT/4) { 684 _context.statManager().addRateData("tunnel.dropLoad", age, sz); 788 685 _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: High load")); 789 686 // if the queue is backlogged, stop adding new messages 790 _context.statManager().addRateData("tunnel.dropLoadBacklog", _inboundBuildMessages.size(), _inboundBuildMessages.size()); 687 _context.statManager().addRateData("tunnel.dropLoadBacklog", sz, sz); 688 accept = false; 689 } 690 } 691 if (accept) { 692 int queueTime = estimateQueueTime(sz); 693 float pDrop = queueTime/((float)BuildRequestor.REQUEST_TIMEOUT*3); 694 pDrop = (float)Math.pow(pDrop, 16); // steeeep 695 float f = _context.random().nextFloat(); 696 //if ( (pDrop > f) && (allowProactiveDrop()) ) { 697 if (pDrop > f) { 698 _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Queue time")); 699 _context.statManager().addRateData("tunnel.dropLoadProactive", queueTime, sz); 791 700 } else { 792 int queueTime = estimateQueueTime(_inboundBuildMessages.size()); 793 float pDrop = queueTime/((float)BuildRequestor.REQUEST_TIMEOUT*3); 794 pDrop = (float)Math.pow(pDrop, 16); // steeeep 795 float f = _context.random().nextFloat(); 796 if ( (pDrop > f) && (allowProactiveDrop()) ) { 797 _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Queue time")); 798 _context.statManager().addRateData("tunnel.dropLoadProactive", queueTime, _inboundBuildMessages.size()); 701 accept = _inboundBuildMessages.offer(new BuildMessageState(receivedMessage, from, fromHash)); 702 if (accept) { 703 // wake up the Executor to call handleInboundRequests() 704 _exec.repoll(); 799 705 } else { 800 _inboundBuildMessages.add(new BuildMessageState(receivedMessage, from, fromHash)); 706 _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: High load")); 707 _context.statManager().addRateData("tunnel.dropLoadBacklog", sz, sz); 801 708 } 802 709 } 803 710 } 804 _exec.repoll();805 711 } 806 712 } … … 809 715 } 810 716 717 /**** 811 718 private boolean allowProactiveDrop() { 812 String allow = _context.getProperty("router.allowProactiveDrop", "true"); 813 boolean rv = false; 814 if ( (allow == null) || (Boolean.valueOf(allow).booleanValue()) ) 815 rv = true; 719 boolean rv = _context.getBooleanPropertyDefaultTrue("router.allowProactiveDrop"); 816 720 if (!rv) 817 721 _context.statManager().addRateData("tunnel.dropLoadProactiveAbort", 1, 0); 818 722 return rv; 819 723 } 724 ****/ 820 725 821 726 private int estimateQueueTime(int numPendingMessages) { … … 846 751 _log.debug("Receive tunnel build reply message " + receivedMessage.getUniqueId() + " from " 847 752 + (fromHash != null ? fromHash.toBase64() : from != null ? from.calculateHash().toBase64() : "a tunnel")); 848 if (HANDLE_REPLIES_INLINE) { 849 handleReply(new BuildReplyMessageState(receivedMessage)); 850 } else { 851 synchronized (_inboundBuildReplyMessages) { 852 _inboundBuildReplyMessages.add(new BuildReplyMessageState(receivedMessage)); 853 } 854 _exec.repoll(); 855 } 753 handleReply(new BuildReplyMessageState(receivedMessage)); 856 754 return _buildReplyMessageHandlerJob; 857 755 } … … 860 758 /** normal inbound requests from other people */ 861 759 private static class BuildMessageState { 862 TunnelBuildMessage msg;863 RouterIdentity from;864 Hash fromHash;865 long recvTime;760 final TunnelBuildMessage msg; 761 final RouterIdentity from; 762 final Hash fromHash; 763 final long recvTime; 866 764 public BuildMessageState(I2NPMessage m, RouterIdentity f, Hash h) { 867 765 msg = (TunnelBuildMessage)m; … … 873 771 /** replies for outbound tunnels that we have created */ 874 772 private static class BuildReplyMessageState { 875 TunnelBuildReplyMessage msg;876 long recvTime;773 final TunnelBuildReplyMessage msg; 774 final long recvTime; 877 775 public BuildReplyMessageState(I2NPMessage m) { 878 776 msg = (TunnelBuildReplyMessage)m; … … 882 780 /** replies for inbound tunnels we have created */ 883 781 private static class BuildEndMessageState { 884 TunnelBuildMessage msg;885 PooledTunnelCreatorConfig cfg;886 long recvTime;782 final TunnelBuildMessage msg; 783 final PooledTunnelCreatorConfig cfg; 784 final long recvTime; 887 785 public BuildEndMessageState(PooledTunnelCreatorConfig c, I2NPMessage m) { 888 786 cfg = c; … … 892 790 } 893 791 894 / / noop792 /** noop */ 895 793 private static class TunnelBuildMessageHandlerJob extends JobImpl { 896 794 private TunnelBuildMessageHandlerJob(RouterContext ctx) { super(ctx); } … … 898 796 public String getName() { return "Receive tunnel build message"; } 899 797 } 900 // noop 798 799 /** noop */ 901 800 private static class TunnelBuildReplyMessageHandlerJob extends JobImpl { 902 801 private TunnelBuildReplyMessageHandlerJob(RouterContext ctx) { super(ctx); } … … 911 810 */ 912 811 private static class TunnelBuildNextHopFailJob extends JobImpl { 913 HopConfig _cfg;812 final HopConfig _cfg; 914 813 private TunnelBuildNextHopFailJob(RouterContext ctx, HopConfig cfg) { 915 814 super(ctx); -
router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java
rcacd0f8 r9030b64 23 23 24 24 /** 25 * 25 * Methods for creating Tunnel Build Messages, i.e. requests 26 26 */ 27 class BuildRequestor {27 abstract class BuildRequestor { 28 28 private static final List<Integer> ORDER = new ArrayList(TunnelBuildMessage.MAX_RECORD_COUNT); 29 29 static { … … 38 38 * Put the expiration in the PTCC. 39 39 * 40 * Also, perhaps,save the PTCC even after expiration for an extended time,40 * Also, we now save the PTCC even after expiration for an extended time, 41 41 * so can we use a successfully built tunnel anyway. 42 42 * … … 50 50 private static final int BUILD_MSG_TIMEOUT = 60*1000; 51 51 52 /** 53 * "paired tunnels" means using a client's own inbound tunnel to receive the 54 * reply for an outbound build request, and using a client's own outbound tunnel 55 * to send an inbound build request. 56 * This is more secure than using the router's exploratory tunnels, as it 57 * makes correlation of multiple clients more difficult. 58 */ 52 59 private static boolean usePairedTunnels(RouterContext ctx) { 53 String val = ctx.getProperty("router.usePairedTunnels"); 54 if ( (val == null) || (Boolean.valueOf(val).booleanValue()) ) 55 return true; 56 else 57 return false; 60 return true; 61 //return ctx.getBooleanPropertyDefaultTrue("router.usePairedTunnels"); 58 62 } 59 63 … … 322 326 */ 323 327 private static class TunnelBuildFirstHopFailJob extends JobImpl { 324 TunnelPool _pool;325 PooledTunnelCreatorConfig _cfg;326 BuildExecutor _exec;328 final TunnelPool _pool; 329 final PooledTunnelCreatorConfig _cfg; 330 final BuildExecutor _exec; 327 331 private TunnelBuildFirstHopFailJob(RouterContext ctx, TunnelPool pool, PooledTunnelCreatorConfig cfg, BuildExecutor exec) { 328 332 super(ctx); -
router/java/src/net/i2p/router/tunnel/pool/ExpireJob.java
rcacd0f8 r9030b64 6 6 import net.i2p.router.tunnel.TunnelCreatorConfig; 7 7 8 /** 9 * This runs twice for each tunnel. 10 * The first time, remove it from the LeaseSet. 11 * The second time, stop accepting data for it. 12 */ 8 13 class ExpireJob extends JobImpl { 9 private TunnelPool _pool;10 private TunnelCreatorConfig _cfg;14 private final TunnelPool _pool; 15 private final TunnelCreatorConfig _cfg; 11 16 private boolean _leaseUpdated; 12 private long _dropAfter; 17 private final long _dropAfter; 18 13 19 public ExpireJob(RouterContext ctx, TunnelCreatorConfig cfg, TunnelPool pool) { 14 20 super(ctx); 15 21 _pool = pool; 16 22 _cfg = cfg; 17 _leaseUpdated = false;18 23 // we act as if this tunnel expires a random skew before it actually does 19 24 // so we rebuild out of sync. otoh, we will honor tunnel messages on it … … 29 34 getTiming().setStartAfter(expire); 30 35 } 36 31 37 public String getName() { 32 38 return "Expire tunnel"; 33 39 } 40 34 41 public void runJob() { 35 42 if (!_leaseUpdated) { -
router/java/src/net/i2p/router/tunnel/pool/TestJob.java
rcacd0f8 r9030b64 23 23 24 24 class TestJob extends JobImpl { 25 private Log _log;26 private TunnelPool _pool;27 private PooledTunnelCreatorConfig _cfg;25 private final Log _log; 26 private final TunnelPool _pool; 27 private final PooledTunnelCreatorConfig _cfg; 28 28 private boolean _found; 29 29 private TunnelInfo _outTunnel; … … 40 40 super(ctx); 41 41 _log = ctx.logManager().getLog(TestJob.class); 42 _pool = pool;43 42 _cfg = cfg; 44 if (_pool == null) 43 if (pool != null) 44 _pool = pool; 45 else 45 46 _pool = cfg.getTunnelPool(); 46 47 if ( (_pool == null) && (_log.shouldLog(Log.ERROR)) ) … … 62 63 RATES); 63 64 } 65 64 66 public String getName() { return "Test tunnel"; } 67 65 68 public void runJob() { 66 69 if (_pool == null) … … 247 250 248 251 private class ReplySelector implements MessageSelector { 249 private RouterContext _context; 250 private long _id; 251 private long _expiration; 252 private final RouterContext _context; 253 private final long _id; 254 private final long _expiration; 255 252 256 public ReplySelector(RouterContext ctx, long id, long expiration) { 253 257 _context = ctx; … … 258 262 259 263 public boolean continueMatching() { return !_found && _context.clock().now() < _expiration; } 264 260 265 public long getExpiration() { return _expiration; } 266 261 267 public boolean isMatch(I2NPMessage message) { 262 268 if (message instanceof DeliveryStatusMessage) { … … 281 287 private long _successTime; 282 288 private OutNetMessage _sentMessage; 289 283 290 public OnTestReply(RouterContext ctx) { super(ctx); } 291 284 292 public String getName() { return "Tunnel test success"; } 293 285 294 public void setSentMessage(OutNetMessage m) { _sentMessage = m; } 295 286 296 public void runJob() { 287 297 if (_sentMessage != null) … … 293 303 _found = true; 294 304 } 305 295 306 // who cares about the details... 296 307 public void setMessage(I2NPMessage message) { … … 311 322 */ 312 323 private class OnTestTimeout extends JobImpl { 313 private long _started; 324 private final long _started; 325 314 326 public OnTestTimeout(RouterContext ctx) { 315 327 super(ctx); 316 328 _started = ctx.clock().now(); 317 329 } 330 318 331 public String getName() { return "Tunnel test timeout"; } 332 319 333 public void runJob() { 320 334 if (_log.shouldLog(Log.WARN)) -
router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
rcacd0f8 r9030b64 23 23 24 24 /** 25 * 25 * A group of tunnels for the router or a particular client, in a single direction. 26 26 */ 27 27 public class TunnelPool { 28 28 private final List _inProgress = new ArrayList(); 29 private RouterContext _context;30 private Log _log;29 private final RouterContext _context; 30 private final Log _log; 31 31 private TunnelPoolSettings _settings; 32 32 private final ArrayList<TunnelInfo> _tunnels; 33 private TunnelPeerSelector _peerSelector;34 private TunnelPoolManager _manager;33 private final TunnelPeerSelector _peerSelector; 34 private final TunnelPoolManager _manager; 35 35 private boolean _alive; 36 36 private long _lifetimeProcessed; 37 37 private TunnelInfo _lastSelected; 38 38 private long _lastSelectionPeriod; 39 private int _expireSkew;39 private final int _expireSkew; 40 40 private long _started; 41 41 private long _lastRateUpdate; … … 51 51 _tunnels = new ArrayList(settings.getLength() + settings.getBackupQuantity()); 52 52 _peerSelector = sel; 53 _alive = false;54 _lastSelectionPeriod = 0;55 _lastSelected = null;56 _lifetimeProcessed = 0;57 53 _expireSkew = _context.random().nextInt(90*1000); 58 54 _started = System.currentTimeMillis(); 59 55 _lastRateUpdate = _started; 60 _lastLifetimeProcessed = 0;61 56 _rateName = "tunnel.Bps." + 62 57 (_settings.isExploratory() ? "exploratory" : _settings.getDestinationNickname()) + … … 413 408 } 414 409 410 /** noop for outbound */ 415 411 void refreshLeaseSet() { 416 if (_log.shouldLog(Log.DEBUG))417 _log.debug(toString() + ": refreshing leaseSet on tunnel expiration (but prior to grace timeout)");418 LeaseSet ls = null;419 412 if (_settings.isInbound() && (_settings.getDestination() != null) ) { 413 if (_log.shouldLog(Log.DEBUG)) 414 _log.debug(toString() + ": refreshing leaseSet on tunnel expiration (but prior to grace timeout)"); 415 LeaseSet ls = null; 420 416 synchronized (_tunnels) { 421 417 ls = locked_buildNewLeaseSet(); … … 428 424 429 425 /** 430 * Return true if a fallback tunnel is built426 * @return true if a fallback tunnel is built 431 427 * 432 428 */ … … 852 848 853 849 PooledTunnelCreatorConfig configureNewTunnel() { return configureNewTunnel(false); } 850 854 851 private PooledTunnelCreatorConfig configureNewTunnel(boolean forceZeroHop) { 855 852 TunnelPoolSettings settings = getSettings(); -
router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java
rcacd0f8 r9030b64 38 38 */ 39 39 public class TunnelPoolManager implements TunnelManagerFacade { 40 private RouterContext _context;41 private Log _log;40 private final RouterContext _context; 41 private final Log _log; 42 42 /** Hash (destination) to TunnelPool */ 43 43 private final Map<Hash, TunnelPool> _clientInboundPools; … … 62 62 _clientOutboundPools = new ConcurrentHashMap(4); 63 63 64 _isShutdown = false;65 64 _executor = new BuildExecutor(ctx, this); 66 65 I2PThread execThread = new I2PThread(_executor, "BuildExecutor");
Note: See TracChangeset
for help on using the changeset viewer.