public abstract class AbstractRemoteMetadataSource extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Exception |
error |
protected Map<Class,List<SourceExceptionHandler>> |
exceptionHandlersMap |
protected long |
interRequestTime |
protected long |
lastRequest |
protected ReentrantLock |
lock |
protected int |
maxRetry |
protected String |
operationId |
protected int |
retry |
protected String |
warning |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRemoteMetadataSource()
Constructs an empty MetadataSource class object and initializes the Exceptionhandlers
|
| Modifier and Type | Method and Description |
|---|---|
Exception |
getError()
Retrieve the last encountered exception
|
protected List<SourceExceptionHandler> |
getExceptionHandler(Exception exception)
Retrieve a list of SourceExceptionHandler objects that have an instanceof the exception configured to them.
|
int |
getMaxRetry()
Return the number of max retries that can be undertaken before separate functionality kicks in
|
String |
getOperationId()
Retrieve the operationId
|
int |
getRetry()
Return the number of retries that have currently been undertaken
|
String |
getWarning()
Return the warning message used for logging during exception catching
|
protected void |
handleException(int retry,
Exception exception,
String operationId)
Handles a given exception or throws on a
MetadataSourceException if no ExceptionHandler is set |
abstract void |
init()
Attempts to init a session
|
protected void |
initExceptionHandlers()
initialize the exceptionHandlersMap with an empty
LinkedHashMap |
protected <T> T |
retry(Callable<T> callable)
Command pattern implementation.
|
void |
setError(Exception error)
Set the last encountered error
|
void |
setMaxRetry(int maxRetry)
Set the number of maximum retries before throwing on the exception
|
void |
setWarning(String warning)
Set the warning message used for logging
|
protected void |
throwSourceException(int retry,
Exception exception,
String operationId)
Throw a
MetadataSourceException |
protected void |
throwSourceExceptionHook()
A specified point where methods can be specified or callbacks can be executed
|
protected long lastRequest
protected long interRequestTime
protected ReentrantLock lock
protected int maxRetry
protected int retry
protected String operationId
protected String warning
protected Map<Class,List<SourceExceptionHandler>> exceptionHandlersMap
protected Exception error
protected AbstractRemoteMetadataSource()
protected void initExceptionHandlers()
LinkedHashMappublic String getWarning()
public void setWarning(String warning)
warning - public int getRetry()
public int getMaxRetry()
public void setMaxRetry(int maxRetry)
maxRetry - public String getOperationId()
public Exception getError()
public void setError(Exception error)
error - protected <T> T retry(Callable<T> callable) throws MetadataSourceException
T - return type. Generics for type safety.callable - the callable to call. See the classes with the same name as
the public methods of this class.MetadataSourceException - if something unrecoverable happens (e.g. network failures)protected void handleException(int retry,
Exception exception,
String operationId)
throws MetadataSourceException
MetadataSourceException if no ExceptionHandler is setretry - The number of retries before the exception was thrown onexception - The exception to handleoperationId - The id of the operation that threw the exceptionMetadataSourceException - if no ExceptionHandler is configured for the given exceptionprotected List<SourceExceptionHandler> getExceptionHandler(Exception exception)
exception - The exception to base the retrieval of SourceExceptionHandler onSourceExceptionHandler objectsprotected void throwSourceException(int retry,
Exception exception,
String operationId)
throws MetadataSourceException
MetadataSourceExceptionretry - The number of retries before the exception was thrown onexception - The exception to throwoperationId - The id of the operation that threw the exceptionMetadataSourceExceptionprotected void throwSourceExceptionHook()
Copyright © 2016 DuraSpace. All rights reserved.