X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionRateLimitingCallback.java;h=678891446ab9b3da8c87315497bb1f044b681897;hp=1202a909d54bfb8faf69adce2a47cded7391853d;hb=3b0499cd187bcdeda057465350d381c8bc28847c;hpb=61722bffcf885c04d11f684f2f03b09fa96f2002 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java index 1202a909d5..678891446a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java @@ -8,30 +8,20 @@ package org.opendaylight.controller.cluster.datastore; -import com.codahale.metrics.Snapshot; import com.codahale.metrics.Timer; import com.google.common.base.Preconditions; -import java.util.concurrent.TimeUnit; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * TransactionRateLimitingCallback computes the new transaction rate limit on the successful completion of a * transaction */ public class TransactionRateLimitingCallback implements OperationCallback{ - - private static final Logger LOG = LoggerFactory.getLogger(TransactionRateLimitingCallback.class); - private static final String COMMIT = "commit"; - private final Timer commitTimer; - private final ActorContext actorContext; private Timer.Context timerContext; TransactionRateLimitingCallback(ActorContext actorContext){ - this.actorContext = actorContext; - commitTimer = actorContext.getOperationTimer(COMMIT); + commitTimer = actorContext.getOperationTimer(ActorContext.COMMIT); } @Override @@ -43,35 +33,6 @@ public class TransactionRateLimitingCallback implements OperationCallback{ public void success() { Preconditions.checkState(timerContext != null, "Call run before success"); timerContext.stop(); - - Snapshot timerSnapshot = commitTimer.getSnapshot(); - double newRateLimit = 0; - - long commitTimeoutInSeconds = actorContext.getDatastoreContext() - .getShardTransactionCommitTimeoutInSeconds(); - long commitTimeoutInNanos = TimeUnit.SECONDS.toNanos(commitTimeoutInSeconds); - - // Find the time that it takes for transactions to get executed in every 10th percentile - // Compute the rate limit for that percentile and sum it up - for(int i=1;i<=10;i++){ - // Get the amount of time transactions take in the i*10th percentile - double percentileTimeInNanos = timerSnapshot.getValue(i * 0.1D); - - if(percentileTimeInNanos > 0) { - // Figure out the rate limit for the i*10th percentile in nanos - double percentileRateLimit = ((double) commitTimeoutInNanos / percentileTimeInNanos); - - // Add the percentileRateLimit to the total rate limit - newRateLimit += percentileRateLimit; - } - } - - // Compute the rate limit per second - newRateLimit = newRateLimit/(commitTimeoutInSeconds*10); - - LOG.debug("Data Store {} commit rateLimit adjusted to {}", actorContext.getDataStoreType(), newRateLimit); - - actorContext.setTxCreationLimit(newRateLimit); } @Override @@ -80,4 +41,5 @@ public class TransactionRateLimitingCallback implements OperationCallback{ // the default transaction commit timeout. Using the timeout information to figure out the rate limit is // not going to be useful - so we leave it as it is } + } \ No newline at end of file