class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusListener
I2PThread.OOMEventListenerThread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected ByteArrayOutputStream | _baos56 byte header, only used for suds |
protected RouterContext | _contextrouter context |
protected URI | _currentURIcurrent URI being fetched |
protected EepGet | _getthe current EepGet instance |
protected boolean | _isPartialtells the listeners what mode we are in - set to true in extending classes for checks |
protected boolean | _isRunningwhether the runner is currently running |
protected Log | _logClass logger. |
protected UpdateMethod | _methodupdate method |
protected ConsoleUpdateManager | _mgrupdate manager |
protected String | _newVersionset by the listeners on completion |
protected UpdateType | _typeupdate type |
protected String | _updateFiletemporary file for the update download |
protected List<URI> | _urlslist of update URIs |
protected static long | CONNECT_TIMEOUTconnect timeout in ms |
protected boolean | donewhether the update completed |
protected static long | INACTIVITY_TIMEOUTinactivity timeout with proxy in ms |
protected static long | NOPROXY_INACTIVITY_TIMEOUTinactivity timeout without proxy in ms |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
UpdateRunner(RouterContext ctx,
ConsoleUpdateManager mgr,
UpdateType type,
List<URI> uris)Uses router version for partial checks |
UpdateRunner(RouterContext ctx,
ConsoleUpdateManager mgr,
UpdateType type,
List<URI> uris,
String currentVersion)Constructor with explicit current version. |
UpdateRunner(RouterContext ctx,
ConsoleUpdateManager mgr,
UpdateType type,
UpdateMethod method,
List<URI> uris)Uses router version for partial checks |
UpdateRunner(RouterContext ctx,
ConsoleUpdateManager mgr,
UpdateType type,
UpdateMethod method,
List<URI> uris,
String currentVersion)Full constructor. |
| Modifier and Type | Method and Description |
|---|---|
protected String | _t(String s)translate a string |
protected String | _t(String s,
Object o)translate a string with a parameter |
void | attemptFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt,
int numRetries,
Exception cause)attemptFailed. |
void | attempting(String url)attempting. |
void | bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)subclasses should override |
String | getID()I d. |
UpdateMethod | getMethod()Method. |
UpdateType | getType()Type. |
URI | getURI()U r i. |
void | headerReceived(String url,
int attemptNum,
String key,
String val)headerReceived. |
boolean | isRunning()Whether running. |
protected static String | linkify(String url)linkify. |
void | run()run. |
void | shutdown()shutdown. |
String | toString()toString. |
void | transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)subclasses should override |
void | transferFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt)subclasses should override |
protected void | update()Loop through the entire list of update URLs. |
protected void | updateStatus(String s)updateStatus. |
addOOMEventThreadListener, fireOOM, removeOOMEventThreadListeneraddOOMEventListener, removeOOMEventListener, startactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, yieldequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitstartprotected final ByteArrayOutputStream _baos
protected final RouterContext _context
protected URI _currentURI
protected EepGet _get
protected boolean _isPartial
protected volatile boolean _isRunning
protected final Log _log
protected final UpdateMethod _method
protected final ConsoleUpdateManager _mgr
protected String _newVersion
protected final UpdateType _type
protected final String _updateFile
protected static final long CONNECT_TIMEOUT
protected boolean done
protected static final long INACTIVITY_TIMEOUT
protected static final long NOPROXY_INACTIVITY_TIMEOUT
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, List<URI> uris)
ctx - router contextmgr - update managertype - update typeuris - list of update URIspublic UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, List<URI> uris, String currentVersion)
ctx - router contextmgr - update managertype - update typeuris - list of update URIscurrentVersion - used for partial checkspublic UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, UpdateMethod method, List<URI> uris)
ctx - router contextmgr - update managertype - update typemethod - update methoduris - list of update URIspublic UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, UpdateType type, UpdateMethod method, List<URI> uris, String currentVersion)
ctx - router contextmgr - update managertype - update typemethod - HTTP, HTTP_CLEARNET, or HTTPS_CLEARNETuris - list of update URIscurrentVersion - used for partial checkspublic void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause)
attemptFailed in interface EepGet.StatusListenerurl - the URLbytesTransferred - total transferredbytesRemaining - remainingcurrentAttempt - attempt indexnumRetries - retry limitcause - failure causeEepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)public void attempting(String url)
attempting in interface EepGet.StatusListenerurl - the URL being attemptedpublic void bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)bytesTransferred in interface EepGet.StatusListeneralreadyTransferred - 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 fetchedpublic String getID()
getID in interface UpdateTaskpublic UpdateMethod getMethod()
getMethod in interface UpdateTaskpublic UpdateType getType()
getType in interface UpdateTaskpublic URI getURI()
getURI in interface UpdateTaskpublic void headerReceived(String url, int attemptNum, String key, String val)
headerReceived in interface EepGet.StatusListenerurl - the URLattemptNum - attempt indexkey - header keyval - header valuepublic boolean isRunning()
isRunning in interface UpdateTaskpublic void shutdown()
shutdown in interface UpdateTaskpublic void transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)transferComplete in interface EepGet.StatusListeneralreadyTransferred - total bytes transferredbytesTransferred - total incl headersbytesRemaining - remaining bytesurl - the URLoutputFile - null if unknown (output stream constructor)notModified - whether 304EepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt)
transferFailed in interface EepGet.StatusListenerurl - the URLbytesTransferred - total transferredbytesRemaining - remainingcurrentAttempt - attempt indexEepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)protected void update()
protected void updateStatus(String s)