org.gcube.data.streams.handlers
Class CountingHandler

java.lang.Object
  extended by org.gcube.data.streams.handlers.CountingHandler
All Implemented Interfaces:
FaultHandler

public abstract class CountingHandler
extends Object
implements FaultHandler

A partial implementation for FaultHandler that count failures and keep track of the last observed failure.

Author:
Fabio Simeoni

Constructor Summary
CountingHandler()
           
 
Method Summary
 FaultResponse handle(RuntimeException failure)
          Indicates whether iteration should continue or stop the iteration on the occurrence of an iteration failure.
protected abstract  FaultResponse handle(RuntimeException failure, Exception lastFailure, int failureCount)
          Indicates whether iteration should continue or stop the iteration on the occurrence of an iteration failure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountingHandler

public CountingHandler()
Method Detail

handle

public final FaultResponse handle(RuntimeException failure)
Description copied from interface: FaultHandler
Indicates whether iteration should continue or stop the iteration on the occurrence of an iteration failure.

Specified by:
handle in interface FaultHandler
Parameters:
failure - the failure
Returns:
the FaultResponse

handle

protected abstract FaultResponse handle(RuntimeException failure,
                                        Exception lastFailure,
                                        int failureCount)
                                 throws StreamContingencyException,
                                        RuntimeException
Indicates whether iteration should continue or stop the iteration on the occurrence of an iteration failure.

Parameters:
failure - the failure
lastFailure - the failure observed previously, or null if this is the first observed failure
failureCount - the number of failures counted so far, 0 if this is the first observed failure
Returns:
true if iteration should continue, false if it should stop
Throws:
StreamContingencyException - if no element can be yielded, because the input element violates pre-conditions
RuntimeException - if no element can be yielded from the input element, because of an unrecoverable condition


Copyright © 2012. All Rights Reserved.