|
| 1 | +// Copyright (c) 2014, Facebook, Inc. All rights reserved. |
| 2 | +// This source code is licensed under the BSD-style license found in the |
| 3 | +// LICENSE file in the root directory of this source tree. An additional grant |
| 4 | +// of patent rights can be found in the PATENTS file in the same directory. |
| 5 | +package org.rocksdb; |
| 6 | + |
| 7 | +/** |
| 8 | + * Config for rate limiter, which is used to control write rate of flush and |
| 9 | + * compaction. |
| 10 | + */ |
| 11 | +public class GenericRateLimiterConfig extends RateLimiterConfig { |
| 12 | + private static final long DEFAULT_REFILL_PERIOD_MICROS = (100 * 1000); |
| 13 | + private static final int DEFAULT_FAIRNESS = 10; |
| 14 | + |
| 15 | + public GenericRateLimiterConfig(long rateBytesPerSecond, |
| 16 | + long refillPeriodMicros, int fairness) { |
| 17 | + rateBytesPerSecond_ = rateBytesPerSecond; |
| 18 | + refillPeriodMicros_ = refillPeriodMicros; |
| 19 | + fairness_ = fairness; |
| 20 | + } |
| 21 | + |
| 22 | + public GenericRateLimiterConfig(long rateBytesPerSecond) { |
| 23 | + this(rateBytesPerSecond, DEFAULT_REFILL_PERIOD_MICROS, DEFAULT_FAIRNESS); |
| 24 | + } |
| 25 | + |
| 26 | + @Override protected long newRateLimiterHandle() { |
| 27 | + return newRateLimiterHandle(rateBytesPerSecond_, refillPeriodMicros_, |
| 28 | + fairness_); |
| 29 | + } |
| 30 | + |
| 31 | + private native long newRateLimiterHandle(long rateBytesPerSecond, |
| 32 | + long refillPeriodMicros, int fairness); |
| 33 | + private final long rateBytesPerSecond_; |
| 34 | + private final long refillPeriodMicros_; |
| 35 | + private final int fairness_; |
| 36 | +} |
0 commit comments