org.rhq.enterprise.server.resource.cluster
Class ClusterKey

java.lang.Object
  extended by org.rhq.enterprise.server.resource.cluster.ClusterKey

public class ClusterKey
extends java.lang.Object

A ClusterKey represents an AutoCluster of resources in a Cluster Hierarchy. Given the key it is possible to determine specific membership of the AutoCluster at any time. It represents the Cluster Root (a Compatible Group) and the hierarchy of resource cluster nodes. Each level of the hierarchy represents a resource cluster node defined by a Plugin|ResourceType|ResourceKey tuple.

The ClusterKey has the following form:

 
  Expressed iteratively:
  
  CompatibleGroupId::ResourceTypeId1:ResourceKey1::ResourceTypeId2:ResourceKey2:: ... ::ResourceTypeIdN:ResourceKeyN
  
  Expressed Recursively:
  
  Depth-1 AutoCluster  CompatibleGroupId::ResourceTypeId1:ResourceKey1
  Depth-N AutoCluster  ::ResourceTypeIdN:ResourceKeyN
 

Author:
jay shaughnessy

Nested Class Summary
static class ClusterKey.Node
          Immutable class representing a node in an AutoCluster hierarchy.
 
Constructor Summary
ClusterKey(ClusterKey parentKey, int childResourceTypeId, java.lang.String childResourceKey)
          Construct a new ClusterKey for a child AutoCluster of the provided parentKey
ClusterKey(int clusterResourceGroupId)
          Construct ClusterKey with to-be-defined Hierarcrhy
ClusterKey(int clusterResourceGroupId, int resourceTypeId, java.lang.String resourceKey)
          Construct ClusterKey for a top level AutoCluster
 
Method Summary
 java.util.List<ClusterKey.Node> addChildToHierarchy(int childResourceTypeId, java.lang.String childResourceKey)
          Increase depth of hierarchy with new child node.
 boolean equals(java.lang.Object o)
           
 int getClusterGroupId()
           
 int getDepth()
           
 java.util.List<ClusterKey.Node> getHierarchy()
           
 java.lang.String getKey()
           
static int getResourceType(ClusterKey clusterKey)
           
 int hashCode()
           
 void setDepth(int newDepth)
           
 java.lang.String toNamedString(javax.persistence.EntityManager em)
          format: see class doc, used delimiters ClusterKey.DELIM_NODE and ClusterKey.DELIM.
 java.lang.String toString()
          format: see class doc, used delimiters ClusterKey.DELIM_NODE and ClusterKey.DELIM
static ClusterKey valueOf(java.lang.String clusterKey)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClusterKey

public ClusterKey(int clusterResourceGroupId)
Construct ClusterKey with to-be-defined Hierarcrhy


ClusterKey

public ClusterKey(int clusterResourceGroupId,
                  int resourceTypeId,
                  java.lang.String resourceKey)
Construct ClusterKey for a top level AutoCluster


ClusterKey

public ClusterKey(ClusterKey parentKey,
                  int childResourceTypeId,
                  java.lang.String childResourceKey)
Construct a new ClusterKey for a child AutoCluster of the provided parentKey

Method Detail

getClusterGroupId

public int getClusterGroupId()

getHierarchy

public java.util.List<ClusterKey.Node> getHierarchy()

addChildToHierarchy

public java.util.List<ClusterKey.Node> addChildToHierarchy(int childResourceTypeId,
                                                           java.lang.String childResourceKey)
Increase depth of hierarchy with new child node.

Parameters:
childResourceTypeId -
childResourceKey -
Returns:
The updated hierarchy

getDepth

public int getDepth()
Returns:
the depth of the AutoCluster hierarchy. Just another way of getting the hierarchy size.

setDepth

public void setDepth(int newDepth)
Parameters:
newDepth - > 0, keep only the hierarchy up to an including the specified depth.

getKey

public java.lang.String getKey()

toString

public java.lang.String toString()
format: see class doc, used delimiters ClusterKey.DELIM_NODE and ClusterKey.DELIM

Overrides:
toString in class java.lang.Object

toNamedString

public java.lang.String toNamedString(javax.persistence.EntityManager em)
format: see class doc, used delimiters ClusterKey.DELIM_NODE and ClusterKey.DELIM. ResourceTypeId replaced with Plugin:ResourceTypeName tuple.


valueOf

public static ClusterKey valueOf(java.lang.String clusterKey)

getResourceType

public static int getResourceType(ClusterKey clusterKey)
Parameters:
clusterKey -
Returns:
The ResourceType id of the resource group this clusterKey defines.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.