org.codehaus.activecluster
Interface Cluster

All Superinterfaces:
Service
All Known Implementing Classes:
DefaultCluster

public interface Cluster
extends Service

Represents a logical connection to a cluster. From this object you can obtain the destination to send messages to, view the members of the cluster, watch cluster events (nodes joining, leaving, updating their state) as well as viewing each members state.

You may also update the local node's state.

Version:
$Revision: 1.6 $

Method Summary
 void addClusterListener(ClusterListener listener)
          Adds a new listener to cluster events
 BytesMessage createBytesMessage()
          Creates a new bytes message
 MessageConsumer createConsumer(Destination destination)
          Creates a consumer of all the messags sent to the given destination, including messages sent via the send() messages
 MessageConsumer createConsumer(Destination destination, String selector)
          Creates a consumer of all message sent to the given destination, including messages sent via the send() message with an optional SQL 92 based selector to filter messages
 MessageConsumer createConsumer(Destination destination, String selector, boolean noLocal)
          Creates a consumer of all message sent to the given destination, including messages sent via the send() message with an optional SQL 92 based selector to filter messages along with optionally ignoring local traffic - messages sent via the send() method on this object.
 MapMessage createMapMessage()
          Creates a new MapMessage
 Message createMessage()
          Creates a new message without a body
 ObjectMessage createObjectMessage()
          Creates a new ObjectMessage
 ObjectMessage createObjectMessage(Serializable object)
          Creates a new ObjectMessage
 StreamMessage createStreamMessage()
          Creates a new StreamMessage
 TextMessage createTextMessage()
          Creates a new TextMessage
 TextMessage createTextMessage(String text)
          Creates a new TextMessage
 Topic getDestination()
          Returns the destination used to send a message to all members of the cluster
 LocalNode getLocalNode()
          The local Node which allows you to mutate the state or subscribe to the nodes temporary queue for inbound messages direct to the Node
 Map getNodes()
          A snapshot of the nodes in the cluster indexed by the Destination
 void removeClusterListener(ClusterListener listener)
          Removes a listener to cluster events
 void send(Destination destination, Message message)
          Sends a message to a destination, which could be to the entire group or could be a single Node's destination
 boolean waitForClusterToComplete(int expectedCount, long timeout)
          wait until a the cardimality of the cluster is reaches the expected count.
 
Methods inherited from interface org.codehaus.activecluster.Service
start, stop
 

Method Detail

getDestination

public Topic getDestination()
Returns the destination used to send a message to all members of the cluster

Returns:
the destination to send messages to all members of the cluster

getNodes

public Map getNodes()
A snapshot of the nodes in the cluster indexed by the Destination


addClusterListener

public void addClusterListener(ClusterListener listener)
Adds a new listener to cluster events

Parameters:
listener -

removeClusterListener

public void removeClusterListener(ClusterListener listener)
Removes a listener to cluster events

Parameters:
listener -

getLocalNode

public LocalNode getLocalNode()
The local Node which allows you to mutate the state or subscribe to the nodes temporary queue for inbound messages direct to the Node


send

public void send(Destination destination,
                 Message message)
          throws JMSException
Sends a message to a destination, which could be to the entire group or could be a single Node's destination

Parameters:
destination - is either the group topic or a node's destination
message - the message to be sent
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination)
                               throws JMSException
Creates a consumer of all the messags sent to the given destination, including messages sent via the send() messages

Parameters:
destination -
Returns:
a newly created message consumer
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      String selector)
                               throws JMSException
Creates a consumer of all message sent to the given destination, including messages sent via the send() message with an optional SQL 92 based selector to filter messages

Parameters:
destination -
selector -
Returns:
a newly created message consumer
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      String selector,
                                      boolean noLocal)
                               throws JMSException
Creates a consumer of all message sent to the given destination, including messages sent via the send() message with an optional SQL 92 based selector to filter messages along with optionally ignoring local traffic - messages sent via the send() method on this object.

Parameters:
destination - the destination to consume from
selector - an optional SQL 92 filter of messages which could be null
noLocal - which if true messages sent via send() on this object will not be delivered to the consumer
Returns:
a newly created message consumer
Throws:
JMSException

createMessage

public Message createMessage()
                      throws JMSException
Creates a new message without a body

Throws:
JMSException

createBytesMessage

public BytesMessage createBytesMessage()
                                throws JMSException
Creates a new bytes message

Throws:
JMSException

createMapMessage

public MapMessage createMapMessage()
                            throws JMSException
Creates a new MapMessage

Throws:
JMSException

createObjectMessage

public ObjectMessage createObjectMessage()
                                  throws JMSException
Creates a new ObjectMessage

Throws:
JMSException

createObjectMessage

public ObjectMessage createObjectMessage(Serializable object)
                                  throws JMSException
Creates a new ObjectMessage

Parameters:
object -
Throws:
JMSException

createStreamMessage

public StreamMessage createStreamMessage()
                                  throws JMSException
Creates a new StreamMessage

Throws:
JMSException

createTextMessage

public TextMessage createTextMessage()
                              throws JMSException
Creates a new TextMessage

Throws:
JMSException

createTextMessage

public TextMessage createTextMessage(String text)
                              throws JMSException
Creates a new TextMessage

Parameters:
text -
Throws:
JMSException

waitForClusterToComplete

public boolean waitForClusterToComplete(int expectedCount,
                                        long timeout)
                                 throws InterruptedException
wait until a the cardimality of the cluster is reaches the expected count. This method will return false if the cluster isn't started or stopped while waiting

Parameters:
expectedCount - the number of expected members of a cluster
timeout - timeout in milliseconds
Returns:
true if the cluster is fully connected
Throws:
InterruptedException


Copyright © 2004-2005 Protique, Ltd.. All Rights Reserved.