Package com.amazonaws.event
Class SDKProgressPublisher
java.lang.Object
com.amazonaws.event.SDKProgressPublisher
This class is responsible for executing the callback method of
ProgressListener; listener callbacks are executed sequentially in a separate
single thread.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static ExecutorService
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
Deprecated.
-
Constructor Details
-
SDKProgressPublisher
public SDKProgressPublisher()
-
-
Method Details
-
publishProgress
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
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
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
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
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
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
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
Returns the executor service used for performing the callbacks. -
setLatestFutureTask
-
waitTillCompletion
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.
-