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
class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusListener
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.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected ByteArrayOutputStream_baos56 byte header, only used for sudsprotected RouterContext_contextprotected URI_currentURIprotected EepGet_getprotected boolean_isPartialtells the listeners what mode we are in - set to true in extending classes for checksprotected boolean_isRunningprotected Log_logprotected UpdateMethod_methodprotected ConsoleUpdateManager_mgrprotected String_newVersionset by the listeners on completionprotected UpdateType_typeprotected String_updateFileprotected List<URI>_urlsprotected static longCONNECT_TIMEOUTprotected booleandoneprotected static longINACTIVITY_TIMEOUTprotected static longNOPROXY_INACTIVITY_TIMEOUT-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description UpdateRunner(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String_t(String s)translate a stringprotected String_t(String s, Object o)translate a string with a parametervoidattemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause)voidattempting(String url)voidbytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url)subclasses should overrideStringgetID()Valid for pluginsUpdateMethodgetMethod()UpdateTypegetType()URIgetURI()The current URI being checked or downloaded from.voidheaderReceived(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().booleanisRunning()protected static Stringlinkify(String url)voidrun()voidshutdown()StringtoString()voidtransferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified)subclasses should overridevoidtransferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt)subclasses should overrideprotected voidupdate()Loop through the entire list of update URLs.protected voidupdateStatus(String s)-
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, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, suspend, 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 Detail
-
_context
protected final RouterContext _context
-
_log
protected final Log _log
-
_mgr
protected final ConsoleUpdateManager _mgr
-
_type
protected final UpdateType _type
-
_method
protected final UpdateMethod _method
-
_updateFile
protected final String _updateFile
-
_isRunning
protected volatile boolean _isRunning
-
done
protected boolean done
-
_get
protected EepGet _get
-
_isPartial
protected boolean _isPartial
tells the listeners what mode we are in - set to true in extending classes for checks
-
_newVersion
protected String _newVersion
set by the listeners on completion
-
_baos
protected final ByteArrayOutputStream _baos
56 byte header, only used for suds
-
_currentURI
protected URI _currentURI
-
CONNECT_TIMEOUT
protected static final long CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
INACTIVITY_TIMEOUT
protected static final long INACTIVITY_TIMEOUT
- See Also:
- Constant Field Values
-
NOPROXY_INACTIVITY_TIMEOUT
protected static final long NOPROXY_INACTIVITY_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UpdateRunner
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, List<URI> uris)
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 Detail
-
isRunning
public boolean isRunning()
- Specified by:
isRunningin interfaceUpdateTask
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceUpdateTask
-
getType
public UpdateType getType()
- Specified by:
getTypein interfaceUpdateTask
-
getMethod
public UpdateMethod getMethod()
- Specified by:
getMethodin interfaceUpdateTask
-
getURI
public URI getURI()
Description copied from interface:UpdateTaskThe current URI being checked or downloaded from. Can change if there are multiple URIs to try.- Specified by:
getURIin interfaceUpdateTask
-
getID
public String getID()
Description copied from interface:UpdateTaskValid for plugins- Specified by:
getIDin interfaceUpdateTask
-
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:
attemptFailedin interfaceEepGet.StatusListener- See Also:
EepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)
-
bytesTransferred
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url)subclasses should override- Specified by:
bytesTransferredin 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:
transferCompletein interfaceEepGet.StatusListeneroutputFile- null if unknown (output stream constructor)- See Also:
EepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)
-
transferFailed
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt)
subclasses should override- Specified by:
transferFailedin interfaceEepGet.StatusListener- See Also:
EepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)
-
headerReceived
public void headerReceived(String url, int attemptNum, String key, String val)
Description copied from interface:EepGet.StatusListenerNote: 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:
headerReceivedin interfaceEepGet.StatusListener
-
attempting
public void attempting(String url)
- Specified by:
attemptingin interfaceEepGet.StatusListener
-
updateStatus
protected void updateStatus(String s)
-
-