public final class OperationContext extends Object
Modifier and Type | Field and Description |
---|---|
static String |
defaultLoggerName
Name of the
Logger that will be created by default if logging is enabled and a
Logger has not been specified. |
Constructor and Description |
---|
OperationContext()
Creates an instance of the
OperationContext class. |
Modifier and Type | Method and Description |
---|---|
void |
appendRequestResult(RequestResult requestResult)
Reserved for internal use.
|
String |
getClientRequestID()
Gets the client side trace ID.
|
long |
getClientTimeInMs()
Gets the operation latency, in milliseconds, from the client's perspective.
|
static Proxy |
getDefaultProxy()
Gets the default proxy used by the client library if enabled.
|
StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> |
getErrorReceivingResponseEventHandler()
Gets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.
|
static StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> |
getGlobalErrorReceivingResponseEventHandler()
Gets a global event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.
|
static StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> |
getGlobalRequestCompletedEventHandler()
Gets a global event multi-caster that is triggered when a request is completed.
|
static StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> |
getGlobalResponseReceivedEventHandler()
Gets a global event multi-caster that is triggered when a response is received.
|
static StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> |
getGlobalRetryingEventHandler()
Gets a global event multi-caster that is triggered when a request is retried.
|
static StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> |
getGlobalSendingRequestEventHandler()
Gets a global event multi-caster that is triggered before sending a request.
|
RequestResult |
getLastResult()
Gets the last request result encountered for the operation.
|
org.slf4j.Logger |
getLogger()
Gets the
Logger associated with this operation. |
Proxy |
getProxy()
Gets a proxy which will be used when making a request.
|
StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> |
getRequestCompletedEventHandler()
Gets an event multi-caster that is triggered when a request is completed.
|
ArrayList<RequestResult> |
getRequestResults()
Returns the set of request results that the current operation has created.
|
StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> |
getResponseReceivedEventHandler()
Gets an event multi-caster that is triggered when a response is received.
|
StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> |
getRetryingEventHandler()
Gets an event multi-caster that is triggered when a request is retried.
|
StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> |
getSendingRequestEventHandler()
Gets an event multi-caster that is triggered before sending a request.
|
HashMap<String,String> |
getUserHeaders()
Gets any additional headers for the request, for example, for proxy or logging information.
|
void |
initialize()
Reserved for internal use.
|
boolean |
isLoggingEnabled()
Indicates whether log entries will be produced for this request.
|
static boolean |
isLoggingEnabledByDefault()
Indicates whether the client library should produce log entries by default.
|
void |
setClientRequestID(String clientRequestID)
Sets the client side request ID.
|
void |
setClientTimeInMs(long clientTimeInMs)
Reserved for internal use.
|
static void |
setDefaultProxy(Proxy defaultProxy)
Specifies the proxy the client library should use by default.
|
void |
setErrorReceivingResponseEventHandler(StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> errorReceivingResponseEventHandler)
Sets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.
|
static void |
setGlobalErrorReceivingResponseEventHandler(StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> globalErrorReceivingResponseEventHandler)
Sets a global event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.
|
static void |
setGlobalRequestCompletedEventHandler(StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> globalRequestCompletedEventHandler)
Sets a global event multi-caster that is triggered when a request is completed.
|
static void |
setGlobalResponseReceivedEventHandler(StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> globalResponseReceivedEventHandler)
Sets a global event multi-caster that is triggered when a response is received.
|
static void |
setGlobalRetryingEventHandler(StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> globalRetryingEventHandler)
Sets a global event multi-caster that is triggered when a request is retried.
|
static void |
setGlobalSendingRequestEventHandler(StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> globalSendingRequestEventHandler)
Sets a global event multi-caster that is triggered before sending a request.
|
void |
setLogger(org.slf4j.Logger logger)
Sets the
Logger for this operation. |
void |
setLoggingEnabled(boolean loggingEnabled)
Specifies whether log entries will be produced for this request.
|
static void |
setLoggingEnabledByDefault(boolean enableLoggingByDefault)
Specifies whether the client library should produce log entries by default.
|
void |
setProxy(Proxy proxy)
Sets a proxy which will be used when making a request.
|
void |
setRequestCompletedEventHandler(StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> requestCompletedEventHandler)
Sets an event multi-caster that is triggered when a request is completed.
|
void |
setResponseReceivedEventHandler(StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> responseReceivedEventHandler)
Sets an event multi-caster that is triggered when a response is received.
|
void |
setRetryingEventHandler(StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> retryingEventHandler)
Sets an event multi-caster that is triggered when a request is retried.
|
void |
setSendingRequestEventHandler(StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> sendingRequestEventHandler)
Sets an event multi-caster that is triggered before sending a request.
|
void |
setUserHeaders(HashMap<String,String> userHeaders)
Sets any additional headers for the request, for example, for proxy or logging information.
|
public static final String defaultLoggerName
Logger
that will be created by default if logging is enabled and a
Logger
has not been specified.public OperationContext()
OperationContext
class.public String getClientRequestID()
String which represents the client request ID.
public long getClientTimeInMs()
long
which contains the client latency time in milliseconds.public RequestResult getLastResult()
RequestResult
object which represents the last request result.public org.slf4j.Logger getLogger()
Logger
associated with this operation. If the Logger
object
associated with this operation is null, this will return the class's default Logger
object.Logger
object associated with this operation,
or the class's default Logger
if null.public Proxy getProxy()
null
. To set a proxy to use by
default, use setDefaultProxy(java.net.Proxy)
Proxy
to use when making a request.public HashMap<String,String> getUserHeaders()
java.util.HashMap
which contains the the user headers for the request.public ArrayList<RequestResult> getRequestResults()
ArrayList
object that contains RequestResult
objects that represent
the request results created by the current operation.public void appendRequestResult(RequestResult requestResult)
RequestResult
object to the internal collection in a synchronized
manner.requestResult
- A RequestResult
to append.public static StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> getGlobalSendingRequestEventHandler()
StorageEventMultiCaster
object for the globalSendingRequestEventHandler
.public static StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> getGlobalResponseReceivedEventHandler()
StorageEventMultiCaster
object for the globalResponseReceivedEventHandler
.public static StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> getGlobalErrorReceivingResponseEventHandler()
StorageEventMultiCaster
object for the globabErrorReceivingResponseEventHandler
.public static StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> getGlobalRequestCompletedEventHandler()
StorageEventMultiCaster
object for the globalRequestCompletedEventHandler
.public static StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> getGlobalRetryingEventHandler()
StorageEventMultiCaster
object for the globalRetryingEventHandler
.public StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> getSendingRequestEventHandler()
StorageEventMultiCaster
object for the sendingRequestEventHandler
.public StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> getResponseReceivedEventHandler()
StorageEventMultiCaster
object for the responseReceivedEventHandler
.public StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> getErrorReceivingResponseEventHandler()
StorageEventMultiCaster
object for the errorReceivingResponseEventHandler
.public StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> getRequestCompletedEventHandler()
StorageEventMultiCaster
object for the requestCompletedEventHandler
.public StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> getRetryingEventHandler()
StorageEventMultiCaster
object for the retryingEventHandler
.public void initialize()
OperationContext
in order to begin processing a
new operation. All operation specific information is erased.public boolean isLoggingEnabled()
true
if logging is enabled; otherwise false
.public void setClientRequestID(String clientRequestID)
clientRequestID
- A String
which contains the client request ID to set.public void setClientTimeInMs(long clientTimeInMs)
clientTimeInMs
- A long
which contains the client operation latency in milliseconds.public void setLogger(org.slf4j.Logger logger)
Logger
for this operation.logger
- The Logger
to use for this operation.public void setProxy(Proxy proxy)
null
. To set a proxy to use by
default, use setDefaultProxy(java.net.Proxy)
proxy
- A Proxy
to use when making a request.public void setUserHeaders(HashMap<String,String> userHeaders)
userHeaders
- A java.util.HashMap
which contains any additional headers to set.public void setLoggingEnabled(boolean loggingEnabled)
loggingEnabled
- true
to enable logging; otherwise false
to disable logging.public static void setGlobalSendingRequestEventHandler(StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> globalSendingRequestEventHandler)
globalSendingRequestEventHandler
- The StorageEventMultiCaster
object to set for the globalSendingRequestEventHandler
.public static void setGlobalResponseReceivedEventHandler(StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> globalResponseReceivedEventHandler)
globalResponseReceivedEventHandler
- The StorageEventMultiCaster
object to set for the globalResponseReceivedEventHandler
.public static void setGlobalErrorReceivingResponseEventHandler(StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> globalErrorReceivingResponseEventHandler)
globalErrorReceivingResponseEventHandler
- The StorageEventMultiCaster
object to set for the globalErrorReceivingResponseEventHandler
.public static void setGlobalRequestCompletedEventHandler(StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> globalRequestCompletedEventHandler)
globalRequestCompletedEventHandler
- The StorageEventMultiCaster
object to set for the globalRequestCompletedEventHandler
.public static void setGlobalRetryingEventHandler(StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> globalRetryingEventHandler)
globalRetryingEventHandler
- The StorageEventMultiCaster
object to set for the globalRetryingEventHandler
.public void setSendingRequestEventHandler(StorageEventMultiCaster<SendingRequestEvent,StorageEvent<SendingRequestEvent>> sendingRequestEventHandler)
sendingRequestEventHandler
- The StorageEventMultiCaster
object to set for the sendingRequestEventHandler
.public void setResponseReceivedEventHandler(StorageEventMultiCaster<ResponseReceivedEvent,StorageEvent<ResponseReceivedEvent>> responseReceivedEventHandler)
responseReceivedEventHandler
- The StorageEventMultiCaster
object to set for the responseReceivedEventHandler
.public void setErrorReceivingResponseEventHandler(StorageEventMultiCaster<ErrorReceivingResponseEvent,StorageEvent<ErrorReceivingResponseEvent>> errorReceivingResponseEventHandler)
errorReceivingResponseEventHandler
- The StorageEventMultiCaster
object to set for the errorReceivingResponseEventHandler
.public void setRequestCompletedEventHandler(StorageEventMultiCaster<RequestCompletedEvent,StorageEvent<RequestCompletedEvent>> requestCompletedEventHandler)
requestCompletedEventHandler
- The StorageEventMultiCaster
object to set for the requestCompletedEventHandler
.public void setRetryingEventHandler(StorageEventMultiCaster<RetryingEvent,StorageEvent<RetryingEvent>> retryingEventHandler)
retryingEventHandler
- The StorageEventMultiCaster
object to set for the retryingEventHandler
.public static boolean isLoggingEnabledByDefault()
setLoggingEnabled(boolean)
.true
if logging is enabled by default; otherwise false
.public static void setLoggingEnabledByDefault(boolean enableLoggingByDefault)
setLoggingEnabled(boolean)
.enableLoggingByDefault
- true
if logging should be enabled by default; otherwise false
if logging should
be disabled by default.public static Proxy getDefaultProxy()
setProxy(java.net.Proxy)
.Proxy
if set; otherwise null
public static void setDefaultProxy(Proxy defaultProxy)
setProxy(java.net.Proxy)
.defaultProxy
- The Proxy
to use by default, or null
to not use a proxy.Copyright © 2019. All rights reserved.