Sets the number of successive successful executions that must occur when in a half-open state in order to close the
circuit, else the circuit is re-opened when a failure occurs.

@throws IllegalArgumentException if {@code successThreshold} < 1
977542
public CircuitBreaker<R> withSuccessThreshold(int successThreshold) {
    Assert.isTrue(successThreshold >= 1, "successThreshold must be greater than or equal to 1");
    return withSuccessThreshold(successThreshold, successThreshold);
  }
105671
public synchronized void reset() {
		executing.reset();
		rejected.reset();
		failed.reset();
		succeeded.reset();

		counter.reset();
		histogram.reset();

		lastFailureReason = null;
		lastRejectReason = null;
	}
329628
public void setReliability(Reliability reliability)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setReliability", reliability);

        JsMessage localMsg = getJSMessage(true);
        msgReliability = reliability;
        localMsg.setReliability(msgReliability);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setReliability");
    }
1365660
private void synchronizedRecordResult(CircuitBreakerResult result) {
        synchronized (this) {
            switch (state.get()) {
                case CLOSED:
                    rollingWindow.record(result);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Recording result {0} in closed state: {1}", result, rollingWindow);
                    }
                    if (rollingWindow.isOverThreshold()) {
                        stateOpen();
                    }
                    break;
                case HALF_OPEN:
                    if (result == CircuitBreakerResult.FAILURE) {
                        stateOpen();
                    } else {
                        halfOpenRunningExecutions--;
                        halfOpenSuccessfulExecutions++;
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Recording result {0} in half-open state. Running executions: {1}, Current results: ({2}/{3})",
                                     result, halfOpenRunningExecutions, halfOpenSuccessfulExecutions, policy.getSuccessThreshold());
                        }
                        if (halfOpenSuccessfulExecutions >= policy.getSuccessThreshold()) {
                            stateClosed();
                        }
                    }
                    break;
                case OPEN:
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Recording result {0} in open state", result);
                    }
                    // Nothing else to do
                    break;
            }
        }
    }
681234
private boolean synchronizedRequestPermissionToExecute() {
        boolean result = false;
        synchronized (this) {
            switch (state.get()) {
                case CLOSED:
                    result = true;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Allowing execution in closed state");
                    }
                    break;
                case HALF_OPEN:
                    // Limit the number of concurrent executions when we're half-open
                    if (halfOpenRunningExecutions < policy.getSuccessThreshold()) {
                        halfOpenRunningExecutions++;
                        halfOpenLastExecutionStarted = System.nanoTime();
                        result = true;
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Allowing execution in half-open state. Now running ({0}/{1})", halfOpenRunningExecutions, policy.getSuccessThreshold());
                        }
                    } else {
                        // If the user runs an operation which never returns (possible using CompletionStage), we might end up stuck in half-open state
                        // denying all executions forever. For this reason, if we stay in half-open state for longer than the open state delay time,
                        // allow another execution
                        if (System.nanoTime() - halfOpenLastExecutionStarted > policyDelayNanos) {
                            halfOpenLastExecutionStarted = System.nanoTime();
                            result = true;
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "Allowing execution in half-open state because enough time has passed without a trial executions completing");
                            }
                        } else {
                            result = false;
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "Denying execution in half-open state, trial execution limit reached");
                            }
                        }
                    }
                    break;
                case OPEN:
                    if (System.nanoTime() - openStateStartTime > policyDelayNanos) {
                        // We've been in open state for long enough, transition to half-open
                        stateHalfOpen();
                        halfOpenRunningExecutions++;
                        halfOpenLastExecutionStarted = System.nanoTime();
                        result = true;
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Allowing execution because we just changed to half-open state");
                        }
                    } else {
                        result = false;
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Denying execution in open state");
                        }
                    }
                    break;
            }
        }
        return result;
    }
651021
public void set(final MethodCallInfo another) {
		this.failed = another.failed;
		this.exception = another.exception;
		this.result = another.result;
	}
625712
public void executeNext() {

        if (!m_idle) {
            if (m_actions.isEmpty()) {
                m_idle = true;
            } else {
                CmsValidationController action = m_actions.removeFirst();
                action.internalStartValidation();
            }
        } else {
            assert false; // this shouldn't happen
        }
    }
615184
public void count(final SuccessCallback<Long> successCallback, final ErrorCallback errorCallback) {
        checkNotNull(successCallback);
        checkNotNull(errorCallback);

        final Callable<Long> call = new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                return SugarRecord.count(getSugarClass());
            }
        };

        final Future<Long> future = doInBackground(call);
        Long count;

        try {
            count = future.get();

            if (null == count) {
                errorCallback.onError(new Exception("Error when trying to get count"));
            } else {
                successCallback.onSuccess(count);
            }

        } catch (Exception e) {
            errorCallback.onError(e);
        }
    }
838329
protected void renewConnection() {
		this.logicallyClosed.set(false);
		this.threadUsingConnection = Thread.currentThread();
		if (this.doubleCloseCheck){
			this.doubleCloseException = null;
		}
	}
257661
protected EventBase<T> setRequiresResult(boolean value) {
        if (requiresResult == value) {
            return this;
        }
        if (value) {
            openCount.incrementAndGet();
            requiresResult = true;
        } else {
            requiresResult = false;
            decrementOpen();
        }
        return this;
    }
1004564
public synchronized void setFailure(Exception paramE) {
        if (done)
            return; // can't mark done twice
        e = paramE;
        done = true;
        notifyAll();

        // if we have a callback to call, schedule
        // it on a different thread. Who knows what this
        // thread is doing.
        if (callback != null) {
            QueueBuffer.executor.submit(new Callable<Void>() {
                public Void call() throws Exception {
                    callback.onError(e);
                    return null;
                }
            });

        }

    }
431589
public void fail() {
        hasFailure = true;
        // fail fast
        long count = latch.getCount();
        for (int i = 0; i < count; i++) {
            latch.countDown();
        }
    }
1248243
@SuppressWarnings("unchecked")
	@Override
	public T retry(final int count, final int waitTime) {
		context().setMaxRetryCount(count).setRetryWaitTime(waitTime);
		return (T) this;
	}
642083
public void setUnsuccessful(java.util.Collection<UnsuccessfulItem> unsuccessful) {
        if (unsuccessful == null) {
            this.unsuccessful = null;
            return;
        }

        this.unsuccessful = new com.amazonaws.internal.SdkInternalList<UnsuccessfulItem>(unsuccessful);
    }
1147061
@Override
  public FutureResultImpl<T> setFailure(Throwable throwable) {
    this.throwable = throwable;
    failed = true;
    checkCallHandler();
    return this;
  }
1297718
public void setLimit(int limit) {
        FailureInterpreter fi = getFailureInterpreter();
        if (!(fi instanceof DefaultFailureInterpreter)) {
            throw new IllegalStateException("setLimit() not supported: this CircuitBreaker's FailureInterpreter isn't a DefaultFailureInterpreter.");
        }
        ((DefaultFailureInterpreter)fi).setLimit(limit);
    }
183638
public Closeable decrementOnceCloseable()
  {
    AtomicBoolean decremented = new AtomicBoolean(false);
    return () -> {
      if (decremented.compareAndSet(false, true)) {
        decrement();
      } else {
        log.warn("close() is called more than once on ReferenceCountingSegment.decrementOnceCloseable()");
      }
    };
  }