org.apache.hadoop.tools.util
Class RetriableCommand

java.lang.Object
  extended by org.apache.hadoop.tools.util.RetriableCommand
Direct Known Subclasses:
RetriableDirectoryCreateCommand, RetriableFileCopyCommand

public abstract class RetriableCommand
extends Object

This class represents commands that be retried on failure, in a configurable manner.


Field Summary
protected  String description
           
 
Constructor Summary
RetriableCommand(String description)
          Constructor.
RetriableCommand(String description, RetryPolicy retryPolicy)
          Constructor.
 
Method Summary
protected abstract  Object doExecute(Object... arguments)
          Implement this interface-method define the command-logic that will be retried on failure (i.e.
 Object execute(Object... arguments)
          The execute() method invokes doExecute() until either: 1.
 RetriableCommand setRetryPolicy(RetryPolicy retryHandler)
          Fluent-interface to change the RetryHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

protected String description
Constructor Detail

RetriableCommand

public RetriableCommand(String description)
Constructor.

Parameters:
description - The human-readable description of the command.

RetriableCommand

public RetriableCommand(String description,
                        RetryPolicy retryPolicy)
Constructor.

Parameters:
description - The human-readable description of the command.
retryPolicy - The RetryHandler to be used to compute retries.
Method Detail

doExecute

protected abstract Object doExecute(Object... arguments)
                             throws Exception
Implement this interface-method define the command-logic that will be retried on failure (i.e. with Exception).

Parameters:
arguments - Argument-list to the command.
Returns:
Generic "Object".
Throws:
Exception - Throws Exception on complete failure.

execute

public Object execute(Object... arguments)
               throws Exception
The execute() method invokes doExecute() until either: 1. doExecute() succeeds, or 2. the command may no longer be retried (e.g. runs out of retry-attempts).

Parameters:
arguments - The list of arguments for the command.
Returns:
Generic "Object" from doExecute(), on success.
Throws:
IOException, - IOException, on complete failure.
Exception

setRetryPolicy

public RetriableCommand setRetryPolicy(RetryPolicy retryHandler)
Fluent-interface to change the RetryHandler.

Parameters:
retryHandler - The new RetryHandler instance to be used.
Returns:
Self.


Copyright © 2014 InMobi. All rights reserved.