public class TableClient extends Object implements AutoCloseable
This is intended as an illustration, not necessarily the most efficient way to implement a client.
Depending on the context, it may be desirable to implement an alternative to SimpleMessageHandler in a way
that avoids memory allocation, decoding incoming SBE messages into existing buffers.
| Constructor and Description |
|---|
TableClient(String host,
int port,
MessageHandler messageHandler)
Start a new table client, connecting to the given host and port.
|
TableClient(String host,
int port,
MessageHandler messageHandler,
boolean allocateDirect)
Start a new table client, connecting to the given host and port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the table client.
|
boolean |
isAlive()
Return if the client is still alive and processing incoming messages.
|
void |
subscribe(int subscriptionId,
SubscribeMode subscribeMode,
String name)
Subscribe to an exported table.
|
void |
subscribe(int subscriptionId,
SubscribeMode subscribeMode,
String name,
List<String> columnNames)
Subscribe to an exported table.
|
void |
subscribe(int subscriptionId,
SubscribeMode subscribeMode,
String name,
List<String> columnNames,
String filter)
Subscribe to updates on the given columns for the table identified by the given name.
|
void |
unsubscribe(int subscriptionId)
Unsubscribe from updates for the given subscription id.
|
public TableClient(String host, int port, MessageHandler messageHandler, boolean allocateDirect) throws IOException
host - Host on which the TableServer is runningport - Port on which the TableServer is boundmessageHandler - Object which handles incoming messages from the serverallocateDirect - If true, use direct (off-heap) buffers to allocate message buffersIOException - If there is an error while connecting to the serverpublic TableClient(String host, int port, MessageHandler messageHandler) throws IOException
TableClient.TableClient(String, int, MessageHandler, boolean)host - Host on which the TableServer is runningport - Port on which the TableServer is boundmessageHandler - Object which handles incoming messages from the serverIOException - If there is an error while connecting to the serverpublic boolean isAlive()
TableClient.close() method.public void close()
throws InterruptedException,
IOException
close in interface AutoCloseableInterruptedException - If interrupted while waiting for receive thread to dieIOException - If an error occurs while closing the socketpublic void subscribe(int subscriptionId,
SubscribeMode subscribeMode,
String name,
List<String> columnNames)
throws IOException
subscriptionId - A client generated unique identifier for this subscriptionsubscribeMode - Specifies whether the client is requesting an initial snapshot, update stream, or bothname - Exported table name (see exportTable on TableServer)columnNames - List of columns for for which to receive updates (specify null for all columns)IOException - If an error occurs while sending to the serverpublic void subscribe(int subscriptionId,
SubscribeMode subscribeMode,
String name)
throws IOException
subscriptionId - A client generated unique identifier for this subscriptionsubscribeMode - Specifies whether the client is requesting an initial snapshot, update stream, or bothname - Exported table name (see exportTable on TableServer)IOException - If an error occurs while sending to the serverpublic void subscribe(int subscriptionId,
SubscribeMode subscribeMode,
String name,
List<String> columnNames,
String filter)
throws IOException
subscriptionId - A client generated unique identifier for this subscriptionsubscribeMode - Specifies whether the client is requesting an initial snapshot, update stream, or bothname - Exported table name (see exportTable on TableServer)columnNames - List of columns for for which to receive updates (specify null for all columns)filter - An expression to be used in a "where" clause to filter the desired table; in this way, only rows
matching specified the criteria can be monitored (specify null for no filter)IOException - If an error occurs while sending to the serverpublic void unsubscribe(int subscriptionId)
throws IOException
subscriptionId - A subscription id previously used in a subscribe callIOException - If an error occurs while sending to the server