## org.apache.cassandra.net
Class MessagingService

    java.lang.Object
      org.apache.cassandra.net.MessagingService

All Implemented Interfaces:
  MessagingServiceMBean

    public final class MessagingService

extends java.lang.Object
implements MessagingServiceMBean

Field Summary
`static java.util.EnumSet<StorageService.Verb>` `DROPPABLE_VERBS` Verbs it's okay to drop if the request has been queued longer than RPC_TIMEOUT.
`static java.lang.String` `MBEAN_NAME`
`static int` `version_`
`static int` `VERSION_07`
`static int` `VERSION_080`
`static int` `VERSION_10`

Method Summary
`void` `addLatency(java.net.InetAddress address, double latency)`
`void` `clearCallbacksUnsafe()`
`java.nio.ByteBuffer` `constructStreamHeader(StreamHeader streamHeader, boolean compress, int version)`
`void` `convict(java.net.InetAddress ep)` called from gossiper when it notices a node is not responding.
`int` `getActiveStreamsOutbound()` The count of active outbound stream tasks.
`static int` `getBits(int x, int p, int n)`
`java.util.Map<java.lang.String,java.lang.Long>` `getCommandCompletedTasks()` Completed tasks for Command(Mutations, Read etc) TCP Connections
`java.util.Map<java.lang.String,java.lang.Integer>` `getCommandPendingTasks()` Pending tasks for Command(Mutations, Read etc) TCP Connections
`OutboundTcpConnection` `getConnection(java.net.InetAddress to, Message msg)`
`OutboundTcpConnectionPool` `getConnectionPool(java.net.InetAddress to)`
`static long` `getDefaultCallbackTimeout()`
`java.util.Map<java.lang.String,java.lang.Integer>` `getDroppedMessages()` dropped message counts for server lifetime
`java.util.Map<java.lang.String,java.lang.Integer>` `getRecentlyDroppedMessages()` dropped message counts since last called
`java.util.Map<java.lang.String,java.lang.Long>` `getRecentTimeoutsPerHost()` Number of timeouts since last check per host.
`long` `getRecentTotalTimouts()` Number of timeouts since last check.
`long` `getRegisteredCallbackAge(java.lang.String messageId)`
`java.util.Map<java.lang.String,java.lang.Long>` `getResponseCompletedTasks()` Completed tasks for Response(GOSSIP & RESPONSE) TCP Connections
`java.util.Map<java.lang.String,java.lang.Integer>` `getResponsePendingTasks()` Pending tasks for Response(GOSSIP & RESPONSE) TCP Connections
`java.util.Map<java.lang.String,java.lang.Long>` `getTimeoutsPerHost()` Number of timeouts per host
`long` `getTotalTimeouts()` Total number of timeouts happened on this node
`IVerbHandler` `getVerbHandler(StorageService.Verb type)` This method returns the verb handler associated with the registered verb.
`void` `incrementDroppedMessages(StorageService.Verb verb)`
`static MessagingService` `instance()`
`void` `listen(java.net.InetAddress localEp)` Listen on the specified port.
`void` `maybeAddLatency(IMessageCallback cb, java.net.InetAddress address, double latency)` Track latency information for the dynamic snitch
`void` `receive(Message message, java.lang.String id)`
`void` `register(ILatencySubscriber subcriber)`
`void` `registerVerbHandlers(StorageService.Verb verb, IVerbHandler verbHandler)` Register a verb and the corresponding verb handler with the Messaging Service.
`org.apache.cassandra.net.CallbackInfo` `removeRegisteredCallback(java.lang.String messageId)`
`void` `sendOneWay(Message message, java.net.InetAddress to)`
`void` `sendReply(Message message, java.lang.String id, java.net.InetAddress to)`
`IAsyncResult` `sendRR(Message message, java.net.InetAddress to)`
`java.lang.String` `sendRR(Message message, java.net.InetAddress to, IMessageCallback cb)`
`java.lang.String` `sendRR(Message message, java.net.InetAddress to, IMessageCallback cb, long timeout)` Send a message to a given endpoint.
`java.lang.String` `sendRR(MessageProducer producer, java.net.InetAddress to, IAsyncCallback cb)` Send a message to a given endpoint.
`void` `shutdown()` Wait for callbacks and don't allow any more to be created (since they could require writing hints)
`void` `stream(StreamHeader header, java.net.InetAddress to)` Stream a file from source to destination.
`static void` `validateMagic(int magic)`
`void` `waitForStreaming()`
`void` `waitUntilListening()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MBEAN_NAME

    public static final java.lang.String MBEAN_NAME

See Also:
  Constant Field Values

### VERSION_07

    public static final int VERSION_07

See Also:
  Constant Field Values

### VERSION_080

    public static final int VERSION_080

See Also:
  Constant Field Values

### VERSION_10

    public static final int VERSION_10

See Also:
  Constant Field Values

### version_

    public static final int version_

See Also:
  Constant Field Values

### DROPPABLE_VERBS

    public static final java.util.EnumSet<StorageService.Verb> DROPPABLE_VERBS

  Verbs it's okay to drop if the request has been queued longer than RPC_TIMEOUT. These all correspond to client requests or something triggered by them; we don't want to drop internal messages like bootstrap or repair notifications.

Method Detail

### instance

    public static MessagingService instance()

### maybeAddLatency

    public void maybeAddLatency(IMessageCallback cb,
                                java.net.InetAddress address,
                                double latency)

  Track latency information for the dynamic snitch

  Parameters:
    `cb` - the callback associated with this message -- this lets us know if it's a message type we're interested in
    `address` - the host that replied to the message
    `latency` -

### addLatency

    public void addLatency(java.net.InetAddress address,
                           double latency)

### convict

    public void convict(java.net.InetAddress ep)

  called from gossiper when it notices a node is not responding.

### listen

    public void listen(java.net.InetAddress localEp)
                throws java.io.IOException,
                       ConfigurationException

  Listen on the specified port.

  Parameters:
    `localEp` - InetAddress whose port to listen on.
  Throws:
    `java.io.IOException`
    `ConfigurationException`

### waitUntilListening

    public void waitUntilListening()

### getConnectionPool

    public OutboundTcpConnectionPool getConnectionPool(java.net.InetAddress to)

### getConnection

    public OutboundTcpConnection getConnection(java.net.InetAddress to,
                                               Message msg)

### registerVerbHandlers

    public void registerVerbHandlers(StorageService.Verb verb,
                                     IVerbHandler verbHandler)

  Register a verb and the corresponding verb handler with the Messaging Service.

  Parameters:
    `verb` -
    `verbHandler` - handler for the specified verb

### getVerbHandler

    public IVerbHandler getVerbHandler(StorageService.Verb type)

  This method returns the verb handler associated with the registered verb. If no handler has been registered then null is returned.

  Parameters:
    `type` - for which the verb handler is sought
  Returns:
    a reference to IVerbHandler which is the handler for the specified verb

### sendRR

    public java.lang.String sendRR(Message message,
                                   java.net.InetAddress to,
                                   IMessageCallback cb)

### sendRR

    public java.lang.String sendRR(Message message,
                                   java.net.InetAddress to,
                                   IMessageCallback cb,
                                   long timeout)

  Send a message to a given endpoint. This method specifies a callback which is invoked with the actual response. Also holds the message (only mutation messages) to determine if it needs to trigger a hint (uses StorageProxy for that).

  Parameters:
    `message` - message to be sent.
    `to` - endpoint to which the message needs to be sent
    `cb` - callback interface which is used to pass the responses or suggest that a timeout occurred to the invoker of the send(). suggest that a timeout occurred to the invoker of the send().
    `timeout` - the timeout used for expiration
  Returns:
    an reference to message id used to match with the result

### sendOneWay

    public void sendOneWay(Message message,
                           java.net.InetAddress to)

### sendReply

    public void sendReply(Message message,
                          java.lang.String id,
                          java.net.InetAddress to)

### sendRR

    public java.lang.String sendRR(MessageProducer producer,
                                   java.net.InetAddress to,
                                   IAsyncCallback cb)

  Send a message to a given endpoint. similar to sendRR(Message, InetAddress, IAsyncCallback)

  Parameters:
    `producer` - pro
    `to` - endpoing to which the message needs to be sent
    `cb` - callback that processes responses.
  Returns:
    a reference to the message id use to match with the result.

### sendRR

    public IAsyncResult sendRR(Message message,
                               java.net.InetAddress to)

### stream

    public void stream(StreamHeader header,
                       java.net.InetAddress to)

  Stream a file from source to destination. This is highly optimized to not hold any of the contents of the file in memory.

  Parameters:
    `header` - Header contains file to stream and other metadata.
    `to` - endpoint to which we need to stream the file.

### getActiveStreamsOutbound

    public int getActiveStreamsOutbound()

  The count of active outbound stream tasks.

### register

    public void register(ILatencySubscriber subcriber)

### waitForStreaming

    public void waitForStreaming()
                          throws java.lang.InterruptedException

  Throws:
    `java.lang.InterruptedException`

### clearCallbacksUnsafe

    public void clearCallbacksUnsafe()

### shutdown

    public void shutdown()

  Wait for callbacks and don't allow any more to be created (since they could require writing hints)

### receive

    public void receive(Message message,
                        java.lang.String id)

### removeRegisteredCallback

    public org.apache.cassandra.net.CallbackInfo removeRegisteredCallback(java.lang.String messageId)

### getRegisteredCallbackAge

    public long getRegisteredCallbackAge(java.lang.String messageId)

### validateMagic

    public static void validateMagic(int magic)
                              throws java.io.IOException

  Throws:
    `java.io.IOException`

### getBits

    public static int getBits(int x,
                              int p,
                              int n)

### constructStreamHeader

    public java.nio.ByteBuffer constructStreamHeader(StreamHeader streamHeader,
                                                     boolean compress,
                                                     int version)

### incrementDroppedMessages

    public void incrementDroppedMessages(StorageService.Verb verb)

### getCommandPendingTasks

    public java.util.Map<java.lang.String,java.lang.Integer> getCommandPendingTasks()

  Description copied from interface: `MessagingServiceMBean`
  Pending tasks for Command(Mutations, Read etc) TCP Connections

  Specified by:
    `getCommandPendingTasks` in interface `MessagingServiceMBean`

### getCommandCompletedTasks

    public java.util.Map<java.lang.String,java.lang.Long> getCommandCompletedTasks()

  Description copied from interface: `MessagingServiceMBean`
  Completed tasks for Command(Mutations, Read etc) TCP Connections

  Specified by:
    `getCommandCompletedTasks` in interface `MessagingServiceMBean`

### getResponsePendingTasks

    public java.util.Map<java.lang.String,java.lang.Integer> getResponsePendingTasks()

  Description copied from interface: `MessagingServiceMBean`
  Pending tasks for Response(GOSSIP & RESPONSE) TCP Connections

  Specified by:
    `getResponsePendingTasks` in interface `MessagingServiceMBean`

### getResponseCompletedTasks

    public java.util.Map<java.lang.String,java.lang.Long> getResponseCompletedTasks()

  Description copied from interface: `MessagingServiceMBean`
  Completed tasks for Response(GOSSIP & RESPONSE) TCP Connections

  Specified by:
    `getResponseCompletedTasks` in interface `MessagingServiceMBean`

### getDefaultCallbackTimeout

    public static long getDefaultCallbackTimeout()

### getDroppedMessages

    public java.util.Map<java.lang.String,java.lang.Integer> getDroppedMessages()

  Description copied from interface: `MessagingServiceMBean`
  dropped message counts for server lifetime

  Specified by:
    `getDroppedMessages` in interface `MessagingServiceMBean`

### getRecentlyDroppedMessages

    public java.util.Map<java.lang.String,java.lang.Integer> getRecentlyDroppedMessages()

  Description copied from interface: `MessagingServiceMBean`
  dropped message counts since last called

  Specified by:
    `getRecentlyDroppedMessages` in interface `MessagingServiceMBean`

### getTotalTimeouts

    public long getTotalTimeouts()

  Description copied from interface: `MessagingServiceMBean`
  Total number of timeouts happened on this node

  Specified by:
    `getTotalTimeouts` in interface `MessagingServiceMBean`

### getRecentTotalTimouts

    public long getRecentTotalTimouts()

  Description copied from interface: `MessagingServiceMBean`
  Number of timeouts since last check.

  Specified by:
    `getRecentTotalTimouts` in interface `MessagingServiceMBean`

### getTimeoutsPerHost

    public java.util.Map<java.lang.String,java.lang.Long> getTimeoutsPerHost()

  Description copied from interface: `MessagingServiceMBean`
  Number of timeouts per host

  Specified by:
    `getTimeoutsPerHost` in interface `MessagingServiceMBean`

### getRecentTimeoutsPerHost

    public java.util.Map<java.lang.String,java.lang.Long> getRecentTimeoutsPerHost()

  Description copied from interface: `MessagingServiceMBean`
  Number of timeouts since last check per host.

  Specified by:
    `getRecentTimeoutsPerHost` in interface `MessagingServiceMBean`

Copyright © 2012 The Apache Software Foundation