/** * Constructor where we specify certain {@link Throwable} classes * that will be ignored by the breaker and not be treated as * failures (they will be passed through transparently without * causing the breaker to trip). * @param ignore an array of {@link Throwable} classes that will * be ignored. Any given <code>Throwable</code> that is a * subclass of one of these classes will be ignored. */ public PercentErrPerTimeFailureInterpreter(Class<? extends Throwable>[] ignore) { setIgnore(ignore); }
/** * Default constructor. Any {@link Throwable} will cause the breaker to trip. */ @SuppressWarnings("unchecked") public PercentErrPerTimeFailureInterpreter() { setIgnore(defaultIgnore); requestCounter = new RequestCounter(); }
/** * Constructor that allows a tolerance for a certain number of * failures within a given window of time without tripping. * @param rc A {@link RequestCounter} wrapped around the same thing that this * {@link org.fishwife.jrugged.CircuitBreaker} is protecting. This is * needed in order to keep track of the total number of requests, enabling a * percentage calculation to be done. * @param percent the whole number percentage of failures that will be tolerated * (i.e. the percentage of failures has to be strictly <em>greater * than</em> this number in order to trip the breaker). For * example, if the percentage is 3, any calculated failure percentage * above that number during the window will cause the breaker to trip. * @param windowMillis length of the window in milliseconds */ @SuppressWarnings("unchecked") public PercentErrPerTimeFailureInterpreter(RequestCounter rc, int percent, long windowMillis) { setIgnore(defaultIgnore); setPercent(percent); setWindowMillis(windowMillis); setRequestCounter(rc); }
/** * Constructor where we specify tolerance and a set of ignored failures. * * @param rc A {@link RequestCounter} wrapped around the same thing that this * {@link org.fishwife.jrugged.CircuitBreaker} is protecting. This is * needed in order to keep track of the total number of requests, enabling a * percentage calculation to be done. * @param ignore an array of {@link Throwable} classes that will * be ignored. Any given <code>Throwable</code> that is a * subclass of one of these classes will be ignored. * @param percent the whole number percentage of failures that will be tolerated * (i.e. the percentage of failures has to be strictly <em>greater * than</em> this number in order to trip the breaker). For * example, if the percentage is 3, any calculated failure percentage * above that number during the window will cause the breaker to trip. * @param windowMillis length of the window in milliseconds */ public PercentErrPerTimeFailureInterpreter(RequestCounter rc, Class<? extends Throwable>[] ignore, int percent, long windowMillis) { setRequestCounter(rc); setIgnore(ignore); setPercent(percent); setWindowMillis(windowMillis); }
/** * Constructor that allows a tolerance for a certain number of * failures within a given window of time without tripping. * @param p A {@link PerformanceMonitor} from which we can get an underlying * {@link RequestCounter} that is wrapped around the same thing that this * {@link org.fishwife.jrugged.CircuitBreaker} is protecting. This is * needed in order to keep track of the total number of requests, enabling a * percentage calculation to be done. * @param percent the whole number percentage of failures that will be tolerated * (i.e. the percentage of failures has to be strictly <em>greater * than</em> this number in order to trip the breaker). For * example, if the percentage is 3, any calculated failure percentage * above that number during the window will cause the breaker to trip. * @param windowMillis length of the window in milliseconds */ @SuppressWarnings("unchecked") public PercentErrPerTimeFailureInterpreter(PerformanceMonitor p, int percent, long windowMillis) { setIgnore(defaultIgnore); setPercent(percent); setWindowMillis(windowMillis); setRequestCounter(p.getRequestCounter()); }