- 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;
- }