java.lang.Object
java.lang.Thread
net.i2p.util.I2PThread
net.i2p.util.I2PAppThread
net.i2p.router.update.UpdateRunner
net.i2p.router.update.UnsignedUpdateChecker
- All Implemented Interfaces:
Runnable, UpdateTask, EepGet.StatusListener
Does a simple EepHead to get the last-modified header. Moved from
NewsFetcher and turned into an UpdateTask.Overrides UpdateRunner for convenience, does not use super's Eepget StatusListener.
Nested Class Summary
Nested classes/interfaces inherited from class I2PThread
I2PThread.OOMEventListenerModifier and TypeClassDescriptionstatic interfaceListener for out-of-memory events.Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandlerField Summary
FieldsModifier and TypeFieldDescriptionprivate final longMilliseconds between checks.private booleanTrue once an update with no valid signature is foundFields inherited from class UpdateRunner
_baos, _context, _currentURI, _get, _isPartial, _isRunning, _log, _method, _mgr, _newVersion, _type, _updateFile, _urls, CONNECT_TIMEOUT, done, INACTIVITY_TIMEOUT, NOPROXY_INACTIVITY_TIMEOUTModifier and TypeFieldDescriptionprotected final ByteArrayOutputStream56 byte header, only used for suds.protected final RouterContextRouter context.protected URICurrent URI being fetched.protected EepGetThe current EepGet instance.protected booleanTells the listeners what mode we are in - set to true in extending classes for checks.protected booleanWhether the runner is currently running.protected final LogClass logger.protected final UpdateMethodUpdate method.protected final ConsoleUpdateManagerUpdate manager.protected StringSet by the listeners on completion.protected final UpdateTypeUpdate type.protected final StringTemporary file for the update download.List of update URIs.protected static final longConnect timeout in ms.protected booleanWhether the update completed.protected static final longInactivity timeout with proxy in ms.protected static final longInactivity timeout without proxy in ms.Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITYConstructor Summary
ConstructorsConstructorDescriptionUnsignedUpdateChecker(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris, long lastUpdateTime) Records the installed version time used to decide if an update is newer.Method Summary
Modifier and TypeMethodDescriptionprivate booleanHEAD the update url, and if the last-mod time is newer than the last update we downloaded, as stored in the properties, then we download it using eepget.voidrun()Checks for a newer unsigned update and reports the outcome to the manager.Methods inherited from class UpdateRunner
_t, _t, attemptFailed, attempting, bytesTransferred, getID, getMethod, getType, getURI, headerReceived, isRunning, linkify, shutdown, toString, transferComplete, transferFailed, update, updateStatusModifier and TypeMethodDescriptionprotected StringTranslate a string.protected StringTranslate a string with a parameter.voidattemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) An attempt failed.voidattempting(String url) A retry is starting.voidbytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) Subclasses should override.getID()I d.Returns how the update is fetched, such as HTTP or torrent.getType()Returns what kind of update this runner handles.getURI()U r i.voidheaderReceived(String url, int attemptNum, String key, String val) HTTP response headers are not used to determine the update version.booleanWhether running.protected static StringWrap a URL in an anchor tag for display.voidshutdown()Clears the running flag and interrupts any update in progress.toString()Handler summary for log messages.voidtransferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) Subclasses should override.voidtransferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) Subclasses should override.protected voidupdate()Loop through the entire list of update URLs.protected voidReport progress to the user.Methods inherited from class I2PAppThread
addOOMEventThreadListener, fireOOM, removeOOMEventThreadListenerModifier and TypeMethodDescriptionvoidRegister a new component that wants notification of OOM events.protected voidfireOOM(OutOfMemoryError oom) Notify listeners that an OutOfMemoryError occurred.voidUnregister a component that wants notification of OOM events.Methods inherited from class I2PThread
addOOMEventListener, removeOOMEventListener, startModifier and TypeMethodDescriptionstatic voidRegister a new component that wants notification of OOM events.static voidUnregister a component that wants notification of OOM events.voidstart()Overridden to provide useful info to users on OOM, and to prevent shutting down the whole JVM for what is most likely not a heap issue.Methods inherited from class Thread
activeCount, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, startVirtualThread, threadId, yieldMethods inherited from interface UpdateTask
start
Field Details
_ms
private final long _msMilliseconds between checks._unsignedUpdateAvailable
private boolean _unsignedUpdateAvailableTrue once an update with no valid signature is found
Constructor Details
UnsignedUpdateChecker
public UnsignedUpdateChecker(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris, long lastUpdateTime) Records the installed version time used to decide if an update is newer.- Parameters:
ctx- the router context, passed to the superclass for fetchingmgr- the update manager to notify of the check's progress and resulturis- the update URLs to HEAD, tried in turnlastUpdateTime- the time in milliseconds of the currently installed version; 0 or less means unknown, and no update is then offered
Method Details
run
public void run()Checks for a newer unsigned update and reports the outcome to the manager.- Specified by:
runin interfaceRunnable- Overrides:
runin classUpdateRunner
fetchUnsignedHead
private boolean fetchUnsignedHead()HEAD the update url, and if the last-mod time is newer than the last update we downloaded, as stored in the properties, then we download it using eepget.- Returns:
- true if the HEAD request succeeded, false if there is no URL or the request failed