public class DataTapSink extends Object implements Sink
This Sink receives data items and transmit them via TCP socket
connections.
It can be used for inter-process- / inter-machine-communication.
Other objects can register themselves to be notified, if a new client
connects to this DataTapSink - see e.g. OnEvent.
To receive the 'new client connect event' they must
CallableEventListener interface andListenerHandler:
#getListenerHandler() and invokeListenerHandler#addListener(CallableEventListener)-method on the
returned object.Listenable interface.
| Modifier and Type | Field and Description |
|---|---|
protected int |
clientBufferSize
The buffer size (number of items) used for each client
|
protected ConnectionHandler |
connectionHandler
|
protected boolean |
detectClientClose
Defines if this sink actively listens to client disconnect events (=
client's input stream read-method returns '-1').
|
protected boolean |
disconnectSlowClients
Defines if slow clients should be disconnected.
|
protected boolean |
gzip
This parameter allows for enabling GZIP compression on the TCP stream,
default is no compression.
|
protected String |
id
contains the
ClientConnectListener that are notified when a new
client connects to this server |
(package private) static org.slf4j.Logger |
log |
protected boolean |
logBufferFull
Defines if the event 'client buffer is full' should be logged.
|
protected Integer |
port
The port to listen on for incoming tap connections, defaults to 9100.
|
| Constructor and Description |
|---|
DataTapSink() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
getClientBufferSize()
Returns the buffer size used for each client
|
String |
getId() |
Integer |
getPort() |
void |
init() |
boolean |
isActivelyDetectClientClose() |
boolean |
isDisconnectSlowClients() |
boolean |
isGzip() |
void |
setClientBufferSize(int clientBufferSize)
Sets the buffer size used for each client
|
void |
setDetectClientClose(boolean activelyDetectClientClose) |
void |
setDisconnectSlowClients(boolean disconnectSlowClients) |
void |
setGzip(boolean gzip) |
void |
setId(String id) |
void |
setPort(Integer port) |
boolean |
write(Collection<Data> data) |
boolean |
write(Data item)
|
protected Integer port
protected int clientBufferSize
protected boolean gzip
protected boolean detectClientClose
protected boolean disconnectSlowClients
protected boolean logBufferFull
static final org.slf4j.Logger log
protected ConnectionHandler connectionHandler
protected String id
ClientConnectListener that are notified when a new
client connects to this serverpublic Integer getPort()
@Parameter(description="The port to listen on for incoming tap connections, defaults to 9100.") public void setPort(Integer port)
port - the port to setpublic int getClientBufferSize()
@Parameter(description="The buffer size (number of items) used for each client", defaultValue="10") public void setClientBufferSize(int clientBufferSize)
clientBufferSize - public boolean isGzip()
@Parameter(description="This parameter allows for enabling GZIP compression on the TCP stream, default is no compression.") public void setGzip(boolean gzip)
gzip - the gzip to setpublic boolean isActivelyDetectClientClose()
@Parameter(required=false, defaultValue="false", description="Defines if this sink actively listens to client disconnect events (= client\'s input stream read-method returns \'-1\').If true, this sink will close the connection immediately if the event occurs.Otherwise a client disconnect will be detected (and the connection will also be closed)the next time, an item should be transferred to the client (and therefore the client\'s output stream write-method is unsuccessful).") public void setDetectClientClose(boolean activelyDetectClientClose)
public boolean isDisconnectSlowClients()
@Parameter(required=false, defaultValue="false", description="Defines if slow clients should be disconnected. A client is defined to be \'slow\', if its buffer is completely filled.") public void setDisconnectSlowClients(boolean disconnectSlowClients)
public boolean write(Collection<Data> data) throws Exception
public boolean write(Data item) throws Exception
This operation blocks if at least one client buffer is exceeded.
Copyright © 2018. All rights reserved.