Skip to content

Commit

Permalink
Merge pull request Netflix#27 from benjchristensen/healthcount-concur…
Browse files Browse the repository at this point in the history
…rency-bug

Initialize HealthCounts to non-null value.
  • Loading branch information
benjchristensen committed Nov 30, 2012
2 parents 836da10 + 0a8e985 commit 0da4f5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.junit.Test;

import com.netflix.hystrix.HystrixCommandMetrics.HealthCounts;
import com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifierDefault;
import com.netflix.hystrix.util.HystrixRollingNumberEvent;

Expand Down Expand Up @@ -172,14 +173,15 @@ public boolean isOpen() {
}

// we're closed, so let's see if errors have made us so we should trip the circuit open

HealthCounts health = metrics.getHealthCounts();

// check if we are past the statisticalWindowVolumeThreshold
if (metrics.getHealthCounts().getTotalRequests() < properties.circuitBreakerRequestVolumeThreshold().get()) {
if (health.getTotalRequests() < properties.circuitBreakerRequestVolumeThreshold().get()) {
// we are not past the minimum volume threshold for the statisticalWindow so we'll return false immediately and not calculate anything
return false;
}

if (metrics.getHealthCounts().getErrorPercentage() < properties.circuitBreakerErrorThresholdPercentage().get()) {
if (health.getErrorPercentage() < properties.circuitBreakerErrorThresholdPercentage().get()) {
return false;
} else {
// our failure rate is too high, trip the circuit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public int getCurrentConcurrentExecutionCount() {
}
}

private volatile HealthCounts healthCountsSnapshot = null;
private volatile HealthCounts healthCountsSnapshot = new HealthCounts(0, 0, 0);
private volatile AtomicLong lastHealthCountsSnapshot = new AtomicLong(System.currentTimeMillis());

/**
Expand Down

0 comments on commit 0da4f5b

Please sign in to comment.