Package com.cloudloop

Examples of com.cloudloop.ProviderRequestStatus


  public <T> T executeRequest( ProviderRequest request )
  {
    int retryCount = 0;
    boolean successful = false;
    T output = null;
    ProviderRequestStatus status = new ProviderRequestStatus( request );
    do
    {
      try
      {
        output = (T)request.invoke( status );
        successful = true;
      }
      catch ( Throwable ex )
      {
        successful = false;
        if ( retryCount >= _retryCount )
        {
          if ( status.getStatus( ) != Status.ERROR )
          {
            status.setStatus( Status.ERROR, "Error occurred during operation. " + ex.getMessage( ) );
          }
          if ( _observer != null )
          {
            _observer.onFailure( ex );
          }
          if ( ex instanceof ProviderRequestException )
          {
            throw (ProviderRequestException) ex;
          }
          throw new ProviderRequestException(ex);
        }
        if ( _observer != null )
        {
          _observer.onRetry( ex, retryCount );
        }
        sleep( _timeBetweenRetriesMillis );
      }
      retryCount++;
    }
    while ( !successful );
    if (status.getStatus( ) != Status.COMPLETED)
    {
      status.setStatus( Status.COMPLETED, "Operation completed successfully." );
    }
    if ( _observer != null )
    {
      _observer.onSuccess( status.getElapsedMillis( ) );
    }
    return output;
  }
View Full Code Here

TOP

Related Classes of com.cloudloop.ProviderRequestStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.