Package tigase.cluster.api

## Class ClusterElement

- java.lang.Object
- - tigase.cluster.api.ClusterElement

-     public class ClusterElement
      extends java.lang.Object

  Class ClusterElement is a utility class for handling tigase cluster specific packets. The cluster packet has the following form:
  `<cluster xmlns="tigase:cluster" from="source" to="dest" type="set"> <data> <message xmlns="jabber:client" from="source-u" to="dest-x" type="chat"> <body>Hello world!</body> </message> </data> <control> <first-node>node1 JID address</first-node> <visited-nodes> <node-id>node1 JID address</node-id> <node-id>node2 JID address</node-id> </visited-nodes> <method-call name="method name"> <par name="param1 name">value</par> <par name="param2 name">value</par> <results> <val name="val1 name">value</var> <val name="val2 name">value</var> </results> </method-call> </control> </cluster>`
  If none of nodes could process the packet it goes back to the first node as this node is the most likely to process the packet correctly.
  Created: Fri May 2 09:40:40 2008
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `CLUSTER_CONTROL_EL_NAME` |
    `static java.lang.String[]` | `CLUSTER_CONTROL_PATH` |
    `static java.lang.String` | `CLUSTER_DATA_EL_NAME` |
    `static java.lang.String[]` | `CLUSTER_DATA_PATH` |
    `static java.lang.String` | `CLUSTER_EL_NAME` |
    `static java.lang.String` | `CLUSTER_METHOD_EL_NAME` |
    `static java.lang.String` | `CLUSTER_METHOD_PAR_EL_NAME` |
    `static java.lang.String[]` | `CLUSTER_METHOD_PATH` |
    `static java.lang.String` | `CLUSTER_METHOD_RESULTS_EL_NAME` |
    `static java.lang.String[]` | `CLUSTER_METHOD_RESULTS_PATH` |
    `static java.lang.String` | `CLUSTER_METHOD_RESULTS_VAL_EL_NAME` |
    `static java.lang.String` | `CLUSTER_NAME_ATTR` |
    `static java.lang.String` | `FIRST_NODE_EL_NAME` |
    `static java.lang.String[]` | `FIRST_NODE_PATH` |
    `static java.lang.String` | `NODE_ID_EL_NAME` |
    `static java.lang.String` | `VISITED_NODES_EL_NAME` |
    `static java.lang.String[]` | `VISITED_NODES_PATH` |
    `static java.lang.String` | `XMLNS` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ClusterElement​(Element elem)` | Creates a new `ClusterElement` instance.
    `ClusterElement​(JID from, JID to, StanzaType type, Packet packet)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addDataPacket​(Packet packet)` |
    `void` | `addDataPacket​(Element packet)` |
    `void` | `addDataPackets​(java.util.Queue<Element> packets)` |
    `void` | `addMethodResult​(java.lang.String key, java.lang.String val)` |
    `void` | `addVisitedNode​(JID node_id)` |
    `void` | `addVisitedNodes​(java.util.Set<JID> nodes)` |
    `static Element` | `clusterElement​(JID from, JID to, StanzaType type)` |
    `static Element` | `createClusterElement​(JID from, JID to, StanzaType type, java.lang.String packet_from)` |
    `static ClusterElement` | `createClusterMethodCall​(JID from, JID to, StanzaType type, java.lang.String method_name, java.util.Map<java.lang.String,​java.lang.String> params)` |
    `static ClusterElement` | `createForNextNode​(ClusterElement clel, java.util.List<JID> cluster_nodes, JID comp_id)` |
    `ClusterElement` | `createMethodResponse​(JID from, JID to, StanzaType type, java.util.Map<java.lang.String,​java.lang.String> results)` |
    `ClusterElement` | `createMethodResponse​(JID from, StanzaType type, java.util.Map<java.lang.String,​java.lang.String> results)` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getAllMethodParams()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getAllMethodResults()` |
    `Element` | `getClusterElement​(java.lang.String id)` |
    `java.util.Queue<Element>` | `getDataPackets()` |
    `JID` | `getFirstNode()` |
    `java.lang.String` | `getMethodName()` |
    `java.lang.String` | `getMethodParam​(java.lang.String par_name)` |
    `long` | `getMethodParam​(java.lang.String par_name, long def)` |
    `java.lang.String` | `getMethodResultVal​(java.lang.String val_name)` |
    `long` | `getMethodResultVal​(java.lang.String val_name, long def)` |
    `Priority` | `getPriority()` |
    `java.util.Set<JID>` | `getVisitedNodes()` |
    `boolean` | `isVisitedNode​(JID node_id)` |
    `ClusterElement` | `nextClusterNode​(JID node_id)` |
    `protected void` | `parseMethodCall​(Element method_call)` |
    `void` | `setPriority​(Priority priority)` |

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

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

- - ### Field Detail

    - #### CLUSTER_CONTROL_EL_NAME

          public static final java.lang.String CLUSTER_CONTROL_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_DATA_EL_NAME

          public static final java.lang.String CLUSTER_DATA_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_EL_NAME

          public static final java.lang.String CLUSTER_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_METHOD_EL_NAME

          public static final java.lang.String CLUSTER_METHOD_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_METHOD_PAR_EL_NAME

          public static final java.lang.String CLUSTER_METHOD_PAR_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_METHOD_RESULTS_EL_NAME

          public static final java.lang.String CLUSTER_METHOD_RESULTS_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_METHOD_RESULTS_VAL_EL_NAME

          public static final java.lang.String CLUSTER_METHOD_RESULTS_VAL_EL_NAME

      See Also:
        Constant Field Values

    - #### CLUSTER_NAME_ATTR

          public static final java.lang.String CLUSTER_NAME_ATTR

      See Also:
        Constant Field Values

    - #### FIRST_NODE_EL_NAME

          public static final java.lang.String FIRST_NODE_EL_NAME

      See Also:
        Constant Field Values

    - #### NODE_ID_EL_NAME

          public static final java.lang.String NODE_ID_EL_NAME

      See Also:
        Constant Field Values

    - #### VISITED_NODES_EL_NAME

          public static final java.lang.String VISITED_NODES_EL_NAME

      See Also:
        Constant Field Values

    - #### XMLNS

          public static final java.lang.String XMLNS

      See Also:
        Constant Field Values

    - #### VISITED_NODES_PATH

          public static final java.lang.String[] VISITED_NODES_PATH

    - #### FIRST_NODE_PATH

          public static final java.lang.String[] FIRST_NODE_PATH

    - #### CLUSTER_METHOD_RESULTS_PATH

          public static final java.lang.String[] CLUSTER_METHOD_RESULTS_PATH

    - #### CLUSTER_METHOD_PATH

          public static final java.lang.String[] CLUSTER_METHOD_PATH

    - #### CLUSTER_DATA_PATH

          public static final java.lang.String[] CLUSTER_DATA_PATH

    - #### CLUSTER_CONTROL_PATH

          public static final java.lang.String[] CLUSTER_CONTROL_PATH

  - ### Constructor Detail

    - #### ClusterElement

          public ClusterElement​(Element elem)

      Creates a new `ClusterElement` instance.

    - #### ClusterElement

          public ClusterElement​(JID from,
                                JID to,
                                StanzaType type,
                                Packet packet)

  - ### Method Detail

    - #### clusterElement

          public static Element clusterElement​(JID from,
                                               JID to,
                                               StanzaType type)

    - #### createClusterElement

          public static Element createClusterElement​(JID from,
                                                     JID to,
                                                     StanzaType type,
                                                     java.lang.String packet_from)

    - #### createClusterMethodCall

          public static ClusterElement createClusterMethodCall​(JID from,
                                                               JID to,
                                                               StanzaType type,
                                                               java.lang.String method_name,
                                                               java.util.Map<java.lang.String,​java.lang.String> params)

    - #### createForNextNode

          public static ClusterElement createForNextNode​(ClusterElement clel,
                                                         java.util.List<JID> cluster_nodes,
                                                         JID comp_id)

    - #### addDataPacket

          public void addDataPacket​(Packet packet)

    - #### addDataPacket

          public void addDataPacket​(Element packet)

    - #### addDataPackets

          public void addDataPackets​(java.util.Queue<Element> packets)

    - #### addMethodResult

          public void addMethodResult​(java.lang.String key,
                                      java.lang.String val)

    - #### addVisitedNode

          public void addVisitedNode​(JID node_id)

    - #### addVisitedNodes

          public void addVisitedNodes​(java.util.Set<JID> nodes)

    - #### createMethodResponse

          public ClusterElement createMethodResponse​(JID from,
                                                     StanzaType type,
                                                     java.util.Map<java.lang.String,​java.lang.String> results)

    - #### createMethodResponse

          public ClusterElement createMethodResponse​(JID from,
                                                     JID to,
                                                     StanzaType type,
                                                     java.util.Map<java.lang.String,​java.lang.String> results)

    - #### getAllMethodParams

          public java.util.Map<java.lang.String,​java.lang.String> getAllMethodParams()

    - #### getAllMethodResults

          public java.util.Map<java.lang.String,​java.lang.String> getAllMethodResults()

    - #### getClusterElement

          public Element getClusterElement​(java.lang.String id)

    - #### getDataPackets

          public java.util.Queue<Element> getDataPackets()

    - #### getFirstNode

          public JID getFirstNode()

    - #### getMethodName

          public java.lang.String getMethodName()

    - #### getMethodParam

          public java.lang.String getMethodParam​(java.lang.String par_name)

    - #### getMethodParam

          public long getMethodParam​(java.lang.String par_name,
                                     long def)

    - #### getMethodResultVal

          public java.lang.String getMethodResultVal​(java.lang.String val_name)

    - #### getMethodResultVal

          public long getMethodResultVal​(java.lang.String val_name,
                                         long def)

    - #### getPriority

          public Priority getPriority()

    - #### setPriority

          public void setPriority​(Priority priority)

    - #### getVisitedNodes

          public java.util.Set<JID> getVisitedNodes()

    - #### isVisitedNode

          public boolean isVisitedNode​(JID node_id)

    - #### nextClusterNode

          public ClusterElement nextClusterNode​(JID node_id)

    - #### parseMethodCall

          protected void parseMethodCall​(Element method_call)