public abstract class TusExecutor
extends java.lang.Object
TusExecutor executor = new TusExecutor() {
{@literal @}Override
protected void makeAttempt() throws ProtocolException, IOException {
TusUploader uploader = client.resumeOrCreateUpload(upload);
while(uploader.uploadChunk() > -1) {}
uploader.finish();
}
};
executor.makeAttempts();
The retries are basically just calling the makeAttempt()
method which should then
retrieve an TusUploader
using TusClient.resumeOrCreateUpload(TusUpload)
and then
invoke TusUploader.uploadChunk()
as long as possible without catching
ProtocolException
s or IOException
s as this is taken over by this class.
The current attempt can be interrupted using Thread.interrupt()
which will cause the
makeAttempts()
method to return false
immediately.Constructor and Description |
---|
TusExecutor() |
Modifier and Type | Method and Description |
---|---|
int[] |
getDelays()
Get the delays which will be used for waiting before attempting retries.
|
protected abstract void |
makeAttempt()
This method must be implemented by the specific caller.
|
boolean |
makeAttempts()
This method is basically just calling the
makeAttempt() method which should then
retrieve an TusUploader using TusClient.resumeOrCreateUpload(TusUpload) and then
invoke TusUploader.uploadChunk() as long as possible without catching
ProtocolException s or IOException s as this is taken over by this class. |
void |
setDelays(int[] delays)
Set the delays at which TusExecutor will issue a retry if
makeAttempt() throws an
exception. |
public void setDelays(int[] delays)
makeAttempt()
throws an
exception. If the methods call fails for the first time it will wait delays[0]
ms
before calling it again. If this second calls also does not return normally
delays[1]
ms will be waited on so on.
It total delays.length
retries may be issued, resulting in up to
delays.length + 1
calls to makeAttempt()
.
The default delays are set to 500ms, 1s, 2s and 3s.delays
- The desired delay values to be usedgetDelays()
public int[] getDelays()
setDelays(int[])
public boolean makeAttempts() throws ProtocolException, java.io.IOException
makeAttempt()
method which should then
retrieve an TusUploader
using TusClient.resumeOrCreateUpload(TusUpload)
and then
invoke TusUploader.uploadChunk()
as long as possible without catching
ProtocolException
s or IOException
s as this is taken over by this class.
The current attempt can be interrupted using Thread.interrupt()
which will cause the
method to return false
immediately.true
if the makeAttempt()
method returned normally and
false
if the thread was interrupted while sleeping until the next attempt.ProtocolException
java.io.IOException
protected abstract void makeAttempt() throws ProtocolException, java.io.IOException
makeAttempts()
method.
A proper implementation should retrieve an TusUploader
using
TusClient.resumeOrCreateUpload(TusUpload)
and then invoke
TusUploader.uploadChunk()
as long as possible without catching
ProtocolException
s or IOException
s as this is taken over by this class.ProtocolException
java.io.IOException