* i2psnark: Report cleared trackerErr immediately
    * i2psnark: Add trackerErr reporting after previous success; retry more quickly
    * i2psnark: Set up new connections more quickly
    * i2psnark: Don't delay tracker fetch when setting up lots of connections
    * i2psnark: Reduce MAX_UPLOADERS from 12 to 4
This commit is contained in:
zzz
2006-09-04 08:26:21 +00:00
committed by zzz
parent aef19fcd38
commit b92ee364bc
4 changed files with 48 additions and 18 deletions

View File

@ -39,7 +39,7 @@ public class PeerCoordinator implements PeerListener
// package local for access by CheckDownLoadersTask // package local for access by CheckDownLoadersTask
final static long CHECK_PERIOD = 20*1000; // 20 seconds final static long CHECK_PERIOD = 20*1000; // 20 seconds
final static int MAX_CONNECTIONS = 24; final static int MAX_CONNECTIONS = 24;
final static int MAX_UPLOADERS = 12; // i2p: might as well balance it out final static int MAX_UPLOADERS = 4;
// Approximation of the number of current uploaders. // Approximation of the number of current uploaders.
// Resynced by PeerChecker once in a while. // Resynced by PeerChecker once in a while.
@ -154,8 +154,8 @@ public class PeerCoordinator implements PeerListener
uploaded_old[i] = uploaded_old[i-1]; uploaded_old[i] = uploaded_old[i-1];
downloaded_old[i] = downloaded_old[i-1]; downloaded_old[i] = downloaded_old[i-1];
} }
uploaded_old[0] = up; uploaded_old[0] = up;
downloaded_old[0] = down; downloaded_old[0] = down;
} }
/** /**
@ -275,12 +275,13 @@ public class PeerCoordinator implements PeerListener
return null; return null;
} }
public void addPeer(final Peer peer) // returns true if actual attempt to add peer occurs
public boolean addPeer(final Peer peer)
{ {
if (halted) if (halted)
{ {
peer.disconnect(false); peer.disconnect(false);
return; return false;
} }
boolean need_more; boolean need_more;
@ -305,6 +306,7 @@ public class PeerCoordinator implements PeerListener
}; };
String threadName = peer.toString(); String threadName = peer.toString();
new I2PThread(r, threadName).start(); new I2PThread(r, threadName).start();
return true;
} }
else else
if (_log.shouldLog(Log.DEBUG)) { if (_log.shouldLog(Log.DEBUG)) {
@ -314,6 +316,7 @@ public class PeerCoordinator implements PeerListener
_log.info("MAX_CONNECTIONS = " + MAX_CONNECTIONS _log.info("MAX_CONNECTIONS = " + MAX_CONNECTIONS
+ " not accepting extra peer: " + peer); + " not accepting extra peer: " + peer);
} }
return false;
} }

View File

@ -43,6 +43,8 @@ public class TrackerClient extends I2PThread
private static final String STOPPED_EVENT = "stopped"; private static final String STOPPED_EVENT = "stopped";
private final static int SLEEP = 5; // 5 minutes. private final static int SLEEP = 5; // 5 minutes.
private final static int DELAY_MIN = 2000; // 2 secs.
private final static int DELAY_MUL = 1500; // 1.5 secs.
private final MetaInfo meta; private final MetaInfo meta;
private final PeerCoordinator coordinator; private final PeerCoordinator coordinator;
@ -110,6 +112,7 @@ public class TrackerClient extends I2PThread
long left = coordinator.getLeft(); long left = coordinator.getLeft();
boolean completed = (left == 0); boolean completed = (left == 0);
int sleptTime = 0;
try try
{ {
@ -117,6 +120,7 @@ public class TrackerClient extends I2PThread
boolean started = false; boolean started = false;
while (!started) while (!started)
{ {
sleptTime = 0;
try try
{ {
// Send start. // Send start.
@ -125,18 +129,20 @@ public class TrackerClient extends I2PThread
STARTED_EVENT); STARTED_EVENT);
Set peers = info.getPeers(); Set peers = info.getPeers();
coordinator.trackerSeenPeers = peers.size(); coordinator.trackerSeenPeers = peers.size();
coordinator.trackerProblems = null;
if (!completed) { if (!completed) {
Iterator it = peers.iterator(); Iterator it = peers.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Peer cur = (Peer)it.next(); Peer cur = (Peer)it.next();
coordinator.addPeer(cur); coordinator.addPeer(cur);
int delay = 3000; int delay = DELAY_MUL;
int c = ((int)cur.getPeerID().getAddress().calculateHash().toBase64().charAt(0)) % 10; delay *= ((int)cur.getPeerID().getAddress().calculateHash().toBase64().charAt(0)) % 10;
try { Thread.sleep(delay * c); } catch (InterruptedException ie) {} delay += DELAY_MIN;
sleptTime += delay;
try { Thread.sleep(delay); } catch (InterruptedException ie) {}
} }
} }
started = true; started = true;
coordinator.trackerProblems = null;
} }
catch (IOException ioe) catch (IOException ioe)
{ {
@ -168,8 +174,15 @@ public class TrackerClient extends I2PThread
try try
{ {
// Sleep some minutes... // Sleep some minutes...
int delay = SLEEP*60*1000 + r.nextInt(120*1000); int delay;
Thread.sleep(delay); if(coordinator.trackerProblems != null) {
delay = 60*1000;
} else {
delay = SLEEP*60*1000 + r.nextInt(120*1000);
delay -= sleptTime;
}
if (delay > 0)
Thread.sleep(delay);
} }
catch(InterruptedException interrupt) catch(InterruptedException interrupt)
{ {
@ -206,6 +219,8 @@ public class TrackerClient extends I2PThread
uploaded, downloaded, left, uploaded, downloaded, left,
event); event);
coordinator.trackerProblems = null;
sleptTime = 0;
Set peers = info.getPeers(); Set peers = info.getPeers();
coordinator.trackerSeenPeers = peers.size(); coordinator.trackerSeenPeers = peers.size();
if ( (left > 0) && (!completed) ) { if ( (left > 0) && (!completed) ) {
@ -216,10 +231,14 @@ public class TrackerClient extends I2PThread
Iterator it = ordered.iterator(); Iterator it = ordered.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Peer cur = (Peer)it.next(); Peer cur = (Peer)it.next();
coordinator.addPeer(cur); // only delay if we actually make an attempt to add peer
int delay = 3000; if(coordinator.addPeer(cur)) {
int c = ((int)cur.getPeerID().getAddress().calculateHash().toBase64().charAt(0)) % 10; int delay = DELAY_MUL;
try { Thread.sleep(delay * c); } catch (InterruptedException ie) {} delay *= ((int)cur.getPeerID().getAddress().calculateHash().toBase64().charAt(0)) % 10;
delay += DELAY_MIN;
sleptTime += delay;
try { Thread.sleep(delay); } catch (InterruptedException ie) {}
}
} }
} }
} }
@ -229,6 +248,7 @@ public class TrackerClient extends I2PThread
Snark.debug Snark.debug
("WARNING: Could not contact tracker at '" ("WARNING: Could not contact tracker at '"
+ announce + "': " + ioe, Snark.WARNING); + announce + "': " + ioe, Snark.WARNING);
coordinator.trackerProblems = ioe.getMessage();
} }
} }
} }

View File

@ -1,4 +1,11 @@
$Id: history.txt,v 1.508 2006-09-03 04:12:23 zzz Exp $ $Id: history.txt,v 1.509 2006-09-04 01:01:54 zzz Exp $
2006-09-04 zzz
* i2psnark: Report cleared trackerErr immediately
* i2psnark: Add trackerErr reporting after previous success; retry more quickly
* i2psnark: Set up new connections more quickly
* i2psnark: Don't delay tracker fetch when setting up lots of connections
* i2psnark: Reduce MAX_UPLOADERS from 12 to 4
2006-09-04 zzz 2006-09-04 zzz
* Enable pipelining in i2psnark * Enable pipelining in i2psnark

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
* *
*/ */
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.448 $ $Date: 2006-09-03 04:12:22 $"; public final static String ID = "$Revision: 1.449 $ $Date: 2006-09-04 01:01:53 $";
public final static String VERSION = "0.6.1.24"; public final static String VERSION = "0.6.1.24";
public final static long BUILD = 7; public final static long BUILD = 8;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);