All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fnklabs.draenei.orm.FutureTimerCallback Maven / Gradle / Ivy

There is a newer version: 0.8.3
Show newest version
package com.fnklabs.draenei.orm;

import com.codahale.metrics.Timer;
import com.google.common.util.concurrent.FutureCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Function for stopping timer on future completion
 *
 * @param  Future type
 */
class FutureTimerCallback implements FutureCallback {
    private static final Logger LOGGER = LoggerFactory.getLogger(FutureTimerCallback.class);
    private final Timer.Context timer;

    FutureTimerCallback(Timer.Context timer) {
        this.timer = timer;
    }

    @Override
    public void onSuccess(Input result) {
        timer.stop();
    }

    @Override
    public void onFailure(Throwable t) {
        timer.stop();
        LOGGER.warn("Cant complete operation", t);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy