Package org.apache.cassandra.net
Class OutboundConnection
java.lang.Object
org.apache.cassandra.net.OutboundConnection
Represents a connection type to a peer, and handles the state transistions on the connection and the netty
Channel.
The underlying socket is not opened until explicitly requested (by sending a message).
TODO: complete this description
Aside from a few administrative methods, the main entry point to sending a message is enqueue(Message).
Any thread may send a message (enqueueing it to queue), but only one thread may consume messages from this
queue. There is a single delivery thread - either the event loop, or a companion thread - that has logical ownership
of the queue, but other threads may temporarily take ownership in order to perform book keeping, pruning, etc.,
to ensure system stability.
Runnable.run() is the main entry point for consuming messages from the queue, and executes either on the event
loop or on a non-dedicated companion thread. This processing is activated via OutboundConnection.Delivery.execute().
Almost all internal state maintenance on this class occurs on the eventLoop, a single threaded executor which is
assigned in the constructor. Further details are outlined below in the class. Some behaviours require coordination
between the eventLoop and the companion thread (if any). Some minimal set of behaviours are permitted to occur on
producers to ensure the connection remains healthy and does not overcommit resources.
All methods are safe to invoke from any thread unless otherwise stated.-
Method Summary
Modifier and TypeMethodDescriptionio.netty.util.concurrent.Future<Void>close(boolean flushQueue) Permanently close this connection.longlongdropped()voidThis is the main entry point for enqueuing a message to be sent to the remote peer.longlonglonglongbooleanbooleanClose any currently open connection, forcing a reconnect if there are messages outstanding (or leaving it closed for now otherwise)booleanlonglonglongintlonglonglonglongtoString()type()
-
Method Details
-
enqueue
This is the main entry point for enqueuing a message to be sent to the remote peer.- Throws:
ClosedChannelException
-
interrupt
public boolean interrupt()Close any currently open connection, forcing a reconnect if there are messages outstanding (or leaving it closed for now otherwise) -
close
Permanently close this connection. Immediately prevent any new messages from being enqueued - these will throw ClosedChannelException. The close itself happens asynchronously on the eventLoop, so a Future is returned to help callers wait for its completion. The flushQueue parameter indicates if any outstanding messages should be delivered before closing the connection. - If false, any already flushed or in-progress messages are completed, and the remaining messages are cleared before the connection is promptly torn down. - If true, we attempt delivery of all queued messages. If necessary, we will continue to open new connections to the remote host until they have been delivered. Only if we continue to fail to open a connection for an extended period of time will we drop any outstanding messages and close the connection. -
isConnected
public boolean isConnected() -
toString
-
hasPending
public boolean hasPending() -
pendingCount
public int pendingCount() -
pendingBytes
public long pendingBytes() -
sentCount
public long sentCount() -
sentBytes
public long sentBytes() -
submittedCount
public long submittedCount() -
dropped
public long dropped() -
overloadedBytes
public long overloadedBytes() -
overloadedCount
public long overloadedCount() -
expiredCount
public long expiredCount() -
expiredBytes
public long expiredBytes() -
errorCount
public long errorCount() -
errorBytes
public long errorBytes() -
successfulConnections
public long successfulConnections() -
connectionAttempts
public long connectionAttempts() -
type
-