FileDocCategorySizeDatePackage
ClusterNode.javaAPI DocJBoss 4.2.15017Fri Jul 13 20:52:38 BST 2007org.jboss.ha.framework.interfaces

ClusterNode

public class ClusterNode extends Object implements Comparable, Serializable, Cloneable
Replacement for a JG IpAddress that doesn't base its representation on the JG address but on the computed node name added to the IPAddress instead. This is to avoid any problem in the cluster as some nodes may interpret a node name differently (IP resolution, name case, FQDN or host name, etc.)
see
org.jboss.ha.framework.server.ClusterPartition
author
Sacha Labourey.
version
$Revision: 57188 $

Revisions:

August 17 2003 Sacha Labourey:

  • First implementation

Fields Summary
protected String
id
protected String
jgId
protected org.jgroups.stack.IpAddress
originalJGAddress
Constructors Summary
public ClusterNode()


   // Static --------------------------------------------------------
   
   // Constructors --------------------------------------------------
       
    
   
   
public ClusterNode(org.jgroups.stack.IpAddress jgAddress)

      if (jgAddress.getAdditionalData() == null)
      {
         this.id = jgAddress.getIpAddress().getHostAddress() + ":" + jgAddress.getPort();
      }
      else
      {
         this.id = new String(jgAddress.getAdditionalData());
      }

      this.originalJGAddress = jgAddress;
      StringBuffer sb = new StringBuffer();
      java.net.InetAddress jgIPAddr = jgAddress.getIpAddress();
      if (jgIPAddr == null)
         sb.append("<null>");
      else
      {
         if (jgIPAddr.isMulticastAddress())
            sb.append(jgIPAddr.getHostAddress());
         else
            sb.append(getShortName(jgIPAddr.getHostName()));
      }
      sb.append(":" + jgAddress.getPort());
      this.jgId = sb.toString();
   
Methods Summary
public intcompareTo(java.lang.Object o)

      if ((o == null) || !(o instanceof ClusterNode))
         throw new ClassCastException("ClusterNode.compareTo(): comparison between different classes");

      ClusterNode other = (ClusterNode) o;

      return this.id.compareTo(other.id);
   
public booleanequals(java.lang.Object obj)

      if (obj == null || !(obj instanceof ClusterNode)) return false;
      
      ClusterNode other = (ClusterNode) obj;
      return this.id.equals(other.id);
   
public java.net.InetAddressgetIpAddress()

      return this.originalJGAddress.getIpAddress();
   
public java.lang.StringgetJGName()

      return this.jgId;
   
public java.lang.StringgetName()

      return this.id;
   
public org.jgroups.stack.IpAddressgetOriginalJGAddress()

      return this.originalJGAddress;
   
public intgetPort()

      return this.originalJGAddress.getPort();      
   
protected java.lang.StringgetShortName(java.lang.String hostname)

      int index = hostname.indexOf('.");

      if (hostname == null) return "";
      if (index > 0 && !Character.isDigit(hostname.charAt(0)))
         return hostname.substring(0, index);
      else
         return hostname;
   
public inthashCode()

      return id.hashCode();
   
public java.lang.StringtoString()

      return this.getName();