public class BufferedDataObjectStream extends DataObjectStream
DataObjectStream for performance reasons and
adds a reconnect functionality in case of an error.| Modifier and Type | Field and Description |
|---|---|
protected int |
bufferSize
The buffer size (in bytes) used by this stream.
|
protected boolean |
connected |
protected int |
connectionRetries
the maximum amount of connection retries before the general connection
attempt finally fails
|
private org.slf4j.Logger |
log |
protected long |
reconnectInterval
the time between two connection attempts if the first connection attempt
was unsuccessful
|
protected String |
urlCache
caches the return value of
getConnectionString() |
inputclosed, count, id, in, limit, prefix, seqId, sequenceKey, urlSOURCE_KEY| Constructor and Description |
|---|
BufferedDataObjectStream(InputStream in)
|
BufferedDataObjectStream(SourceURL url)
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes / Resets this connection such that all resources are freed and the
next invocation of
AbstractStream.getInputStream() will return a fresh new
connection to the target. |
protected void |
connect()
Connects to the specified URL.
|
int |
getBufferSize() |
int |
getConnectionRetries() |
protected String |
getConnectionString()
Returns a string representing the connection url (works currently only
with tcp connections).
|
long |
getReconnectInterval() |
void |
init() |
Data |
readNext()
|
void |
setBufferSize(int bufferSize) |
void |
setConnectionRetries(int connectionRetries) |
void |
setReconnectInterval(String reconnectIntervalString) |
getId, getInputStream, getLimit, getPrefix, getSequenceKey, getUrl, read, setId, setLimit, setPrefix, setSequenceKey, setUrlprivate final org.slf4j.Logger log
protected int bufferSize
BufferedInputStream's default buffer size is taken (usually 8192)protected int connectionRetries
protected long reconnectInterval
protected String urlCache
getConnectionString()protected boolean connected
public BufferedDataObjectStream(InputStream in)
public BufferedDataObjectStream(SourceURL url)
public int getBufferSize()
@Parameter(required=false, defaultValue="0", description="The buffer size (in bytes) used by this stream. If set to <= 0: The BufferedInputStream\'s default buffer size is taken (usually 8192)") public void setBufferSize(int bufferSize)
public int getConnectionRetries()
@Parameter(required=false, defaultValue="Integer.MAX_VALUE", description="the maximum amount of connection retries before the general connection attempt finally fails") public void setConnectionRetries(int connectionRetries)
public long getReconnectInterval()
@Parameter(required=false, defaultValue="5s", description="the time between two connection attempts if the first connection attempt was unsuccessful") public void setReconnectInterval(String reconnectIntervalString) throws Exception
Exceptionpublic void init()
throws Exception
init in interface Sourceinit in class DataObjectStreamExceptionSource.init()protected void connect()
throws ConnectException
connectionRetries times if not successful.ConnectException - if it is not possible to connect to the targetpublic Data readNext() throws ConnectException
See BufferedDataObjectStream for details.
readNext in class DataObjectStreamConnectExceptionSource.read()protected String getConnectionString()
Returns a string representing the connection url (works currently only with tcp connections).
TODO Better: Implement and call SourceURL.toString() methodpublic void close()
Closes / Resets this connection such that all resources are freed and the
next invocation of AbstractStream.getInputStream() will return a fresh new
connection to the target.
Does nothing if the connection is not open
close in interface Sourceclose in class DataObjectStreamSource.close()Copyright © 2018. All rights reserved.