private boolean isAfterSleepWindow() { final long circuitOpenTime = circuitOpened.get(); final long currentTime = System.currentTimeMillis(); final long sleepWindowTime = properties.circuitBreakerSleepWindowInMilliseconds().get(); return currentTime > circuitOpenTime + sleepWindowTime; }
@Override public Number getValue() { return properties.circuitBreakerSleepWindowInMilliseconds().get(); } });
assertEquals(false, command.getProperties().circuitBreakerEnabled().get().booleanValue()); assertEquals(30, command.getProperties().circuitBreakerRequestVolumeThreshold().get().intValue()); assertEquals(250, command.getProperties().circuitBreakerSleepWindowInMilliseconds().get().intValue()); assertEquals(60, command.getProperties().circuitBreakerErrorThresholdPercentage().get().intValue()); assertEquals(false, command.getProperties().circuitBreakerForceOpen().get().booleanValue());
commandProperties.circuitBreakerForceOpen().get(), commandProperties.circuitBreakerRequestVolumeThreshold().get(), commandProperties.circuitBreakerSleepWindowInMilliseconds().get() );
@Override public Number call() { return properties.circuitBreakerSleepWindowInMilliseconds().get(); } });
@Override public Number getValue() { return properties.circuitBreakerSleepWindowInMilliseconds().get(); } });
@Override public Number value() { return properties.circuitBreakerSleepWindowInMilliseconds().get(); } });
@Override public Number getValue() { return properties.circuitBreakerSleepWindowInMilliseconds().get(); } });
private boolean isAfterSleepWindow() { final long circuitOpenTime = circuitOpened.get(); final long currentTime = System.currentTimeMillis(); final long sleepWindowTime = properties.circuitBreakerSleepWindowInMilliseconds().get(); return currentTime > circuitOpenTime + sleepWindowTime; }
public boolean allowSingleTest() { long timeCircuitOpenedOrWasLastTested = circuitOpenedOrLastTestedTime.get(); // 1) if the circuit is open // 2) and it's been longer than 'sleepWindow' since we opened the circuit if (circuitOpen.get() && System.currentTimeMillis() > timeCircuitOpenedOrWasLastTested + properties.circuitBreakerSleepWindowInMilliseconds().get()) { // We push the 'circuitOpenedTime' ahead by 'sleepWindow' since we have allowed one request to try. // If it succeeds the circuit will be closed, otherwise another singleTest will be allowed at the end of the 'sleepWindow'. if (circuitOpenedOrLastTestedTime.compareAndSet(timeCircuitOpenedOrWasLastTested, System.currentTimeMillis())) { // if this returns true that means we set the time so we'll return true to allow the singleTest // if it returned false it means another thread raced us and allowed the singleTest before we did return true; } } return false; }
public CircutBreakerEvent(HystrixCommandKey commandKey, Type type) { super(type); HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(commandKey); if (hystrixCommandMetrics != null) { if (hystrixCommandMetrics.getCommandGroup() instanceof CustomizeCommandGroupKey) { CustomizeCommandGroupKey customCommandGroupKey = (CustomizeCommandGroupKey) hystrixCommandMetrics.getCommandGroup(); this.microservice = customCommandGroupKey.getInstance().getMicroserviceName(); this.role = customCommandGroupKey.getInstance().getInvocationType().name(); this.schema = customCommandGroupKey.getInstance().getSchemaId(); this.operation = customCommandGroupKey.getInstance().getOperationName(); } this.currentTotalRequest = hystrixCommandMetrics.getHealthCounts().getTotalRequests(); this.currentErrorPercentage = hystrixCommandMetrics.getHealthCounts().getErrorCount(); this.currentErrorCount = hystrixCommandMetrics.getHealthCounts().getErrorPercentage(); this.requestVolumeThreshold = hystrixCommandMetrics.getProperties().circuitBreakerRequestVolumeThreshold().get(); this.sleepWindowInMilliseconds = hystrixCommandMetrics.getProperties().circuitBreakerSleepWindowInMilliseconds().get(); this.errorThresholdPercentage = hystrixCommandMetrics.getProperties().circuitBreakerErrorThresholdPercentage().get(); } }
json.writeNumberField("propertyValue_circuitBreakerSleepWindowInMilliseconds", commandProperties.circuitBreakerSleepWindowInMilliseconds().get()); json.writeNumberField("propertyValue_circuitBreakerErrorThresholdPercentage", commandProperties.circuitBreakerErrorThresholdPercentage().get()); json.writeBooleanField("propertyValue_circuitBreakerForceOpen", commandProperties.circuitBreakerForceOpen().get());
json.writeNumberField("propertyValue_circuitBreakerSleepWindowInMilliseconds", commandProperties.circuitBreakerSleepWindowInMilliseconds().get()); json.writeNumberField("propertyValue_circuitBreakerErrorThresholdPercentage", commandProperties.circuitBreakerErrorThresholdPercentage().get()); json.writeBooleanField("propertyValue_circuitBreakerForceOpen", commandProperties.circuitBreakerForceOpen().get());
json.writeNumberField("propertyValue_circuitBreakerSleepWindowInMilliseconds", commandProperties.circuitBreakerSleepWindowInMilliseconds().get()); json.writeNumberField("propertyValue_circuitBreakerErrorThresholdPercentage", commandProperties.circuitBreakerErrorThresholdPercentage().get()); json.writeBooleanField("propertyValue_circuitBreakerForceOpen", commandProperties.circuitBreakerForceOpen().get());
json.writeNumberField("propertyValue_circuitBreakerSleepWindowInMilliseconds", commandProperties.circuitBreakerSleepWindowInMilliseconds().get()); json.writeNumberField("propertyValue_circuitBreakerErrorThresholdPercentage", commandProperties.circuitBreakerErrorThresholdPercentage().get()); json.writeBooleanField("propertyValue_circuitBreakerForceOpen", commandProperties.circuitBreakerForceOpen().get());
public CircutBreakerEvent(HystrixCommandKey commandKey, Type type) { super(type); HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(commandKey); if (hystrixCommandMetrics != null) { if (hystrixCommandMetrics.getCommandGroup() instanceof CustomizeCommandGroupKey) { CustomizeCommandGroupKey customCommandGroupKey = (CustomizeCommandGroupKey) hystrixCommandMetrics.getCommandGroup(); this.microservice = customCommandGroupKey.getInstance().getMicroserviceName(); this.role = customCommandGroupKey.getInstance().getInvocationType().name(); this.schema = customCommandGroupKey.getInstance().getSchemaId(); this.operation = customCommandGroupKey.getInstance().getOperationName(); } this.currentTotalRequest = hystrixCommandMetrics.getHealthCounts().getTotalRequests(); this.currentErrorPercentage = hystrixCommandMetrics.getHealthCounts().getErrorCount(); this.currentErrorCount = hystrixCommandMetrics.getHealthCounts().getErrorPercentage(); this.requestVolumeThreshold = hystrixCommandMetrics.getProperties().circuitBreakerRequestVolumeThreshold().get(); this.sleepWindowInMilliseconds = hystrixCommandMetrics.getProperties().circuitBreakerSleepWindowInMilliseconds().get(); this.errorThresholdPercentage = hystrixCommandMetrics.getProperties().circuitBreakerErrorThresholdPercentage().get(); } }
public static TenacityConfiguration getTenacityConfiguration(TenacityPropertyKey key) { final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(key); final HystrixThreadPoolProperties threadPoolProperties = TenacityCommand.getThreadpoolProperties(key); return new TenacityConfiguration( new ThreadPoolConfiguration( threadPoolProperties.coreSize().get(), threadPoolProperties.keepAliveTimeMinutes().get(), threadPoolProperties.maxQueueSize().get(), threadPoolProperties.queueSizeRejectionThreshold().get(), threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get(), threadPoolProperties.metricsRollingStatisticalWindowBuckets().get()), new CircuitBreakerConfiguration( commandProperties.circuitBreakerRequestVolumeThreshold().get(), commandProperties.circuitBreakerSleepWindowInMilliseconds().get(), commandProperties.circuitBreakerErrorThresholdPercentage().get(), commandProperties.metricsRollingStatisticalWindowInMilliseconds().get(), commandProperties.metricsRollingStatisticalWindowBuckets().get()), new SemaphoreConfiguration( commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get(), commandProperties.fallbackIsolationSemaphoreMaxConcurrentRequests().get()), commandProperties.executionTimeoutInMilliseconds().get(), commandProperties.executionIsolationStrategy().get()); } }
public static TenacityConfiguration getTenacityConfiguration(TenacityPropertyKey key) { final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(key); final HystrixThreadPoolProperties threadPoolProperties = TenacityCommand.getThreadpoolProperties(key); return new TenacityConfiguration( new ThreadPoolConfiguration( threadPoolProperties.coreSize().get(), threadPoolProperties.keepAliveTimeMinutes().get(), threadPoolProperties.maxQueueSize().get(), threadPoolProperties.queueSizeRejectionThreshold().get(), threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get(), threadPoolProperties.metricsRollingStatisticalWindowBuckets().get()), new CircuitBreakerConfiguration( commandProperties.circuitBreakerRequestVolumeThreshold().get(), commandProperties.circuitBreakerSleepWindowInMilliseconds().get(), commandProperties.circuitBreakerErrorThresholdPercentage().get(), commandProperties.metricsRollingStatisticalWindowInMilliseconds().get(), commandProperties.metricsRollingStatisticalWindowBuckets().get()), new SemaphoreConfiguration( commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get(), commandProperties.fallbackIsolationSemaphoreMaxConcurrentRequests().get()), commandProperties.executionTimeoutInMilliseconds().get(), commandProperties.executionIsolationStrategy().get()); } }
commandProperties.circuitBreakerForceOpen().get(), commandProperties.circuitBreakerRequestVolumeThreshold().get(), commandProperties.circuitBreakerSleepWindowInMilliseconds().get() );