FileDocCategorySizeDatePackage
SubPartitionInfo.javaAPI DocJBoss 4.2.15063Fri Jul 13 20:52:36 BST 2007org.jboss.ha.framework.interfaces

SubPartitionInfo

public class SubPartitionInfo extends Object implements Comparable, Cloneable, Serializable
Holder class that knows about a particular HA(sub)Partition i.e. member nodes, partition name and some utility functions.
see
org.jboss.ha.hasessionstate.interfaces.HASessionState
see
org.jboss.ha.hasessionstate.server.HASessionStateImpl
author
Sacha Labourey
version
$Revision: 57188 $

Fields Summary
private static final long
serialVersionUID
The serialVersionUID
public String
subPartitionName
Name of the current sub-partition (will be used to create a JGroups group)
public HashSet
subPartitionMergedNames
When sub-partitions are merged, some names will disappear (eg. Merge G1 and G2 in G1) this structure remembers the removed named so that HAPartition can know which new group they should join
public ArrayList
memberNodeNames
List of nodes part of this sub-partition
private transient boolean
newGroup
Constructors Summary
public SubPartitionInfo()


   // Static --------------------------------------------------------
   
   // Constructors --------------------------------------------------
   
      
public SubPartitionInfo(String partitionName, String[] members)

      super ();
      this.subPartitionName = partitionName;
      if (members != null)
         for (int i=0; i<members.length; i++)
            this.memberNodeNames.add (members[i]);
   
Methods Summary
public booleanactsForSubPartition(java.lang.String subPartitionName)

      return (subPartitionName.equals (subPartitionName) || subPartitionMergedNames.contains (subPartitionName));      
   
public java.lang.Objectclone()

      SubPartitionInfo clonedObject = new SubPartitionInfo ();
      clonedObject.subPartitionName = this.subPartitionName;
      clonedObject.memberNodeNames = (ArrayList)this.memberNodeNames.clone ();
      clonedObject.subPartitionMergedNames = (HashSet)this.subPartitionMergedNames.clone ();
      
      return clonedObject;
   
public intcompareTo(java.lang.Object o)
"Note: this class has a natural ordering that is inconsistent with equals."

      int mySize = memberNodeNames.size ();
      int itsSize = ((SubPartitionInfo)o).memberNodeNames.size ();
      
      if (mySize==itsSize)
         return 0;
      else if (mySize > itsSize)
         return 1;
      else
         return -1;
      
   
public booleancontainsNode(java.lang.String node)

      return memberNodeNames.contains (node);
   
public voidmerge(org.jboss.ha.framework.interfaces.SubPartitionInfo merged)

      this.memberNodeNames.addAll (merged.memberNodeNames);
      if (this.newGroup && !merged.newGroup)
         this.subPartitionName = merged.subPartitionName;
      else if (!merged.newGroup)
         this.subPartitionMergedNames.add (merged.subPartitionName);
      
      
      if (!merged.newGroup)
         this.subPartitionMergedNames.add (merged.subPartitionName);
      this.subPartitionMergedNames.addAll (merged.subPartitionMergedNames); // ? needed ?
      merged.memberNodeNames.clear ();
      merged.subPartitionMergedNames.clear ();
   
public voidsetIsNewGroup()

      this.newGroup = true;
   
public java.lang.StringtoString()

      return subPartitionName + ":[" + memberNodeNames + "] aka '" + subPartitionMergedNames + "'";