forked from I2P_Developers/i2p.i2p
Console: Better status feedback on manual reseed from URL
Reseed: Better status feedback and cleanup in summary bar
This commit is contained in:
@@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 9;
|
||||
public final static long BUILD = 10;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
@@ -6,9 +6,11 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.Addresses;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
* Moved from RouterConsoleRunner.java
|
||||
@@ -31,6 +33,7 @@ public class ReseedChecker {
|
||||
private volatile String _lastError = "";
|
||||
|
||||
public static final int MINIMUM = 50;
|
||||
private static final long STATUS_CLEAN_TIME = 20*60*1000;
|
||||
|
||||
/**
|
||||
* All reseeding must be done through this instance.
|
||||
@@ -123,6 +126,8 @@ public class ReseedChecker {
|
||||
reseeder.requestReseed(url);
|
||||
return true;
|
||||
} catch (IllegalArgumentException iae) {
|
||||
if (iae.getMessage() != null)
|
||||
setError(DataHelper.escapeHTML(iae.getMessage()));
|
||||
done();
|
||||
throw iae;
|
||||
} catch (Throwable t) {
|
||||
@@ -150,6 +155,11 @@ public class ReseedChecker {
|
||||
try {
|
||||
Reseeder reseeder = new Reseeder(_context, this);
|
||||
return reseeder.requestReseed(in);
|
||||
} catch (IOException ioe) {
|
||||
if (ioe.getMessage() != null)
|
||||
setError(DataHelper.escapeHTML(ioe.getMessage()));
|
||||
done();
|
||||
throw ioe;
|
||||
} finally {
|
||||
done();
|
||||
}
|
||||
@@ -174,11 +184,13 @@ public class ReseedChecker {
|
||||
*/
|
||||
void done() {
|
||||
_inProgress.set(false);
|
||||
_context.simpleScheduler().addEvent(new StatusCleaner(_lastStatus, _lastError), STATUS_CLEAN_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Status from current reseed attempt,
|
||||
* probably empty if no reseed in progress.
|
||||
* May include HTML.
|
||||
*
|
||||
* @return non-null, may be empty
|
||||
* @since 0.9
|
||||
@@ -198,7 +210,8 @@ public class ReseedChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Error from last or current reseed attempt
|
||||
* Error from last or current reseed attempt.
|
||||
* May include HTML.
|
||||
*
|
||||
* @return non-null, may be empty
|
||||
* @since 0.9
|
||||
@@ -217,4 +230,22 @@ public class ReseedChecker {
|
||||
_lastError = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.19
|
||||
*/
|
||||
private class StatusCleaner implements SimpleTimer.TimedEvent {
|
||||
private final String _status, _error;
|
||||
|
||||
public StatusCleaner(String status, String error) {
|
||||
_status = status;
|
||||
_error = error;
|
||||
}
|
||||
|
||||
public void timeReached() {
|
||||
if (_status.equals(getStatus()))
|
||||
setStatus("");
|
||||
if (_error.equals(getError()))
|
||||
setError("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -167,6 +167,8 @@ public class Reseeder {
|
||||
* @since 0.9.19
|
||||
*/
|
||||
int requestReseed(InputStream in) throws IOException {
|
||||
_checker.setError("");
|
||||
_checker.setStatus("Reseeding from file");
|
||||
byte[] su3Magic = DataHelper.getASCII(SU3File.MAGIC);
|
||||
byte[] zipMagic = new byte[] { 0x50, 0x4b, 0x03, 0x04 };
|
||||
int len = Math.max(su3Magic.length, zipMagic.length);
|
||||
@@ -282,7 +284,7 @@ public class Reseeder {
|
||||
} else {
|
||||
total = reseed(false);
|
||||
}
|
||||
if (total >= 50) {
|
||||
if (total >= 20) {
|
||||
System.out.println("Reseed complete, " + total + " received");
|
||||
_checker.setError("");
|
||||
} else if (total > 0) {
|
||||
@@ -294,12 +296,15 @@ public class Reseeder {
|
||||
System.out.println(
|
||||
"Ensure that nothing blocks outbound HTTP, check the logs, " +
|
||||
"and if nothing helps, read the FAQ about reseeding manually.");
|
||||
String old = _checker.getError();
|
||||
_checker.setError(_("Reseed failed.") + ' ' +
|
||||
_("See {0} for help.",
|
||||
"<a target=\"_top\" href=\"/configreseed\">" + _("reseed configuration page") + "</a>"));
|
||||
_("See {0} for help.",
|
||||
"<a target=\"_top\" href=\"/configreseed\">" + _("reseed configuration page") + "</a>") +
|
||||
"<br>" + old);
|
||||
}
|
||||
_isRunning = false;
|
||||
_checker.setStatus("");
|
||||
// ReseedChecker will set timer to clean up
|
||||
//_checker.setStatus("");
|
||||
_context.router().eventLog().addEvent(EventLog.RESEED, Integer.toString(total));
|
||||
}
|
||||
|
||||
@@ -328,6 +333,8 @@ public class Reseeder {
|
||||
_log.warn("EepGet failed on " + url, cause);
|
||||
else
|
||||
_log.logAlways(Log.WARN, "EepGet failed on " + url + " : " + cause);
|
||||
if (cause != null && cause.getMessage() != null)
|
||||
_checker.setError(DataHelper.escapeHTML(cause.getMessage()));
|
||||
}
|
||||
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {}
|
||||
|
Reference in New Issue
Block a user