Code example for AtomicLong

Methods: incrementAndGetlongValue

0
     * @param isSuccess if the method invocation was successful 
     */ 
    public void onExecute(long executionTime, boolean isSuccess) {
        try { 
            // (avgTime * count + executionTime) / (count + 1); 
            this.avgTime = new AtomicLong((avgTime.longValue() * count.longValue() + executionTime) / (count.longValue() + 1));
            this.count.incrementAndGet();
            if (this.minTime.longValue() > executionTime) {
                this.minTime.set(executionTime);
            } 
            if (this.maxTime.longValue() < executionTime) {
                this.maxTime.set(executionTime);
            } 
 
            if (isSuccess == false) {
                this.exceptionCount.incrementAndGet();
            } 
        } catch (Throwable t) {
            // in case of any issues, such as overflow, we should reset all the values. 
            log.error("MethodInvocationMonitor: onExecute with error : " + t.getMessage());
            reset();