forked from I2P_Developers/i2p.i2p
* Reseed: Limit time spent downloading from a single source
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2011-02-03 zzz
|
||||||
|
* Console: Add DTG to classpath for old installs
|
||||||
|
* I2PTunnel: Fix NPE
|
||||||
|
* RandomSource: Fix seeding from /dev/urandom
|
||||||
|
* Reseed: Limit time spent downloading from a single source
|
||||||
|
|
||||||
2011-02-02 sponge
|
2011-02-02 sponge
|
||||||
* BOB: Revise lookup code, bump BOB version
|
* BOB: Revise lookup code, bump BOB version
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 1;
|
public final static long BUILD = 2;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@ -35,12 +35,18 @@ import net.i2p.util.Translate;
|
|||||||
*/
|
*/
|
||||||
public class Reseeder {
|
public class Reseeder {
|
||||||
private static ReseedRunner _reseedRunner;
|
private static ReseedRunner _reseedRunner;
|
||||||
private RouterContext _context;
|
private final RouterContext _context;
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
|
|
||||||
// Reject unreasonably big files, because we download into a ByteArrayOutputStream.
|
// Reject unreasonably big files, because we download into a ByteArrayOutputStream.
|
||||||
private static final long MAX_RESEED_RESPONSE_SIZE = 1024 * 1024;
|
private static final long MAX_RESEED_RESPONSE_SIZE = 1024 * 1024;
|
||||||
|
/** limit to spend on a single host, to avoid getting stuck on one that is seriously overloaded */
|
||||||
|
private static final int MAX_TIME_PER_HOST = 7 * 60 * 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE - URLs in both the standard and SSL groups should use the same hostname and path,
|
||||||
|
* so the reseed process will not download from both.
|
||||||
|
*/
|
||||||
public static final String DEFAULT_SEED_URL =
|
public static final String DEFAULT_SEED_URL =
|
||||||
"http://a.netdb.i2p2.de/,http://c.netdb.i2p2.de/," +
|
"http://a.netdb.i2p2.de/,http://c.netdb.i2p2.de/," +
|
||||||
"http://reseed.i2p-projekt.de/,http://forum.i2p2.de/netdb/,http://www.i2pbote.net/netDb/,http://r31453.ovh.net/static_media/files/netDb/";
|
"http://reseed.i2p-projekt.de/,http://forum.i2p2.de/netdb/,http://www.i2pbote.net/netDb/,http://r31453.ovh.net/static_media/files/netDb/";
|
||||||
@ -229,6 +235,7 @@ public class Reseeder {
|
|||||||
**/
|
**/
|
||||||
private int reseedOne(String seedURL, boolean echoStatus) {
|
private int reseedOne(String seedURL, boolean echoStatus) {
|
||||||
try {
|
try {
|
||||||
|
final long timeLimit = _context.clock().now() + MAX_TIME_PER_HOST;
|
||||||
System.setProperty(PROP_STATUS, _("Reseeding: fetching seed URL."));
|
System.setProperty(PROP_STATUS, _("Reseeding: fetching seed URL."));
|
||||||
System.err.println("Reseeding from " + seedURL);
|
System.err.println("Reseeding from " + seedURL);
|
||||||
URL dir = new URL(seedURL);
|
URL dir = new URL(seedURL);
|
||||||
@ -267,7 +274,8 @@ public class Reseeder {
|
|||||||
int fetched = 0;
|
int fetched = 0;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
// 200 max from one URL
|
// 200 max from one URL
|
||||||
for (Iterator<String> iter = urlList.iterator(); iter.hasNext() && fetched < 200; ) {
|
for (Iterator<String> iter = urlList.iterator();
|
||||||
|
iter.hasNext() && fetched < 200 && _context.clock().now() < timeLimit; ) {
|
||||||
try {
|
try {
|
||||||
System.setProperty(PROP_STATUS,
|
System.setProperty(PROP_STATUS,
|
||||||
_("Reseeding: fetching router info from seed URL ({0} successful, {1} errors).", fetched, errors));
|
_("Reseeding: fetching router info from seed URL ({0} successful, {1} errors).", fetched, errors));
|
||||||
|
Reference in New Issue
Block a user