import com.google.common.base.Preconditions;
import com.google.common.base.Ticker;
import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
/**
* TransactionRateLimitingCallback computes the new transaction rate limit on the successful completion of a
- * transaction
+ * transaction.
*/
-public class TransactionRateLimitingCallback implements OperationCallback{
+public class TransactionRateLimitingCallback implements OperationCallback {
private static Ticker TICKER = Ticker.systemTicker();
private enum State {
private long elapsedTime;
private volatile State state = State.STOPPED;
- TransactionRateLimitingCallback(ActorContext actorContext){
- commitTimer = actorContext.getOperationTimer(ActorContext.COMMIT);
+ TransactionRateLimitingCallback(ActorUtils actorUtils) {
+ commitTimer = actorUtils.getOperationTimer(ActorUtils.COMMIT);
}
@Override
@Override
public void pause() {
- if(state == State.RUNNING) {
+ if (state == State.RUNNING) {
elapsedTime += TICKER.read() - startTime;
state = State.PAUSED;
}
@Override
public void resume() {
- if(state != State.RUNNING) {
+ if (state != State.RUNNING) {
startTime = TICKER.read();
state = State.RUNNING;
}
static void setTicker(Ticker ticker) {
TICKER = ticker;
}
-}
\ No newline at end of file
+}