ConnectionHandler (apache-cassandra API)
Date: 2014-10-21

org.apache.cassandra.streaming

## Class ConnectionHandler

- java.lang.Object
- - org.apache.cassandra.streaming.ConnectionHandler

-     public class ConnectionHandler
      extends java.lang.Object

  ConnectionHandler manages incoming/outgoing message exchange for the `StreamSession`.

  Internally, ConnectionHandler manages thread to receive incoming `StreamMessage` and thread to send outgoing message. Messages are encoded/decoded on those thread and handed to `StreamSession.messageReceived(org.apache.cassandra.streaming.messages.StreamMessage)`.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.common.util.concurrent.ListenableFuture<?>` | `close()`
    `void` | `initiate()` Set up incoming message handler and initiate streaming.
    `void` | `initiateOnReceivingSide(java.net.Socket socket, boolean isForOutgoing, int version)` Set up outgoing message handler on receiving side.
    `boolean` | `isOutgoingConnected()`
    `void` | `sendMessage(StreamMessage message)`
    `void` | `sendMessages(java.util.Collection<? extends StreamMessage> messages)` Enqueue messages to be sent.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### initiate

          public void initiate()
                        throws java.io.IOException

      Set up incoming message handler and initiate streaming. This method is called once on initiator.
      Throws:
        `java.io.IOException`

    - #### initiateOnReceivingSide

          public void initiateOnReceivingSide(java.net.Socket socket,
                                     boolean isForOutgoing,
                                     int version)
                                       throws java.io.IOException

      Set up outgoing message handler on receiving side.
      Parameters:
        `socket` - socket to use for `ConnectionHandler.OutgoingMessageHandler`.
        `version` - Streaming message version
      Throws:
        `java.io.IOException`

    - #### close

          public com.google.common.util.concurrent.ListenableFuture<?> close()

    - #### sendMessages

          public void sendMessages(java.util.Collection<? extends StreamMessage> messages)

      Enqueue messages to be sent.
      Parameters:
        `messages` - messages to send

    - #### sendMessage

          public void sendMessage(StreamMessage message)

    - #### isOutgoingConnected

          public boolean isOutgoingConnected()

      Returns:
        true if outgoing connection is opened and ready to send messages

Copyright © 2014 The Apache Software Foundation