/** * When called with true - causes the {@link CircuitBreaker} to byPass * its functionality allowing requests to be executed unmolested * until the <code>CircuitBreaker</code> is reset or the byPass * is manually set to false. * * @param b Set this breaker into bypass mode */ public void setByPassState(boolean b) { byPass = b; notifyBreakerStateChange(getStatus()); }
/** Returns a {@link String} representation of the breaker's * status; potentially useful for exposing to monitoring software. * @return <code>String</code> which is <code>"GREEN"</code> if * the breaker is CLOSED; <code>"YELLOW"</code> if the breaker * is HALF_CLOSED; and <code>"RED"</code> if the breaker is * OPEN (tripped). */ public String getHealthCheck() { return getStatus().getSignal(); }
/** * Reports a successful service call to the {@link CircuitBreaker}, * putting the <code>CircuitBreaker</code> back into the CLOSED * state serving requests. */ protected void close() { state = BreakerState.CLOSED; isAttemptLive = false; notifyBreakerStateChange(getStatus()); }
/** * Manually set the breaker to be reset and ready for use. This * is only useful after a manual trip otherwise the breaker will * trip automatically again if the service is still unavailable. * Just like a real breaker. WOOT!!! */ public void reset() { state = BreakerState.CLOSED; isHardTrip = false; byPass = false; isAttemptLive = false; notifyBreakerStateChange(getStatus()); }
/** * Causes the {@link CircuitBreaker} to trip and OPEN; no new * requests will be allowed until the <code>CircuitBreaker</code> * resets. */ public void trip() { if (state != BreakerState.OPEN) { openCount.getAndIncrement(); } state = BreakerState.OPEN; lastFailure.set(System.currentTimeMillis()); isAttemptLive = false; notifyBreakerStateChange(getStatus()); }
pjp.getSignature().getName(), pjp.getTarget(), circuitBreaker.getStatus()});