org.apache.flume.util
Class OrderSelector<T>

java.lang.Object
  extended by org.apache.flume.util.OrderSelector<T>
Type Parameters:
T - - The class on which ordering is to be done
Direct Known Subclasses:
RandomOrderSelector, RoundRobinOrderSelector

public abstract class OrderSelector<T>
extends Object

A basic implementation of an order selector that implements a simple exponential backoff algorithm. Subclasses can use the same algorithm for backoff by simply overriding createIterator method to order the list of active sinks returned by getIndexList method. Classes instantiating subclasses of this class are expected to call informFailure method when an object passed to this class should be marked as failed and backed off. When implementing a different backoff algorithm, a subclass should minimally override informFailure and getIndexList methods.


Constructor Summary
protected OrderSelector(boolean shouldBackOff)
           
 
Method Summary
abstract  Iterator<T> createIterator()
           
protected  List<Integer> getIndexList()
           
 long getMaxTimeOut()
           
 List<T> getObjects()
          Get the list of objects to be ordered.
 void informFailure(T failedObject)
          Inform this class of the failure of an object so it can be backed off.
 boolean isShouldBackOff()
           
 void setMaxTimeOut(long timeout)
           
 void setObjects(List<T> objects)
          Set the list of objects which this class should return in order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderSelector

protected OrderSelector(boolean shouldBackOff)
Method Detail

setObjects

public void setObjects(List<T> objects)
Set the list of objects which this class should return in order.

Parameters:
objects -

getObjects

public List<T> getObjects()
Get the list of objects to be ordered. This list is in the same order as originally passed in, not in the algorithmically reordered order.

Returns:
- list of objects to be ordered.

createIterator

public abstract Iterator<T> createIterator()
Returns:
- list of algorithmically ordered active sinks

informFailure

public void informFailure(T failedObject)
Inform this class of the failure of an object so it can be backed off.

Parameters:
failedObject -

getIndexList

protected List<Integer> getIndexList()
Returns:
- List of indices currently active objects

isShouldBackOff

public boolean isShouldBackOff()

setMaxTimeOut

public void setMaxTimeOut(long timeout)

getMaxTimeOut

public long getMaxTimeOut()


Copyright © 2009-2013 Apache Software Foundation. All Rights Reserved.