public class Connection extends Object implements Runnable
OutputStream| Modifier and Type | Field and Description |
|---|---|
protected LinkedBlockingQueue<Data> |
buffer
the buffer holding the next items that should be transferred to the
client
|
protected int |
bufferSize |
protected ConnectionHandler |
connectionHandler |
protected boolean |
disconnectSlowClients |
private org.slf4j.Logger |
log |
protected ObjectOutputStream |
out |
protected boolean |
running
flag to indicate that the corresponding client is connected and can
receive data
|
protected Socket |
socket
the socket to communicate with the client.
|
| Constructor and Description |
|---|
Connection(ConnectionHandler connectionHandler) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Shuts down this
DataTap.ClientHandler.Releases all resources. Once a DataTap.ClientHandler has been closed, it is not available for
further processing (i.e. |
void |
init(Socket socket,
int bufferSize,
boolean gzip,
boolean disconnectSlowClients) |
boolean |
isRunning() |
void |
run()
This method
creates a client connection shutdown listener (if wanted) in an own
thread
writes the buffered data items to the output stream in an endless
loop
|
String |
toString() |
boolean |
write(Data item)
Adds the specified data item to this client's buffer.
If buffer is not full: Method returns directly and the item is shipped out later by this thread. If buffer is full: Blocking wait for space in the buffer |
private final org.slf4j.Logger log
protected Socket socket
protected LinkedBlockingQueue<Data> buffer
protected boolean running
protected int bufferSize
protected boolean disconnectSlowClients
protected ConnectionHandler connectionHandler
protected ObjectOutputStream out
public Connection(ConnectionHandler connectionHandler)
public void init(Socket socket, int bufferSize, boolean gzip, boolean disconnectSlowClients) throws IOException
IOExceptionpublic void run()
public void close()
DataTap.ClientHandler.DataTap.ClientHandler has been closed, it is not available for
further processing (i.e. can't be reactivated). A new instance needs to
be created.public boolean write(Data item) throws InterruptedException
chunk - InterruptedExceptionpublic boolean isRunning()
Copyright © 2018. All rights reserved.