Package net.i2p.router.update
Class UpdateRunner
java.lang.Object
java.lang.Thread
net.i2p.util.I2PThread
net.i2p.util.I2PAppThread
net.i2p.router.update.UpdateRunner
- All Implemented Interfaces:
Runnable
,UpdateTask
,EepGet.StatusListener
- Direct Known Subclasses:
DevSU3UpdateChecker
,DevSU3UpdateRunner
,NewsFetcher
,PluginUpdateChecker
,PluginUpdateRunner
,UnsignedUpdateChecker
,UnsignedUpdateRunner
The downloader for router signed updates,
and the base class for all the other Checkers and Runners.
- Since:
- 0.9.4 moved from UpdateHandler
-
Nested Class Summary
Nested classes/interfaces inherited from class net.i2p.util.I2PThread
I2PThread.OOMEventListener
Nested classes/interfaces inherited from class java.lang.Thread
Thread.BuilderPREVIEW, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ByteArrayOutputStream
56 byte header, only used for sudsprotected final RouterContext
protected URI
protected EepGet
protected boolean
tells the listeners what mode we are in - set to true in extending classes for checksprotected boolean
protected final Log
protected final UpdateMethod
protected final ConsoleUpdateManager
protected String
set by the listeners on completionprotected final UpdateType
protected final String
protected static final long
protected boolean
protected static final long
protected static final long
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptionUpdateRunner
(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, List<URI> uris) Uses router version for partial checksUpdateRunner
(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, List<URI> uris, String currentVersion) UpdateRunner
(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, UpdateMethod method, List<URI> uris) Uses router version for partial checksUpdateRunner
(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, UpdateMethod method, List<URI> uris, String currentVersion) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
translate a stringprotected String
translate a string with a parametervoid
attemptFailed
(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) void
attempting
(String url) void
bytesTransferred
(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) subclasses should overridegetID()
Valid for pluginsgetType()
getURI()
The current URI being checked or downloaded from.void
headerReceived
(String url, int attemptNum, String key, String val) Note: Headers are not processed, and this is not called, for most error response codes, unless setWriteErrorToOutput() is called before fetch().boolean
protected static String
void
run()
void
shutdown()
toString()
void
transferComplete
(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) subclasses should overridevoid
transferFailed
(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) subclasses should overrideprotected void
update()
Loop through the entire list of update URLs.protected void
Methods inherited from class net.i2p.util.I2PAppThread
addOOMEventThreadListener, fireOOM, removeOOMEventThreadListener
Methods inherited from class net.i2p.util.I2PThread
addOOMEventListener, removeOOMEventListener, start
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, startVirtualThread, stop, suspend, threadId, yield
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.i2p.update.UpdateTask
start
-
Field Details
-
_context
-
_log
-
_mgr
-
_type
-
_method
-
_urls
-
_updateFile
-
_isRunning
protected volatile boolean _isRunning -
done
protected boolean done -
_get
-
_isPartial
protected boolean _isPartialtells the listeners what mode we are in - set to true in extending classes for checks -
_newVersion
set by the listeners on completion -
_baos
56 byte header, only used for suds -
_currentURI
-
CONNECT_TIMEOUT
protected static final long CONNECT_TIMEOUT- See Also:
-
INACTIVITY_TIMEOUT
protected static final long INACTIVITY_TIMEOUT- See Also:
-
NOPROXY_INACTIVITY_TIMEOUT
protected static final long NOPROXY_INACTIVITY_TIMEOUT- See Also:
-
-
Constructor Details
-
UpdateRunner
Uses router version for partial checks -
UpdateRunner
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, UpdateMethod method, List<URI> uris) Uses router version for partial checks- Since:
- 0.9.9
-
UpdateRunner
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, List<URI> uris, String currentVersion) - Parameters:
currentVersion
- used for partial checks- Since:
- 0.9.7
-
UpdateRunner
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, UpdateMethod method, List<URI> uris, String currentVersion) - Parameters:
method
- HTTP, HTTP_CLEARNET, or HTTPS_CLEARNETcurrentVersion
- used for partial checks- Since:
- 0.9.9
-
-
Method Details
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceUpdateTask
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceUpdateTask
-
getType
- Specified by:
getType
in interfaceUpdateTask
-
getMethod
- Specified by:
getMethod
in interfaceUpdateTask
-
getURI
Description copied from interface:UpdateTask
The current URI being checked or downloaded from. Can change if there are multiple URIs to try.- Specified by:
getURI
in interfaceUpdateTask
-
getID
Description copied from interface:UpdateTask
Valid for plugins- Specified by:
getID
in interfaceUpdateTask
-
run
public void run() -
update
protected void update()Loop 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. -
attemptFailed
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) - Specified by:
attemptFailed
in interfaceEepGet.StatusListener
- See Also:
-
bytesTransferred
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) subclasses should override- Specified by:
bytesTransferred
in interfaceEepGet.StatusListener
- 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 length
-
transferComplete
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) subclasses should override- Specified by:
transferComplete
in interfaceEepGet.StatusListener
- Parameters:
outputFile
- null if unknown (output stream constructor)- See Also:
-
transferFailed
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) subclasses should override- Specified by:
transferFailed
in interfaceEepGet.StatusListener
- See Also:
-
headerReceived
Description copied from interface:EepGet.StatusListener
Note: Headers are not processed, and this is not called, for most error response codes, unless setWriteErrorToOutput() is called before fetch(). To be changed?- Specified by:
headerReceived
in interfaceEepGet.StatusListener
-
attempting
- Specified by:
attempting
in interfaceEepGet.StatusListener
-
updateStatus
-
linkify
-
_t
translate a string -
_t
translate a string with a parameter -
toString
-