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 |
TCP_BUFFER |
| Constructor and Description |
|---|
TcpChannelHub(SessionProvider sessionProvider,
net.openhft.chronicle.core.threads.EventLoop eventLoop,
net.openhft.chronicle.wire.WireType wireType,
String name,
SocketAddressSupplier socketAddressSupplier,
boolean shouldSendCloseMessage,
ClientConnectionMonitor clientConnectionMonitor,
net.openhft.chronicle.core.threads.HandlerPriority monitor,
ConnectionStrategy connectionStrategy) |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertAllHubsClosed() |
void |
checkConnection()
blocks until there is a connection
|
void |
close()
called when we are completed finished with using the TcpChannelHub
|
static void |
closeAllHubs() |
void |
forceDisconnect()
you are unlikely to want to call this method in a production environment the purpose of this
method is to simulate a network outage
|
boolean |
isClosed() |
boolean |
isOpen() |
boolean |
isOutBytesEmpty() |
boolean |
isOutBytesLocked() |
boolean |
lock(TcpChannelHub.Task r) |
boolean |
lock2(TcpChannelHub.Task r,
boolean reconnectOnFailure,
TryLock tryLock) |
long |
nextUniqueTransaction(long timeMs)
the transaction id are generated as unique timestamps
|
void |
notifyClosing() |
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 upon reconnection. |
net.openhft.chronicle.wire.Wire |
proxyReply(long timeoutTime,
long tid)
blocks for a message with the appropriate
tid |
void |
subscribe(net.openhft.chronicle.network.connection.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.
|
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,
boolean reconnectOnFailure)
sends data to the server via TCP/IP
|
public TcpChannelHub(@Nullable
SessionProvider sessionProvider,
@NotNull
net.openhft.chronicle.core.threads.EventLoop eventLoop,
@NotNull
net.openhft.chronicle.wire.WireType wireType,
@NotNull
String name,
@NotNull
SocketAddressSupplier socketAddressSupplier,
boolean shouldSendCloseMessage,
@Nullable
ClientConnectionMonitor clientConnectionMonitor,
@NotNull
net.openhft.chronicle.core.threads.HandlerPriority monitor,
@NotNull
ConnectionStrategy connectionStrategy)
public static void assertAllHubsClosed()
public static void closeAllHubs()
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 upon reconnection.tid - unique transaction idpublic void subscribe(@NotNull
net.openhft.chronicle.network.connection.AsyncSubscription asyncSubscription)
net.openhft.chronicle.network.connection.TcpChannelHub#unsubscribe(long)asyncSubscription - detail of the subscription that you wish to hold with the serverpublic 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()
public boolean isOpen()
public boolean isClosed()
public void notifyClosing()
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,
boolean reconnectOnFailure)
wire - the wire containing the outbound datapublic net.openhft.chronicle.wire.Wire proxyReply(long timeoutTime,
long tid)
throws net.openhft.chronicle.bytes.ConnectionDroppedException,
TimeoutException
tidtimeoutTime - the amount of time to wait ( in MS ) before a time out exceptionstid - the tid of the message that we are waiting fortidnet.openhft.chronicle.bytes.ConnectionDroppedExceptionTimeoutExceptionpublic net.openhft.chronicle.wire.Wire outWire()
public boolean isOutBytesLocked()
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 lock2(@NotNull
TcpChannelHub.Task r,
boolean reconnectOnFailure,
@NotNull
TryLock tryLock)
public void checkConnection()
public void forceDisconnect()
public boolean isOutBytesEmpty()
Copyright © 2017. All rights reserved.