List of usage examples for com.google.common.util.concurrent RateLimiter create
public static RateLimiter create(double permitsPerSecond)
From source file:com.ibm.og.util.io.ThrottledInputStream.java
/** * Constructs an input stream with a maximum throughput * //from ww w .j av a 2 s. c o m * @param in the backing input stream to read from * @param bytesPerSecond the maximum rate at which this input stream can read * @throws IllegalArgumentException if bytesPerSecond is negative or zero */ public ThrottledInputStream(final InputStream in, final long bytesPerSecond) { super(checkNotNull(in)); checkArgument(bytesPerSecond > 0, "bytesPerSecond must be > 0 [%s]", bytesPerSecond); this.rateLimiter = RateLimiter.create(bytesPerSecond); }
From source file:com.ibm.og.util.io.ThrottledOutputStream.java
/** * Constructs an output stream with a maximum throughput * /*from www. jav a 2 s.co m*/ * @param out the backing output stream to write to * @param bytesPerSecond the maximum rate at which this output stream can write * @throws IllegalArgumentException if bytesPerSecond is negative or zero */ public ThrottledOutputStream(final OutputStream out, final long bytesPerSecond) { super(checkNotNull(out)); checkArgument(bytesPerSecond > 0, "bytesPerSecond must be > 0 [%s]", bytesPerSecond); this.rateLimiter = RateLimiter.create(bytesPerSecond); }
From source file:google.registry.dns.writer.clouddns.CloudDnsWriterModule.java
@Provides @Named("cloudDns") static RateLimiter provideRateLimiter() { // This is the default max QPS for Cloud DNS. It can be increased by contacting the team // via the Quotas page on the Cloud Console. int cloudDnsMaxQps = 20; return RateLimiter.create(cloudDnsMaxQps); }
From source file:com.streamsets.pipeline.lib.io.fileref.RateLimitingWrapperStream.java
RateLimitingWrapperStream(T stream, long totalStreamSize, double rateLimit) { super(stream); Utils.checkArgument(rateLimit > 0, "Rate limit for this stream should be greater than 0."); rateLimiter = RateLimiter.create(rateLimit); remainingStreamSize = totalStreamSize; }
From source file:io.flutter.utils.AsyncRateLimiter.java
public AsyncRateLimiter(double framesPerSecond, Computable<CompletableFuture<?>> callback) { this.callback = callback; rateLimiter = RateLimiter.create(framesPerSecond); requestScheduler = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this); }
From source file:com.spotify.scio.transforms.RateLimiterDoFn.java
@Override public RateLimiter createResource() { return RateLimiter.create(recordsPerSecond); }
From source file:com.facebook.buck.event.listener.CacheRateStatsListener.java
public CacheRateStatsListener(BuckEventBus buckEventBus) { this.buckEventBus = buckEventBus; this.cacheRateStatsKeeper = new CacheRateStatsKeeper(); this.rateLimiter = RateLimiter.create(1.0); }
From source file:org.springframework.bus.firehose.doppler.websocket.MessageProducer.java
public MessageProducer(WebSocketSession session, Double requestsPerSecond, DopplerSimulator simulator) { this.session = session; this.running = true; this.simulator = simulator; limiter = RateLimiter.create(requestsPerSecond); }
From source file:com.google.cloud.trace.sdk.RateLimiterTraceEnablingPolicy.java
/** * Creates a rate limiting policy with the given rate. * @param rate//from ww w . j a va2s. c o m */ public RateLimiterTraceEnablingPolicy(double rate) { this.limiter = RateLimiter.create(1.0); }
From source file:gobblin.runtime.RateBasedLimiter.java
public RateBasedLimiter(double rateLimit, TimeUnit timeUnit) { this.rateLimiter = RateLimiter.create(convertRate(rateLimit, timeUnit, TimeUnit.SECONDS)); }