E
- element type.public class SortedKafkaMessageBuffer<E extends Comparable & KafkaMetadataProvider> extends Object implements Buffer<E>
Comparable
.Constructor and Description |
---|
SortedKafkaMessageBuffer() |
SortedKafkaMessageBuffer(int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the messages from this buffer.
|
boolean |
isEmpty() |
E |
peek()
Retrieves, but does not remove, the first message of this buffer, or returns null if this buffer is empty.
|
E |
poll(long timeout,
TimeUnit unit)
Retrieves and removes the first message of this buffer, waiting up to the
specified wait time if necessary for a message to become available.
|
void |
put(E e)
Inserts the specified message in this buffer, waiting
for space to become available if the buffer is full.
|
void |
putAll(Collection<E> c) |
int |
remainingCapacity()
Returns the number of additional elements that this buffer can ideally
(in the absence of memory or resource constraints) accept without
blocking.
|
int |
size()
Returns the number of elements in this buffer.
|
E |
take()
Retrieves and removes the first messages of this buffer, waiting if necessary
until a message becomes available.
|
String |
toString() |
public SortedKafkaMessageBuffer()
public SortedKafkaMessageBuffer(int capacity)
capacity
- the capacity of this buffer.public void put(E e) throws InterruptedException
put
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
InterruptedException
NullPointerException
public void putAll(Collection<E> c) throws InterruptedException
putAll
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
InterruptedException
public E poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the
specified waiting time elapses before a message is availableInterruptedException
- if interrupted while waitingpublic E take() throws InterruptedException
take
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
InterruptedException
- if interrupted while waitingpublic E peek()
peek
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
public int size()
size
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
public boolean isEmpty()
isEmpty
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
public int remainingCapacity()
size
of this buffer.
Note that you cannot always tell if an attempt to insert
an element will succeed by inspecting remainingCapacity
because it may be the case that another thread is about to
insert or remove an element.
remainingCapacity
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
public void clear()
clear
in interface Buffer<E extends Comparable & KafkaMetadataProvider>
Copyright © 2010–2018. All rights reserved.