Dashboard Builder Commons 6.2.0.Beta1

org.jboss.dashboard.cluster
Class ClusterNodesManager

java.lang.Object
  extended by org.jboss.dashboard.cluster.ClusterNodesManager
All Implemented Interfaces:
Startable

@ApplicationScoped
public class ClusterNodesManager
extends Object
implements Startable

A platform component that manages the nodes connected to the cluster, if any. NOTE: BZ-1014612


Field Summary
static org.slf4j.Logger log
           
 
Constructor Summary
ClusterNodesManager()
           
 
Method Summary
 void deregister(Long nodeId)
          Deregister the node from the table.
 Long getCurrentNodeId()
           
 String getCurrentNodeIpAddress()
           
protected  String getIPAddress()
          Return the IP address for the default interface.
 ClusterNode getNodeById(Long id)
          Returns a cluster node instance for a given identifier.
 ClusterNode getNodeByIpAddress(String ip)
          Returns a cluster node instance for a given IP address.
 List<ClusterNode> getNodeByStatus(ClusterNode.ClusterNodeStatus status)
          Returns a cluster node/s instance for a given status.
 Priority getPriority()
          Use highest priority to register the nodes and their statuses as quick as possible on startup.
 void setCurrentNodeStatus(ClusterNode.ClusterNodeStatus newStatus)
          Sets a status for current node.
 void setNodeStatus(Long nodeId, ClusterNode.ClusterNodeStatus newStatus)
          Sets a status for a node.
 boolean shouldInstallModules()
          Check if another node is currently installing initial modules.
 void start()
          Register the node into the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static transient org.slf4j.Logger log
Constructor Detail

ClusterNodesManager

public ClusterNodesManager()
Method Detail

getPriority

public Priority getPriority()
Use highest priority to register the nodes and their statuses as quick as possible on startup. It must has lower priority than startable HibernateInitializer in order to have a valid Hibernate session.

Specified by:
getPriority in interface Startable
Returns:
An urgent priority.

start

public void start()
           throws Exception
Register the node into the table.

Specified by:
start in interface Startable
Throws:
Exception - Error registering node.

deregister

public void deregister(Long nodeId)
                throws Exception
Deregister the node from the table.

Throws:
Exception - Error deregistering node.

getNodeByStatus

public List<ClusterNode> getNodeByStatus(ClusterNode.ClusterNodeStatus status)
                                  throws Exception
Returns a cluster node/s instance for a given status. Several nodes can have same ip address.

Parameters:
status - The status for the node.
Returns:
The cluster node/s or null if there is no match.
Throws:
Exception - Error searching for a cluster node by status.

getNodeById

public ClusterNode getNodeById(Long id)
                        throws Exception
Returns a cluster node instance for a given identifier.

Parameters:
id - The identifier for the node.
Returns:
The cluster node or null if there is no match.
Throws:
Exception - Error searching for a cluster node by identifier.

getNodeByIpAddress

public ClusterNode getNodeByIpAddress(String ip)
                               throws Exception
Returns a cluster node instance for a given IP address.

Parameters:
ip - The ip address for the node.
Returns:
The cluster node or null if there is no match.
Throws:
Exception - Error searching for a cluster node by ip address.

getIPAddress

protected String getIPAddress()
                       throws SocketException
Return the IP address for the default interface.

Returns:
The IP address for the default interface.
Throws:
SocketException - Error reading socket.

setNodeStatus

public void setNodeStatus(Long nodeId,
                          ClusterNode.ClusterNodeStatus newStatus)
                   throws Exception
Sets a status for a node.

Parameters:
nodeId - The node identifier.
newStatus - The new status to set.
Throws:
Exception

shouldInstallModules

public boolean shouldInstallModules()
                             throws Exception
Check if another node is currently installing initial modules. If no other node is installing initial modules, install the modules and register node status to state: installing_modules. If another node is installing initial modules, skip initial modules installation from this node. IMPORTANT NOTE: Perform the change node status in bbdd in a new transaction. NOTE: BZ-1014612

Returns:
If this node should install initial modules.
Throws:
Exception

setCurrentNodeStatus

public void setCurrentNodeStatus(ClusterNode.ClusterNodeStatus newStatus)
                          throws Exception
Sets a status for current node.

Parameters:
newStatus - The new status to set.
Throws:
Exception

getCurrentNodeId

public Long getCurrentNodeId()

getCurrentNodeIpAddress

public String getCurrentNodeIpAddress()

Dashboard Builder Commons 6.2.0.Beta1

Copyright © 2012-2014 JBoss by Red Hat. All Rights Reserved.