Package com.amazonaws.event
Class SDKProgressPublisher
- java.lang.Object
-
- com.amazonaws.event.SDKProgressPublisher
-
public class SDKProgressPublisher extends Object
This class is responsible for executing the callback method of ProgressListener; listener callbacks are executed sequentially in a separate single thread.
-
-
Constructor Summary
Constructors Constructor Description SDKProgressPublisher()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static ExecutorService
getExecutorService()
Returns the executor service used for performing the callbacks.static Future<?>
publishProgress(ProgressListener listener, ProgressEventType type)
Used to deliver a progress event to the given listener.static Future<?>
publishRequestBytesTransferred(ProgressListener listener, long bytes)
Convenient method to publish a request byte transfer event to the given listener.static Future<?>
publishRequestContentLength(ProgressListener listener, long bytes)
Convenient method to publish a request content length event to the given listener.static Future<?>
publishRequestReset(ProgressListener listener, long bytesReset)
Convenient method to publish a request reset event to the given listener.static Future<?>
publishResponseBytesDiscarded(ProgressListener listener, long bytesDiscarded)
Convenient method to publish a response bytes discard event to the given listener.static Future<?>
publishResponseBytesTransferred(ProgressListener listener, long bytes)
Convenient method to publish a response byte transfer event to the given listener.static Future<?>
publishResponseContentLength(ProgressListener listener, long bytes)
Convenient method to publish a response content length event to the given listener.static Future<?>
publishResponseReset(ProgressListener listener, long bytesReset)
Convenient method to publish a response reset event to the given listener.protected static Future<?>
setLatestFutureTask(Future<?> f)
static void
shutdown(boolean now)
Can be used to shutdown the (legacy) executor.static void
waitTillCompletion()
Deprecated.
-
-
-
Method Detail
-
publishProgress
public static Future<?> publishProgress(ProgressListener listener, ProgressEventType type)
Used to deliver a progress event to the given listener.- Returns:
- the future of a submitted task; or null if the delivery is synchronous with no future task involved. Note a listener should never block, and therefore returning null is the typical case.
-
publishRequestContentLength
public static Future<?> publishRequestContentLength(ProgressListener listener, long bytes)
Convenient method to publish a request content length event to the given listener.- Parameters:
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skipped
-
publishResponseContentLength
public static Future<?> publishResponseContentLength(ProgressListener listener, long bytes)
Convenient method to publish a response content length event to the given listener.- Parameters:
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skipped
-
publishRequestBytesTransferred
public static Future<?> publishRequestBytesTransferred(ProgressListener listener, long bytes)
Convenient method to publish a request byte transfer event to the given listener.- Parameters:
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skipped
-
publishResponseBytesTransferred
public static Future<?> publishResponseBytesTransferred(ProgressListener listener, long bytes)
Convenient method to publish a response byte transfer event to the given listener.- Parameters:
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skipped
-
publishRequestReset
public static Future<?> publishRequestReset(ProgressListener listener, long bytesReset)
Convenient method to publish a request reset event to the given listener.- Parameters:
listener
- must not be null or else the publication will be skippedbytesReset
- must be non-negative or else the publication will be skipped
-
publishResponseReset
public static Future<?> publishResponseReset(ProgressListener listener, long bytesReset)
Convenient method to publish a response reset event to the given listener.
-
publishResponseBytesDiscarded
public static Future<?> publishResponseBytesDiscarded(ProgressListener listener, long bytesDiscarded)
Convenient method to publish a response bytes discard event to the given listener.
-
getExecutorService
protected static ExecutorService getExecutorService()
Returns the executor service used for performing the callbacks.
-
waitTillCompletion
@Deprecated public static void waitTillCompletion() throws InterruptedException, ExecutionException
Deprecated.For internal testing and backward compatibility only. This method blocks until all the submitted callbacks are executed. Listeners should never block so this method should never be used.
-
shutdown
public static void shutdown(boolean now)
Can be used to shutdown the (legacy) executor.However, the recommended best practice is to always make use of progress listeners that are short-lived (ie do not block) and are subclasses of either
SyncProgressListener
orS3SyncProgressListener
. That way, the progress publisher (legacy) thread will never be activated in the first place.- Parameters:
now
- true if shutdown now; false otherwise.
-
-