xmlBlaster 2.2.0 API

org.xmlBlaster.engine.cluster
Class ClusterNode

java.lang.Object
  extended by org.xmlBlaster.engine.cluster.ClusterNode
All Implemented Interfaces:
java.lang.Comparable, I_Callback, I_ConnectionStateListener, ClusterNodeMBean

public final class ClusterNode
extends java.lang.Object
implements java.lang.Comparable, I_Callback, I_ConnectionStateListener, ClusterNodeMBean

This class holds the informations about an xmlBlaster server instance (=cluster node).

It collects the node informations from NodeInfo.java, NodeMasterInfo.java and NodeStateInfo.java


Field Summary
private  boolean available
           
private  I_ConnectionStateListener connectionStateListener
           
private  ContextNode contextNode
           
private  ServerScope fatherGlob
           
private  boolean isAllowed
          Currently always true, needs to be configurable !!! TODO
private static java.util.logging.Logger log
           
private  java.util.Map masterInfoMap
          Hold mapping informations to map a message to a master node.
private  java.lang.Object mbeanHandle
          My JMX registration
private  java.lang.String ME
           
private  NodeConnectQos nodeInfo
          Holds address and backup informations
private  Global remoteGlob
          This util global instance is used for I_XmlBlasterAccess, it uses the specific settings from NodeInfo to connect to the remote node
private  SessionInfo sessionInfo
           
private  NodeStateInfo state
          Holds performance informations for load balancing
private  I_XmlBlasterAccess xmlBlasterConnection
           
 
Constructor Summary
ClusterNode(ServerScope glob, NodeId nodeId, SessionInfo sessionInfo)
          Create an object holding all informations about a node
 
Method Summary
 void addNodeMasterInfo(NodeMasterInfo domainInfo)
          Set the filter rules to determine the master of a message.
 int compareTo(java.lang.Object obj)
          Needed for TreeSet and MapSet, implements Comparable.
 java.lang.String destroy()
          For JMX only.
 I_Queue getConnectionQueue()
           
 int getConnectionState()
          Returns the current connection state to the node.
 java.lang.String getConnectionStateStr()
          For JMX access.
 ContextNode getContextNode()
           
 java.lang.String getId()
          Convenience, delegates call to NodeInfo.
 NodeId getNodeId()
          Convenience, delegates call to NodeInfo.
 NodeConnectQos getNodeInfo()
          Access the current nodeInfo of the node.
 NodeMasterInfo[] getNodeMasterInfos()
          Access the filter rules to determine the master of a message.
 NodeStateInfo getNodeStateInfo()
          Access the current state of the node, like current CPU and memory informations.
 Global getRemoteGlob()
           
 SessionName getRemoteSessionName()
          Contains remote clusterNodeId
 SessionName getSessionName()
          Directly from xmlBlasterAccess, may not contain clusterNodeId
 I_XmlBlasterAccess getXmlBlasterAccess()
          On first invocation we connect to the other xmlBlaster cluster node.
 boolean isAlive()
          Check if we currently have an open connection to this node.
 boolean isAllowed()
          Is this node usable.
 boolean isAvailable()
           
 boolean isConnected()
          Check if we have currently a functional connection to this node.
 boolean isLocalNode()
          Check if we have currently a functional connection to this node.
 boolean isPolling()
          Check if we are currently polling for a connection to this node.
 void ping()
          Force a async ping to re-check connection to server.
 void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was established.
 void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE.
 void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was lost.
 void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was lost.
 void registerConnectionListener(I_ConnectionStateListener connectionListener)
          Register a listener to get events about connection status changes.
 void removeNodeMasterInfo(NodeMasterInfo domainInfo)
           
 java.lang.String replace(NodeMasterInfo old, java.lang.String xmlNew)
           
 void resetXmlBlasterAccess(boolean force)
           
 void setAllowed(boolean allowed)
           
 void setNodeId(NodeId nodeId)
          Convenience, delegates call to NodeInfo.
 void setNodeInfo(NodeConnectQos nodeInfo)
          Overwrite the current nodeInfo of the node.
 void setNodeStateInfo(NodeStateInfo state)
          Access the current state of the node, like current CPU and memory informations.
 void shutdown()
           
 java.lang.String toString()
           
 java.lang.String toXml()
          Dump state of this object into a XML ASCII string.
 java.lang.String toXml(java.lang.String extraOffset, java.util.Properties props)
          Dump state of this object into a XML ASCII string.
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          This is the callback method invoked from xmlBlaster delivering us a new asynchronous message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ME

private final java.lang.String ME

fatherGlob

private final ServerScope fatherGlob

remoteGlob

private final Global remoteGlob
This util global instance is used for I_XmlBlasterAccess, it uses the specific settings from NodeInfo to connect to the remote node


log

private static java.util.logging.Logger log

sessionInfo

private final SessionInfo sessionInfo

xmlBlasterConnection

private I_XmlBlasterAccess xmlBlasterConnection

available

private boolean available

nodeInfo

private NodeConnectQos nodeInfo
Holds address and backup informations


state

private NodeStateInfo state
Holds performance informations for load balancing


connectionStateListener

private I_ConnectionStateListener connectionStateListener

masterInfoMap

private java.util.Map masterInfoMap
Hold mapping informations to map a message to a master node. The key is the query string -> to avoid duplicate identical queries The value is an instance of NodeMasterInfo


isAllowed

private boolean isAllowed
Currently always true, needs to be configurable !!! TODO


contextNode

private ContextNode contextNode

mbeanHandle

private java.lang.Object mbeanHandle
My JMX registration

Constructor Detail

ClusterNode

public ClusterNode(ServerScope glob,
                   NodeId nodeId,
                   SessionInfo sessionInfo)
            throws XmlBlasterException
Create an object holding all informations about a node

Throws:
XmlBlasterException
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getId

public java.lang.String getId()
Convenience, delegates call to NodeInfo.

Returns:
The unique name of the managed xmlBlaster instance e.g. "bilbo.mycompany.com"

getNodeId

public NodeId getNodeId()
Convenience, delegates call to NodeInfo.

Returns:
The unique name of the managed xmlBlaster instance

setNodeId

public void setNodeId(NodeId nodeId)
Convenience, delegates call to NodeInfo.

Parameters:
The - unique name of the managed xmlBlaster instance

registerConnectionListener

public void registerConnectionListener(I_ConnectionStateListener connectionListener)
Register a listener to get events about connection status changes.

Parameters:
connectionListener - null or your listener implementation on connection state changes (ALIVE | POLLING | DEAD)
See Also:
client.failsafe requirement

ping

public void ping()
Force a async ping to re-check connection to server. Status change is got asynchronously via registerConnectionListener()


getXmlBlasterAccess

public I_XmlBlasterAccess getXmlBlasterAccess()
                                       throws XmlBlasterException
On first invocation we connect to the other xmlBlaster cluster node.

The failsafe mode is switched on, you can configure it with a connect qos markup.

Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess, I_XmlBlasterAccess.registerConnectionListener(org.xmlBlaster.client.I_ConnectionStateListener)

resetXmlBlasterAccess

public void resetXmlBlasterAccess(boolean force)
Parameters:
force - shutdown even if no was configured

getNodeInfo

public NodeConnectQos getNodeInfo()
Access the current nodeInfo of the node. This configures the connection string.


setNodeInfo

public void setNodeInfo(NodeConnectQos nodeInfo)
Overwrite the current nodeInfo of the node.


getNodeStateInfo

public NodeStateInfo getNodeStateInfo()
Access the current state of the node, like current CPU and memory informations.


setNodeStateInfo

public void setNodeStateInfo(NodeStateInfo state)
Access the current state of the node, like current CPU and memory informations.


getNodeMasterInfos

public NodeMasterInfo[] getNodeMasterInfos()
Access the filter rules to determine the master of a message.

Returns:
The map contains NodeMasterInfo objects, it is never null Please treat as read only or synchronize over the map

replace

public java.lang.String replace(NodeMasterInfo old,
                                java.lang.String xmlNew)

addNodeMasterInfo

public void addNodeMasterInfo(NodeMasterInfo domainInfo)
Set the filter rules to determine the master of a message.


removeNodeMasterInfo

public void removeNodeMasterInfo(NodeMasterInfo domainInfo)

getConnectionQueue

public I_Queue getConnectionQueue()

getRemoteSessionName

public SessionName getRemoteSessionName()
Contains remote clusterNodeId

Returns:
null if not known

getSessionName

public SessionName getSessionName()
Directly from xmlBlasterAccess, may not contain clusterNodeId

Returns:
null if not known

isConnected

public boolean isConnected()
                    throws XmlBlasterException
Check if we have currently a functional connection to this node.

Note: A call to this check does try to login if the connection was not initialized before. This is sometimes an unwanted behavior. On the other hand, without trying to login it is difficult to determine the connection state.

Throws:
XmlBlasterException

isPolling

public boolean isPolling()
                  throws XmlBlasterException
Check if we are currently polling for a connection to this node.

Note: A call to this check does try to login if the connection was not initialized before. This is sometimes an unwanted behavior. On the other hand, without trying to login it is difficult to determine the connection state.

Throws:
XmlBlasterException

isAlive

public boolean isAlive()
                throws XmlBlasterException
Check if we currently have an open connection to this node.

Returns:
Always true for the local node
Throws:
XmlBlasterException

isAllowed

public boolean isAllowed()
Is this node usable.

Specified by:
isAllowed in interface ClusterNodeMBean
Returns:
true if we are logged in or are polling for the node
false if the node should not be used

setAllowed

public void setAllowed(boolean allowed)
Specified by:
setAllowed in interface ClusterNodeMBean

getConnectionStateStr

public java.lang.String getConnectionStateStr()
For JMX access.

Specified by:
getConnectionStateStr in interface ClusterNodeMBean
Returns:

getConnectionState

public int getConnectionState()
                       throws XmlBlasterException
Returns the current connection state to the node.

Returns:
0 -> We are logged in
1 -> We are polling for this node
2 -> The node is not allowed to use
Throws:
XmlBlasterException

isLocalNode

public boolean isLocalNode()
Check if we have currently a functional connection to this node.

Specified by:
isLocalNode in interface ClusterNodeMBean

compareTo

public int compareTo(java.lang.Object obj)
Needed for TreeSet and MapSet, implements Comparable.

Specified by:
compareTo in interface java.lang.Comparable

reachedAlive

public void reachedAlive(ConnectionStateEnum oldState,
                         I_XmlBlasterAccess connection)
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was established.

This method is enforced through interface I_ConnectionStateListener

Specified by:
reachedAlive in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

reachedAliveSync

public void reachedAliveSync(ConnectionStateEnum oldState,
                             I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE. Note that this could take some time or in the worst case it could never been invoked if the queue is never completely processed.

Specified by:
reachedAliveSync in interface I_ConnectionStateListener
Parameters:
oldState - is always ALIVE.

reachedPolling

public void reachedPolling(ConnectionStateEnum oldState,
                           I_XmlBlasterAccess connection)
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was lost.

This method is enforced through interface I_ConnectionStateListener

Specified by:
reachedPolling in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

reachedDead

public void reachedDead(ConnectionStateEnum oldState,
                        I_XmlBlasterAccess connection)
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was lost.

This method is enforced through interface I_ConnectionStateListener

Specified by:
reachedDead in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
This is the callback method invoked from xmlBlaster delivering us a new asynchronous message.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_Callback.update(String, UpdateKey, byte[], UpdateQos)

destroy

public java.lang.String destroy()
For JMX only.

Specified by:
destroy in interface ClusterNodeMBean
Returns:

shutdown

public void shutdown()

toXml

public final java.lang.String toXml()
Dump state of this object into a XML ASCII string.


toXml

public final java.lang.String toXml(java.lang.String extraOffset,
                                    java.util.Properties props)
Dump state of this object into a XML ASCII string.

Parameters:
extraOffset - indenting of tags for nice output

isAvailable

public boolean isAvailable()
Specified by:
isAvailable in interface ClusterNodeMBean

getRemoteGlob

public Global getRemoteGlob()
Returns:
Returns the remoteGlob.

getContextNode

public ContextNode getContextNode()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.