public class LeakyBucketStreamThrottler extends Object implements StreamThrottler
Modifier and Type | Class and Description |
---|---|
private class |
LeakyBucketStreamThrottler.Drain
This class is responsible for draining water from the leaky bucket.
|
private static class |
LeakyBucketStreamThrottler.Request |
private static class |
LeakyBucketStreamThrottler.Response |
Modifier and Type | Field and Description |
---|---|
private ScheduledExecutorService |
executorService |
private int |
maxBytesPerSecond |
private BlockingQueue<LeakyBucketStreamThrottler.Request> |
requestQueue |
private AtomicBoolean |
shutdown |
Constructor and Description |
---|
LeakyBucketStreamThrottler(int maxBytesPerSecond) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
copy(InputStream in,
OutputStream out) |
long |
copy(InputStream in,
OutputStream out,
long maxBytes) |
InputStream |
newThrottledInputStream(InputStream toWrap) |
OutputStream |
newThrottledOutputStream(OutputStream toWrap) |
private final int maxBytesPerSecond
private final BlockingQueue<LeakyBucketStreamThrottler.Request> requestQueue
private final ScheduledExecutorService executorService
private final AtomicBoolean shutdown
public LeakyBucketStreamThrottler(int maxBytesPerSecond)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public OutputStream newThrottledOutputStream(OutputStream toWrap)
newThrottledOutputStream
in interface StreamThrottler
public InputStream newThrottledInputStream(InputStream toWrap)
newThrottledInputStream
in interface StreamThrottler
public long copy(InputStream in, OutputStream out) throws IOException
copy
in interface StreamThrottler
IOException
public long copy(InputStream in, OutputStream out, long maxBytes) throws IOException
copy
in interface StreamThrottler
IOException
Copyright © 2016 Apache NiFi Project. All rights reserved.