forked from I2P_Developers/i2p.i2p
NetDB: Reseed after a long downtime
This commit is contained in:
@ -32,9 +32,12 @@ public class ReseedChecker {
|
|||||||
private volatile String _lastStatus = "";
|
private volatile String _lastStatus = "";
|
||||||
private volatile String _lastError = "";
|
private volatile String _lastError = "";
|
||||||
private volatile boolean _networkLogged;
|
private volatile boolean _networkLogged;
|
||||||
|
private volatile boolean _alreadyRun;
|
||||||
|
|
||||||
public static final int MINIMUM = 50;
|
public static final int MINIMUM = 50;
|
||||||
private static final long STATUS_CLEAN_TIME = 20*60*1000;
|
private static final long STATUS_CLEAN_TIME = 20*60*1000;
|
||||||
|
// if down this long, reseed at startup
|
||||||
|
private static final long RESEED_MIN_DOWNTIME = 60*24*60*60*1000L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All reseeding must be done through this instance.
|
* All reseeding must be done through this instance.
|
||||||
@ -54,8 +57,14 @@ public class ReseedChecker {
|
|||||||
* @return true if a reseed was started
|
* @return true if a reseed was started
|
||||||
*/
|
*/
|
||||||
public boolean checkReseed(int count) {
|
public boolean checkReseed(int count) {
|
||||||
|
if (_alreadyRun) {
|
||||||
if (count >= MINIMUM)
|
if (count >= MINIMUM)
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
_alreadyRun = true;
|
||||||
|
if (count >= MINIMUM && _context.getEstimatedDowntime() < RESEED_MIN_DOWNTIME)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (_context.getBooleanProperty(Reseeder.PROP_DISABLE)) {
|
if (_context.getBooleanProperty(Reseeder.PROP_DISABLE)) {
|
||||||
int x = count - 1; // us
|
int x = count - 1; // us
|
||||||
@ -126,6 +135,7 @@ public class ReseedChecker {
|
|||||||
*/
|
*/
|
||||||
public boolean requestReseed() {
|
public boolean requestReseed() {
|
||||||
if (_inProgress.compareAndSet(false, true)) {
|
if (_inProgress.compareAndSet(false, true)) {
|
||||||
|
_alreadyRun = true;
|
||||||
try {
|
try {
|
||||||
Reseeder reseeder = new Reseeder(_context, this);
|
Reseeder reseeder = new Reseeder(_context, this);
|
||||||
reseeder.requestReseed();
|
reseeder.requestReseed();
|
||||||
|
Reference in New Issue
Block a user