assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); assertFalse(cb.allowRequest()); System.out.println("!!!! 5: Confirmed that no other requests go out during single-test"); assertFalse(cb.allowRequest()); assertFalse(cb.allowRequest()); assertFalse(cb.allowRequest()); assertFalse(cb.allowRequest()); System.out.println("confirmed that 2nd singletest only happened once"); assertFalse(cb.allowRequest()); assertFalse(cb.allowRequest()); assertFalse(cb.allowRequest()); assertFalse(cb.allowRequest()); assertTrue(cb.allowRequest()); assertTrue(cb.allowRequest()); assertTrue(cb.allowRequest());
assertFalse(cb.allowRequest()); assertTrue(cb.isOpen()); assertTrue(cb.allowRequest()); assertFalse(cb.isOpen());
assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); assertFalse(cb.allowRequest()); assertTrue(cb.allowRequest()); assertTrue(cb.allowRequest()); assertTrue(cb.allowRequest());
/** * Test that if all 'marks' are timeouts that it will trip the circuit. */ @Test public void testTripCircuitOnTimeouts() { String key = "cmd-D"; try { HystrixCommand<Boolean> cmd1 = new TimeoutCommand(key); HystrixCircuitBreaker cb = cmd1.circuitBreaker; // this should start as allowing requests assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); // success with high latency cmd1.execute(); HystrixCommand<Boolean> cmd2 = new TimeoutCommand(key); cmd2.execute(); HystrixCommand<Boolean> cmd3 = new TimeoutCommand(key); cmd3.execute(); HystrixCommand<Boolean> cmd4 = new TimeoutCommand(key); cmd4.execute(); // everything has been a timeout so we should not allow any requests Thread.sleep(100); assertFalse(cb.allowRequest()); assertTrue(cb.isOpen()); } catch (Exception e) { e.printStackTrace(); fail("Error occurred: " + e.getMessage()); } }
assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); assertTrue(cb.allowRequest()); assertFalse(cb.isOpen());
assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); assertFalse(cb.allowRequest()); assertTrue(cb.isOpen());
assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); assertFalse(cb.allowRequest()); assertTrue(cb.isOpen()); } catch (Exception e) {
assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); System.out.println("ReqLog : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString()); System.out.println("Current CircuitBreaker Status : " + cmd1.getMetrics().getHealthCounts()); assertTrue(cb.allowRequest()); assertFalse(cb.isOpen()); } catch (Exception e) {
assertFalse(cb.allowRequest()); assertTrue(cb.isOpen()); } catch (Exception e) {
assertTrue(cb.allowRequest()); assertFalse(cb.isOpen());
public static Optional<CircuitBreaker> usingHystrix(TenacityPropertyKey id) { final HystrixCircuitBreaker circuitBreaker = TenacityCommand.getCircuitBreaker(id); if (circuitBreaker == null) { return Optional.empty(); } final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(id); if (commandProperties.circuitBreakerForceOpen().get()) { return Optional.of(CircuitBreaker.forcedOpen(id)); } else if (commandProperties.circuitBreakerForceClosed().get()) { return Optional.of(CircuitBreaker.forcedClosed(id)); } else if (circuitBreaker.allowRequest()) { return Optional.of(CircuitBreaker.closed(id)); } else { return Optional.of(CircuitBreaker.open(id)); } }
public static Optional<CircuitBreaker> usingHystrix(TenacityPropertyKey id) { final HystrixCircuitBreaker circuitBreaker = TenacityCommand.getCircuitBreaker(id); if (circuitBreaker == null) { return Optional.empty(); } final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(id); if (commandProperties.circuitBreakerForceOpen().get()) { return Optional.of(CircuitBreaker.forcedOpen(id)); } else if (commandProperties.circuitBreakerForceClosed().get()) { return Optional.of(CircuitBreaker.forcedClosed(id)); } else if (circuitBreaker.allowRequest()) { return Optional.of(CircuitBreaker.closed(id)); } else { return Optional.of(CircuitBreaker.open(id)); } }
if (circuitBreaker.allowRequest()) { final TryableSemaphore executionSemaphore = getExecutionSemaphore(); final AtomicBoolean semaphoreHasBeenReleased = new AtomicBoolean(false);