Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.ubermq.chord.jms
Class ChordMessage  view ChordMessage download ChordMessage.java

java.lang.Object
  extended bycom.ubermq.chord.jms.ChordMessage
Direct Known Subclasses:
ChordNotifyMessage, ChordQueryMessage, ChordStoreMessage, ChordValueMessage

public class ChordMessage
extends java.lang.Object

A chord message represents a query or store operation that occurs on a remote node.

Internally, chord messages are represented as JMS messages, and can be easily converted back and forth.


Field Summary
static java.lang.String CHORD_COMMAND_PROPERTY
          The JMS property that contains the chord command operation value.
static int CHORD_NOOP
          A NOOP performs no operation.
static int CHORD_NOTIFY
          A chord message that notifies a node of a new immediate predecessor.
static int CHORD_QUERY
          A query operation is an Object message that contains the key in the message body, and specifies a JMSReplyTo topic on which the associated value should be sent.
static int CHORD_STORE
          A store operation is an Object message that contains a List of exactly two items: a key and the value to store at the key.
static int CHORD_VALUE
          A chord message that contains a value that is the result of a query operation.
private  int command
           
private  javax.jms.Message m
           
 
Constructor Summary
(package private) ChordMessage(javax.jms.Message m)
          Creates a chord message from an incoming JMS message.
(package private) ChordMessage(javax.jms.Message m, int command)
          Creates a new outgoing chord message with the given JMS message and command code.
 
Method Summary
static ChordMessage createFromIncoming(javax.jms.Message m)
           
static ChordMessage createNotifyMessage(javax.jms.Session session, boolean goingAway, com.ubermq.chord.ChordNode node)
          Creates a notification message, either a standard notify or a notifyGoingAway depending on the goingAway flag specified.
static ChordQueryMessage createQueryMessage(javax.jms.Session session, javax.jms.Topic replyTopic, java.lang.Object key)
          Creates a chord message that represents a store operation.
static ChordMessage createStoreMessage(javax.jms.Session session, java.lang.Object key, java.lang.Object value)
          Creates a chord message that represents a store operation.
static ChordMessage createValueMessage(javax.jms.Session session, long queryId, java.lang.Object key, java.lang.Object value)
          Creates a chord message that represents the reply that is sent as a result of a query operation.
 void execute(javax.jms.TopicSession session, javax.jms.TopicPublisher pub, com.ubermq.chord.ChordNodeProvider p)
          Executes the contained command on the local node specified.
(package private)  int getCommand()
          Returns the chord command (one of the CHORD_xxx constants) that this object represents.
 javax.jms.Message getJMSMessage()
          Provides the underlying JMS message that can be sent over a JMS transport layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m

private javax.jms.Message m

command

private int command

CHORD_COMMAND_PROPERTY

public static final java.lang.String CHORD_COMMAND_PROPERTY
The JMS property that contains the chord command operation value.

See Also:
Constant Field Values

CHORD_NOOP

public static final int CHORD_NOOP
A NOOP performs no operation. It is mainly used to verify that a node is functioning properly.

See Also:
Constant Field Values

CHORD_STORE

public static final int CHORD_STORE
A store operation is an Object message that contains a List of exactly two items: a key and the value to store at the key.

See Also:
Constant Field Values

CHORD_QUERY

public static final int CHORD_QUERY
A query operation is an Object message that contains the key in the message body, and specifies a JMSReplyTo topic on which the associated value should be sent.

See Also:
Constant Field Values

CHORD_VALUE

public static final int CHORD_VALUE
A chord message that contains a value that is the result of a query operation. The value is an Object message containing a List containing the key originally queried, and the value that was discovered, if any.

See Also:
Constant Field Values

CHORD_NOTIFY

public static final int CHORD_NOTIFY
A chord message that notifies a node of a new immediate predecessor. The value is an Object message containing the ChordNode of the new predecessor.

See Also:
Constant Field Values
Constructor Detail

ChordMessage

ChordMessage(javax.jms.Message m)
Creates a chord message from an incoming JMS message.


ChordMessage

ChordMessage(javax.jms.Message m,
             int command)
       throws javax.jms.JMSException
Creates a new outgoing chord message with the given JMS message and command code.

Method Detail

createFromIncoming

public static ChordMessage createFromIncoming(javax.jms.Message m)

createStoreMessage

public static ChordMessage createStoreMessage(javax.jms.Session session,
                                              java.lang.Object key,
                                              java.lang.Object value)
                                       throws javax.jms.JMSException
Creates a chord message that represents a store operation.


createQueryMessage

public static ChordQueryMessage createQueryMessage(javax.jms.Session session,
                                                   javax.jms.Topic replyTopic,
                                                   java.lang.Object key)
                                            throws javax.jms.JMSException
Creates a chord message that represents a store operation.


createValueMessage

public static ChordMessage createValueMessage(javax.jms.Session session,
                                              long queryId,
                                              java.lang.Object key,
                                              java.lang.Object value)
                                       throws javax.jms.JMSException
Creates a chord message that represents the reply that is sent as a result of a query operation.


createNotifyMessage

public static ChordMessage createNotifyMessage(javax.jms.Session session,
                                               boolean goingAway,
                                               com.ubermq.chord.ChordNode node)
                                        throws javax.jms.JMSException
Creates a notification message, either a standard notify or a notifyGoingAway depending on the goingAway flag specified.


getCommand

int getCommand()
Returns the chord command (one of the CHORD_xxx constants) that this object represents.


getJMSMessage

public javax.jms.Message getJMSMessage()
Provides the underlying JMS message that can be sent over a JMS transport layer.


execute

public void execute(javax.jms.TopicSession session,
                    javax.jms.TopicPublisher pub,
                    com.ubermq.chord.ChordNodeProvider p)
             throws javax.jms.JMSException
Executes the contained command on the local node specified.