public class TcpChannelHub extends Object implements net.openhft.chronicle.core.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
TcpChannelHub.Task |
| Modifier and Type | Field and Description |
|---|---|
static int |
HEATBEAT_PING_PERIOD |
static int |
HEATBEAT_TIMEOUT_PERIOD |
protected String |
name |
static int |
SIZE_OF_SIZE |
protected int |
tcpBufferSize |
long |
timeoutMs |
| Constructor and Description |
|---|
TcpChannelHub(SessionProvider sessionProvider,
net.openhft.chronicle.threads.api.EventLoop eventLoop,
java.util.function.Function<net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.wire.Wire> wire,
String name,
SocketAddressSupplier socketAddressSupplier) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkConnection()
blocks until there is a connection
|
void |
close()
called when we are completed finished with using the TcpChannelHub
|
protected void |
closeSocket()
closes the existing connections
|
boolean |
isOpen() |
boolean |
lock(TcpChannelHub.Task r) |
boolean |
lock(TcpChannelHub.Task r,
boolean tryLock) |
long |
nextUniqueTransaction(long timeMs)
the transaction id are generated as unique timestamps
|
ReentrantLock |
outBytesLock() |
net.openhft.chronicle.wire.Wire |
outWire() |
void |
preventSubscribeUponReconnect(long tid)
prevents subscriptions upon reconnect for the following
tid its useful to call this
method when an unsubscribe has been sent to the server, but before the server has acknoleged
the unsubscribe, hence, perverting a resubscribe uppon reconnection. |
net.openhft.chronicle.wire.Wire |
proxyReply(long timeoutTime,
long tid) |
void |
subscribe(AsyncSubscription asyncSubscription)
sets up subscriptions with the server, even if the socket connection is down, the
subscriptions will be re-establish with the server automatically once it comes back up.
|
void |
subscribe(AsyncSubscription asyncSubscription,
boolean tryLock) |
String |
toString() |
void |
unsubscribe(long tid)
closes a subscription established by
net.openhft.chronicle.network.connection.TcpChannelHub#
subscribe(net.openhft.chronicle.network.connection.AsyncSubscription) |
void |
writeAsyncHeader(net.openhft.chronicle.wire.Wire wire,
String csp,
long cid)
The writes the meta data to wire - the async version does not contain the tid
|
void |
writeMetaDataForKnownTID(long tid,
net.openhft.chronicle.wire.Wire wire,
String csp,
long cid) |
long |
writeMetaDataStartTime(long startTime,
net.openhft.chronicle.wire.Wire wire,
String csp,
long cid) |
void |
writeSocket(net.openhft.chronicle.wire.WireOut wire)
sends data to the server via TCP/IP
|
public static final int HEATBEAT_PING_PERIOD
public static final int HEATBEAT_TIMEOUT_PERIOD
public static final int SIZE_OF_SIZE
public final long timeoutMs
@NotNull protected final String name
protected final int tcpBufferSize
public TcpChannelHub(@NotNull
SessionProvider sessionProvider,
@NotNull
net.openhft.chronicle.threads.api.EventLoop eventLoop,
@NotNull
java.util.function.Function<net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.wire.Wire> wire,
@NotNull
String name,
@NotNull
SocketAddressSupplier socketAddressSupplier)
public void preventSubscribeUponReconnect(long tid)
tid its useful to call this
method when an unsubscribe has been sent to the server, but before the server has acknoleged
the unsubscribe, hence, perverting a resubscribe uppon reconnection.tid - unique transcation idpublic void subscribe(@NotNull
AsyncSubscription asyncSubscription)
net.openhft.chronicle.network.connection.TcpChannelHub#unsubscribe(long)asyncSubscription - detail of the subscription that you wish to hold with the serverpublic void subscribe(@NotNull
AsyncSubscription asyncSubscription,
boolean tryLock)
public void unsubscribe(long tid)
net.openhft.chronicle.network.connection.TcpChannelHub#
subscribe(net.openhft.chronicle.network.connection.AsyncSubscription)tid - the unique id of this subscription@NotNull public ReentrantLock outBytesLock()
protected void closeSocket()
public boolean isOpen()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic long nextUniqueTransaction(long timeMs)
timeMs - in millisecondspublic void writeSocket(@NotNull
net.openhft.chronicle.wire.WireOut wire)
wire - the wire containing the outbound datapublic net.openhft.chronicle.wire.Wire proxyReply(long timeoutTime,
long tid)
throws net.openhft.chronicle.bytes.ConnectionDroppedException
net.openhft.chronicle.bytes.ConnectionDroppedExceptionpublic net.openhft.chronicle.wire.Wire outWire()
public long writeMetaDataStartTime(long startTime,
@NotNull
net.openhft.chronicle.wire.Wire wire,
String csp,
long cid)
public void writeMetaDataForKnownTID(long tid,
@NotNull
net.openhft.chronicle.wire.Wire wire,
@Nullable
String csp,
long cid)
public void writeAsyncHeader(@NotNull
net.openhft.chronicle.wire.Wire wire,
String csp,
long cid)
wire - the wire that we will write tocsp - provide either the csp or the cidcid - provide either the csp or the cidpublic boolean lock(@NotNull
TcpChannelHub.Task r)
public boolean lock(@NotNull
TcpChannelHub.Task r,
boolean tryLock)
public void checkConnection()
throws InterruptedException
InterruptedExceptionCopyright © 2015. All rights reserved.