org.apache.cassandra.net
Class MessagingService

java.lang.Object
  extended by org.apache.cassandra.net.MessagingService
All Implemented Interfaces:
MessagingServiceMBean

public final class MessagingService
extends java.lang.Object
implements MessagingServiceMBean


Field Summary
static int version_
           
 
Method Summary
 void addLatency(java.net.InetAddress address, double latency)
           
 java.nio.ByteBuffer constructStreamHeader(StreamHeader streamHeader, boolean compress)
           
 void convict(java.net.InetAddress ep)
          called from gossiper when it notices a node is not responding.
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)
           
 org.apache.cassandra.net.OutboundTcpConnectionPool getConnectionPool(java.net.InetAddress to)
           
 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
 IVerbHandler getVerbHandler(StorageService.Verb type)
          This method returns the verb handler associated with the registered verb.
 int 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
 java.nio.ByteBuffer packIt(byte[] bytes, boolean compress)
           
 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.
 Pair<java.net.InetAddress,IMessageCallback> 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)
          Send a message to a given endpoint.
 void shutdown()
           
 void stream(StreamHeader header, java.net.InetAddress to)
          Stream a file from source to destination.
static void validateMagic(int magic)
           
 void waitFor()
          blocks until the processing pools are empty and done.
 void waitUntilListening()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version_

public static final int version_
See Also:
Constant Field Values
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 org.apache.cassandra.net.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)
Send a message to a given endpoint. This method specifies a callback which is invoked with the actual response.

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().
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 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.

register

public void register(ILatencySubscriber subcriber)

waitFor

public void waitFor()
             throws java.lang.InterruptedException
blocks until the processing pools are empty and done.

Throws:
java.lang.InterruptedException

shutdown

public void shutdown()

receive

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

removeRegisteredCallback

public Pair<java.net.InetAddress,IMessageCallback> 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)

packIt

public java.nio.ByteBuffer packIt(byte[] bytes,
                                  boolean compress)

constructStreamHeader

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

incrementDroppedMessages

public int 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


Copyright © 2011 The Apache Software Foundation