Changeset 231040d
- Timestamp:
- Nov 14, 2015 2:07:01 AM (5 years ago)
- Branches:
- master
- Children:
- 23cb4ca
- Parents:
- ded249d
- Location:
- router/java/src/net/i2p/router
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java
rded249d r231040d 157 157 */ 158 158 public PeerProfile getProfile(Hash peer) { 159 if (peer.equals(_us)) { 160 if (_log.shouldWarn()) 161 _log.warn("Who wanted our own profile?", new Exception("I did")); 162 return null; 163 } 159 164 getReadLock(); 160 165 try { … … 169 174 */ 170 175 public PeerProfile getProfileNonblocking(Hash peer) { 176 if (peer.equals(_us)) { 177 if (_log.shouldWarn()) 178 _log.warn("Who wanted our own profile?", new Exception("I did")); 179 return null; 180 } 171 181 if (tryReadLock()) { 172 182 try { … … 185 195 186 196 Hash peer = profile.getPeer(); 197 if (peer.equals(_us)) { 198 if (_log.shouldWarn()) 199 _log.warn("Who added our own profile?", new Exception("I did")); 200 return null; 201 } 187 202 188 203 if (_log.shouldLog(Log.DEBUG)) -
router/java/src/net/i2p/router/tunnel/HopConfig.java
rded249d r231040d 51 51 public void setReceiveTunnelId(TunnelId id) { _receiveTunnelId = DataHelper.toLong(4, id.getTunnelId()); } 52 52 53 /** what is the previous peer in the tunnel ( if any)?*/53 /** what is the previous peer in the tunnel (null if gateway) */ 54 54 public Hash getReceiveFrom() { return _receiveFrom; } 55 55 public void setReceiveFrom(Hash from) { _receiveFrom = from; } 56 56 57 /** what is the next tunnel ID we are sending to? */57 /** what is the next tunnel ID we are sending to? (null if endpoint) */ 58 58 public byte[] getSendTunnelId() { return _sendTunnelId; } 59 60 /** what is the next tunnel we are sending to? (null if endpoint) */ 59 61 public TunnelId getSendTunnel() { 60 62 if (_sendTunnel == null) … … 71 73 } 72 74 73 /** what is the next peer in the tunnel ( if any)?*/75 /** what is the next peer in the tunnel (null if endpoint) */ 74 76 public Hash getSendTo() { return _sendTo; } 75 77 public void setSendTo(Hash to) { _sendTo = to; } -
router/java/src/net/i2p/router/tunnel/TunnelCreatorConfig.java
rded249d r231040d 31 31 private final boolean _isInbound; 32 32 private int _messagesProcessed; 33 private volatilelong _verifiedBytesTransferred;33 private long _verifiedBytesTransferred; 34 34 private boolean _failed; 35 35 private int _failures; 36 36 private boolean _reused; 37 37 private int _priority; 38 38 //private static final int THROUGHPUT_COUNT = 3; 39 // Fastest 1 minute throughput, in bytes per minute, ordered with fastest first. 40 //private final double _peakThroughput[] = new double[THROUGHPUT_COUNT]; 41 private long _peakThroughputCurrentTotal; 42 private long _peakThroughputLastCoallesce = System.currentTimeMillis(); 43 // Make configurable? - but can't easily get to pool options from here 44 private static final int MAX_CONSECUTIVE_TEST_FAILURES = 3; 45 private static final SimpleDateFormat _fmt = new SimpleDateFormat("HH:mm:ss", Locale.UK); 46 47 /** 48 * For exploratory only (null destination) 49 * @param length 1 minimum (0 hop is length 1) 50 */ 39 51 public TunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound) { 40 52 this(ctx, length, isInbound, null); 41 53 } 42 54 55 /** 56 * @param length 1 minimum (0 hop is length 1) 57 * @param destination null for exploratory 58 */ 43 59 public TunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound, Hash destination) { 44 60 _context = ctx; … … 132 148 133 149 /** take note of a message being pumped through this tunnel */ 134 public void incrementProcessedMessages() { _messagesProcessed++; } 135 public int getProcessedMessagesCount() { return _messagesProcessed; } 136 137 public void incrementVerifiedBytesTransferred(int bytes) { 150 public synchronized void incrementProcessedMessages() { _messagesProcessed++; } 151 public synchronized int getProcessedMessagesCount() { return _messagesProcessed; } 152 153 /** 154 * This calls profile manager tunnelDataPushed1m() for each peer 155 * @return null for exploratory 156 */ 157 public synchronized void incrementVerifiedBytesTransferred(int bytes) { 138 158 _verifiedBytesTransferred += bytes; 139 159 _peakThroughputCurrentTotal += bytes; … … 145 165 _peakThroughputLastCoallesce = now; 146 166 _peakThroughputCurrentTotal = 0; 147 if (_context != null) 148 for (int i = 0; i < _peers.length; i++) 167 if (_context != null) { 168 // skip ourselves 169 int start = _isInbound ? 0 : 1; 170 int end = _isInbound ? _peers.length - 1 : _peers.length; 171 for (int i = start; i < end; i++) { 149 172 _context.profileManager().tunnelDataPushed1m(_peers[i], (int)normalized); 150 } 151 } 152 153 public long getVerifiedBytesTransferred() { return _verifiedBytesTransferred; } 154 155 private static final int THROUGHPUT_COUNT = 3; 156 /** 157 * fastest 1 minute throughput, in bytes per minute, ordered with fastest 158 * first. 159 */ 160 private final double _peakThroughput[] = new double[THROUGHPUT_COUNT]; 161 private volatile long _peakThroughputCurrentTotal; 162 private volatile long _peakThroughputLastCoallesce = System.currentTimeMillis(); 163 public double getPeakThroughputKBps() { 173 } 174 } 175 } 176 } 177 178 public synchronized long getVerifiedBytesTransferred() { return _verifiedBytesTransferred; } 179 180 /**** unused 181 public synchronized double getPeakThroughputKBps() { 164 182 double rv = 0; 165 183 for (int i = 0; i < THROUGHPUT_COUNT; i++) … … 168 186 return rv; 169 187 } 170 public void setPeakThroughputKBps(double kBps) { 188 189 public synchronized void setPeakThroughputKBps(double kBps) { 171 190 _peakThroughput[0] = kBps*60*1024; 172 191 //for (int i = 0; i < THROUGHPUT_COUNT; i++) 173 192 // _peakThroughput[i] = kBps*60; 174 193 } 175 176 177 // Make configurable? - but can't easily get to pool options from here 178 private static final int MAX_CONSECUTIVE_TEST_FAILURES = 3; 194 ****/ 179 195 180 196 /** … … 265 281 } 266 282 267 private static final SimpleDateFormat _fmt = new SimpleDateFormat("HH:mm:ss", Locale.UK);268 269 283 private String getExpirationString() { 270 284 return format(_expiration); 271 285 } 286 272 287 static String format(long date) { 273 288 Date d = new Date(date); -
router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java
rded249d r231040d 796 796 cfg.setLayerKey(req.readLayerKey()); 797 797 if (isInGW) { 798 cfg.setReceiveFrom(null); 798 // default 799 //cfg.setReceiveFrom(null); 799 800 } else { 800 801 if (state.fromHash != null) { … … 809 810 cfg.setReceiveTunnelId(DataHelper.toLong(4, ourId)); 810 811 if (isOutEnd) { 811 cfg.setSendTo(null); 812 cfg.setSendTunnelId(null); 812 // default 813 //cfg.setSendTo(null); 814 //cfg.setSendTunnelId(null); 813 815 } else { 814 816 cfg.setSendTo(nextPeer); -
router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
rded249d r231040d 1169 1169 cfg.setPeer(j, peers.get(i)); 1170 1170 HopConfig hop = cfg.getConfig(j); 1171 hop.setCreation( _context.clock().now());1171 hop.setCreation(now); 1172 1172 hop.setExpiration(expiration); 1173 1173 hop.setIVKey(_context.keyGenerator().generateSessionKey());
Note: See TracChangeset
for help on using the changeset viewer.