public abstract class AbstractAsyncWriter<T>
extends java.lang.Object
implements java.io.Closeable
write(T)
and close()
.
NOTE: Any exception thrown by the underlying Writer will be propagated back to the caller
during the next available call to write(T)
or close()
. After the exception
has been thrown to the caller, it is not safe to attempt further operations on the instance.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_QUEUE_SIZE |
Modifier | Constructor and Description |
---|---|
protected |
AbstractAsyncWriter(int queueSize)
Creates an AbstractAsyncWriter that will use the provided WriterRunnable to consume from the
internal queue and write records into the synchronous writer.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Attempts to finish draining the queue and then calls synchronouslyClose() to allow implementation
to do any one time clean up.
|
protected abstract java.lang.String |
getThreadNamePrefix()
Returns the prefix to use when naming threads.
|
protected abstract void |
synchronouslyClose() |
protected abstract void |
synchronouslyWrite(T item) |
void |
write(T item)
Public method for sub-classes or ultimately consumers to put an item into the queue
to be written out.
|
public static final int DEFAULT_QUEUE_SIZE
protected AbstractAsyncWriter(int queueSize)
protected abstract java.lang.String getThreadNamePrefix()
protected abstract void synchronouslyWrite(T item)
protected abstract void synchronouslyClose()
public void write(T item)
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable