java.lang.Object
java.lang.Thread
net.i2p.util.I2PThread
net.i2p.util.I2PAppThread
net.i2p.router.update.UpdateRunner
net.i2p.router.update.DevSU3UpdateChecker
- All Implemented Interfaces:
Runnable, UpdateTask, EepGet.StatusListener
Check for an updated su3 version.
Take the update URL then fetch the first 56 bytes of the URL, extract the version, and compare to current full router version.
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
Fields 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
ConstructorsConstructorDescriptionDevSU3UpdateChecker(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris) Registers the check as a partial dev SU3 update and adopts the first URI.Method Summary
Public MethodsModifier and TypeMethodDescriptionvoidbytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) Subclasses should override.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.Methods inherited from class UpdateRunner
_t, _t, attemptFailed, attempting, getID, getMethod, getType, getURI, headerReceived, isRunning, linkify, run, shutdown, toString, 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.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.voidrun()Runs the update, reporting any failure to the update manager.voidshutdown()Clears the running flag and interrupts any update in progress.toString()Handler summary for log messages.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
Constructor Details
DevSU3UpdateChecker
Registers the check as a partial dev SU3 update and adopts the first URI.- Parameters:
ctx- the router contextmgr- the update manageruris- list of update URIs
Method Details
update
protected void update()Description copied from class:UpdateRunnerLoop through the entire list of update URLs. For each one, first get the version from the first 56 bytes and see if it is newer than what we are running now. If it is, get the whole thing.- Overrides:
updatein classUpdateRunner
bytesTransferred
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) Description copied from class:UpdateRunnerSubclasses should override.- Specified by:
bytesTransferredin interfaceEepGet.StatusListener- Overrides:
bytesTransferredin classUpdateRunner- Parameters:
alreadyTransferred- total of all attempts, not including currentWrite If nonzero on the first call, a partial file of that length was found, _and_ the server supports resume. If zero on a subsequent call after some bytes are transferred (and presumably after an attemptFailed), the server does _not_ support resume and we had to start over. To track _actual_ transfer if the output file could already exist, the listener should keep its own counter, or subtract the initial alreadyTransferred value. And watch out for alreadyTransferred resetting if a resume failed...currentWrite- since last call to the listenerbytesTransferred- includes headers, retries, redirects, discarded partial downloads, ...bytesRemaining- on this attempt only, currentWrite already subtracted - or -1 if chunked encoding or server does not return a lengthurl- the URL being fetched
transferComplete
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) Description copied from class:UpdateRunnerSubclasses should override.- Specified by:
transferCompletein interfaceEepGet.StatusListener- Overrides:
transferCompletein classUpdateRunner- Parameters:
alreadyTransferred- total bytes transferredbytesTransferred- total incl headersbytesRemaining- bytes still owed by the server, or -1 if chunked encoding or no Content-Length was returnedurl- the address the transfer was readingoutputFile- null if unknown (output stream constructor)notModified- whether 304- See Also:
transferFailed
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) Description copied from class:UpdateRunnerSubclasses should override.- Specified by:
transferFailedin interfaceEepGet.StatusListener- Overrides:
transferFailedin classUpdateRunner- Parameters:
url- the address whose transfer failedbytesTransferred- bytes received so far, counted across every attempt and including response headersbytesRemaining- bytes still owed, or -1 if unknowncurrentAttempt- zero-based index of the attempt that failed- See Also: