use of voldemort.store.routed.action.Action in project voldemort by voldemort.
the class Pipeline method execute.
/**
* Process events in the order as they were received.
*
* <p/>
*
* The overall time to process the events must be within the bounds of the
* timeout or an {@link InsufficientOperationalNodesException} will be
* thrown.
*/
public void execute() {
try {
while (true) {
Event event = null;
try {
event = eventQueue.poll(timeout, unit);
} catch (InterruptedException e) {
throw new InsufficientOperationalNodesException(operation.getSimpleName() + " operation interrupted!", e);
}
if (event == null)
throw new VoldemortException(operation.getSimpleName() + " returned a null event");
if (event.equals(Event.ERROR)) {
if (logger.isTraceEnabled())
logger.trace(operation.getSimpleName() + " request, events complete due to error");
break;
} else if (event.equals(Event.COMPLETED)) {
if (logger.isTraceEnabled())
logger.trace(operation.getSimpleName() + " request, events complete");
break;
}
Action action = eventActions.get(event);
if (action == null)
throw new IllegalStateException("action was null for event " + event);
if (logger.isTraceEnabled())
logger.trace(operation.getSimpleName() + " request, action " + action.getClass().getSimpleName() + " to handle " + event + " event");
action.execute(this);
}
} finally {
finished = true;
}
}
Aggregations