org.ldaptive.handler
Class AbstractRetryOperationExceptionHandler<Q extends Request,S>

java.lang.Object
  extended by org.ldaptive.handler.AbstractRetryOperationExceptionHandler<Q,S>
Type Parameters:
Q - type of ldap request
S - type of ldap response
All Implemented Interfaces:
Handler<Q,Response<S>>, OperationExceptionHandler<Q,S>
Direct Known Subclasses:
AbstractOperation.ReopenOperationExceptionHandler

public abstract class AbstractRetryOperationExceptionHandler<Q extends Request,S>
extends Object
implements OperationExceptionHandler<Q,S>

Provides common implementation for retrying after an operation exception.

Version:
$Revision: 2885 $ $Date: 2014-02-05 16:28:49 -0500 (Wed, 05 Feb 2014) $
Author:
Middleware Services

Field Summary
protected  org.slf4j.Logger logger
          Logger for this class.
 
Constructor Summary
AbstractRetryOperationExceptionHandler()
           
 
Method Summary
protected abstract  HandlerResult<Response<S>> createResult(Connection conn, Q request, Response<S> response)
          Invoked if handleInternal(org.ldaptive.Connection, Q, org.ldaptive.Response) succeeded.
 int getRetry()
          Returns the retry.
 int getRetryBackoff()
          Returns the retry backoff.
 long getRetryWait()
          Returns the retry wait.
 HandlerResult<Response<S>> handle(Connection conn, Q request, Response<S> response)
          Handle the supplied result.
protected abstract  void handleInternal(Connection conn, Q request, Response<S> response)
          Perform any operations required to recover from the operation exception.
protected  boolean retry(int count)
          Returns whether the supplied count indicates that the operation should be retried.
 void setRetry(int i)
          Sets the number of retries.
 void setRetryBackoff(int backoff)
          Sets the retry backoff.
 void setRetryWait(long time)
          Sets the retry wait.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger for this class.

Constructor Detail

AbstractRetryOperationExceptionHandler

public AbstractRetryOperationExceptionHandler()
Method Detail

getRetry

public int getRetry()
Returns the retry. This is the number of times the handler will retry when it fails.

Returns:
retry

setRetry

public void setRetry(int i)
Sets the number of retries.

Parameters:
i - to set

getRetryWait

public long getRetryWait()
Returns the retry wait. This is the amount of time in seconds that the executing thread will sleep before attempting to retry again.

Returns:
retry wait

setRetryWait

public void setRetryWait(long time)
Sets the retry wait. Time must be >= 0.

Parameters:
time - in seconds

getRetryBackoff

public int getRetryBackoff()
Returns the retry backoff. This is the factor by which the retry wait will be multiplied in order to progressively delay the amount of time between each retry.

Returns:
retry backoff

setRetryBackoff

public void setRetryBackoff(int backoff)
Sets the retry backoff.

Parameters:
backoff - to set

handle

public HandlerResult<Response<S>> handle(Connection conn,
                                         Q request,
                                         Response<S> response)
                                  throws LdapException
Handle the supplied result.

Specified by:
handle in interface Handler<Q extends Request,Response<S>>
Specified by:
handle in interface OperationExceptionHandler<Q extends Request,S>
Parameters:
conn - connection the operation was executed on
request - executed by the operation
response - produced from the operation
Returns:
handler result
Throws:
LdapException - if handling fails

handleInternal

protected abstract void handleInternal(Connection conn,
                                       Q request,
                                       Response<S> response)
                                throws LdapException
Perform any operations required to recover from the operation exception.

Parameters:
conn - connection the operation was executed on
request - executed by the operation
response - typically null
Throws:
LdapException - if the retry fails

createResult

protected abstract HandlerResult<Response<S>> createResult(Connection conn,
                                                           Q request,
                                                           Response<S> response)
                                                    throws LdapException
Invoked if handleInternal(org.ldaptive.Connection, Q, org.ldaptive.Response) succeeded. Creates a response for the original invocation that failed.

Parameters:
conn - connection the operation was executed on
request - executed by the operation
response - typically null
Returns:
handler result containing a response for the original invocation
Throws:
LdapException - if the operation fails

retry

protected boolean retry(int count)
Returns whether the supplied count indicates that the operation should be retried. If a retry wait has been configured, this method will sleep the current thread for the configured time.

Parameters:
count - number of times the operation has been retried
Returns:
whether to retry


Copyright © 2003-2017 Virginia Tech. All Rights Reserved.