/** * Returns the total number of requests seen by this {@link * PerformanceMonitor}. * @return long */ public long getRequestCount() { return requestCounter.sample()[0]; }
/** * Returns the number of failed requests seen by this {@link * PerformanceMonitor}. * @return long */ public long getFailureCount() { return requestCounter.sample()[2]; }
/** * Returns the number of successful requests seen by this {@link * PerformanceMonitor}. * @return long */ public long getSuccessCount() { return requestCounter.sample()[1]; }
/** * Returns the average request rate in requests per second of * all requests, as measured since this object was initialized. * @return double */ public double getTotalRequestsPerSecondLifetime() { long deltaT = System.currentTimeMillis() - startupMillis; return (((double)requestCounter.sample()[0])/(double)deltaT) * 1000; }
/** * Returns the average request rate in requests per second of * successful requests, as measured since this object was * initialized. * @return double */ public double getSuccessRequestsPerSecondLifetime() { long deltaT = System.currentTimeMillis() - startupMillis; return (((double)requestCounter.sample()[1])/(double)deltaT) * 1000; }
/** * Returns the average request rate in requests per second of * failed requests, as measured since this object was * initialized. * @return double */ public double getFailureRequestsPerSecondLifetime() { long deltaT = System.currentTimeMillis() - startupMillis; return (((double)requestCounter.sample()[2])/(double)deltaT) * 1000; }
@ManagedOperation @Override /** * {@inheritDoc} */ public synchronized long[] sample() { return super.sample(); }
public boolean shouldTrip(Throwable cause) { if (isExceptionIgnorable(cause)) return false; // if Exception is of specified type, and window conditions exist, // keep circuit open unless exception threshold has passed if (hasWindowConditions()) { Long currentRequestCount = -1L; long numberOfErrorsAfter; synchronized (modificationLock) { errorTimes.add(System.currentTimeMillis()); requestCounts.add(requestCounter.sample()[0]); // calculates time for which we remove any errors before final long removeTimeBeforeMillis = System.currentTimeMillis() - windowMillis; final int numberOfErrorsBefore = this.errorTimes.size(); removeErrorsPriorToCutoffTime(numberOfErrorsBefore, removeTimeBeforeMillis); numberOfErrorsAfter = this.errorTimes.size(); currentRequestCount = this.requestCounts.get(requestCounts.size() - 1); } long windowRequests = (currentRequestCount - previousRequestHighWaterMark); // Trip if the number of errors over the total of requests over the same period // is over the percentage limit. return windowRequests >= requestThreshold && (((double) numberOfErrorsAfter / (double) windowRequests) * 100d >= percent); } return true; }
long[] currCounts = counter.sample(); long now = System.currentTimeMillis();