org.isam.exehda
Class HostId

java.lang.Object
  |
  +--org.isam.exehda.HierarchicalId
        |
        +--org.isam.exehda.HostId
All Implemented Interfaces:
java.io.Serializable

public final class HostId
extends HierarchicalId

Uniquely identifies a host in the scope of the distributed system. In order to guarantee unicity, a hierarchical approach is used to generate the identifiers. The id itself is built up of two parts:

Note:Currently, methods getHostByName() assumes local id are generated from the host's ip address and that such address is unique (i.e. 10.x and 192.168.x IPs are not used). Such scheme will be changed in future releases to reflect the behavior described above.

Version:
$Date: 2004/12/16 19:45:19 $ $Revision: 1.10 $
Author:
last modified by $Author: lucc $
See Also:
CellId, Serialized Form

Method Summary
 boolean equals(java.lang.Object obj)
          Returns whether this object is equals to the given object.
static HostId getByName(java.lang.String hostName)
          Look ups a host with the given hostName in the local cell and, if such host exists, returns it's system-wide HostId.
static HostId getByName(java.lang.String hostName, java.lang.String cellName)
          Look ups a host with the given hostName in the given cell and, if such host exists, returns it's system-wide HostId.
 CellId getCell()
          Returns the ID of the cell to which the host refered by this HostId belongs.
 java.lang.String getCellName()
          Returns the name of the cell to which the host refered by this HostId belongs.
 int getId()
          Returns the cell-wide id of this host.
 java.net.InetAddress getInetAddress()
          Returns the Internet address of this host.
static HostId getLocalHost()
          Returns the system-wide HostId that describes the local host.
protected  java.lang.Object getLocalId()
          Subclasses must overwrite this method and return an Object representation of the local id.
 java.lang.String getName()
          Returns the symbolic name of the host described by this HostId, if such name exists.
protected  java.lang.String getType()
          Subclasses must overwrite this method and return a String representation of the ID's type.
 int hashCode()
          Returns a hash code suitable for the java.util.Hashtable semantics.
 
Methods inherited from class org.isam.exehda.HierarchicalId
getParentId, isRoot, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getByName

public static HostId getByName(java.lang.String hostName,
                               java.lang.String cellName)
                        throws java.net.UnknownHostException
Look ups a host with the given hostName in the given cell and, if such host exists, returns it's system-wide HostId. Note:The current scheme assumes the local id is generated from the host's IP address and only works if the host name is resolvable throught an DNS query. Such scheme will be improved in future to consider data stored in the Cell Information Base as long as other local id association policies.

Parameters:
hostName - a public name of the host (e.g. its internet name)
cellName - the name of the cell in which the search is to be done. null would be used to refer to the local cell. This parameter is currently not considered in lookup process.
Returns:
the system-wide host identifier of that host.
Throws:
java.net.UnknownHostException - if the given hostName do not exists in the given cell.

getByName

public static HostId getByName(java.lang.String hostName)
                        throws java.net.UnknownHostException
Look ups a host with the given hostName in the local cell and, if such host exists, returns it's system-wide HostId. Note:The current scheme assumes the local id is generated from the host's IP address and only works if the host name is resolvable trough an DNS query. Such scheme will be improved in future to consider data stored in the Cell Information Base as long as other local id association policies.

Parameters:
hostName - a public name of the host (e.g. its internet name)
Returns:
the system-wide host identifier of that host.
Throws:
java.net.UnknownHostException - if the given hostName do not exists in the given cell.

getLocalHost

public static HostId getLocalHost()
Returns the system-wide HostId that describes the local host.

Returns:
a HostId value

getName

public java.lang.String getName()
Returns the symbolic name of the host described by this HostId, if such name exists. Currently, this name is the Internet name of the host as would be used in DNS queries.

Returns:
Returns the symbolic name of the host if its available or null otherwise.

getId

public int getId()
Returns the cell-wide id of this host.

Returns:
a 32 bits integer that uniquely identifies this host in the scope of it's containing cell.

getCell

public CellId getCell()
Returns the ID of the cell to which the host refered by this HostId belongs.

Returns:
the cell name.

getCellName

public java.lang.String getCellName()
Returns the name of the cell to which the host refered by this HostId belongs. Shortcut to getCell().getName().

Returns:
the cell name.

getInetAddress

public java.net.InetAddress getInetAddress()
Returns the Internet address of this host. This method will only return a non-null value if the host has a real IP (i.e. a IP not in 10.x, 127.x, or 192.168.x ranges). Note: This method is to be deprecated in future releases of the middleware, since its not guaranteed that it will be able to return an address suitable to contact every host in the system. An alternative mechanism is under development which will be probably based on host attributes stored in the Cell Information Base.

Returns:
an InetAddress value, or null if a real IP is not available for this host.

equals

public boolean equals(java.lang.Object obj)
Returns whether this object is equals to the given object. The two objects are said to be equal iif: both as of class HostId, their cell scope and local id are equals too.

Overrides:
equals in class HierarchicalId
Parameters:
obj - an Object value
Returns:
true if this object describes the same host as the given object, false otherwise.

hashCode

public int hashCode()
Returns a hash code suitable for the java.util.Hashtable semantics.

Overrides:
hashCode in class HierarchicalId
Returns:
the hash code for this object

getType

protected final java.lang.String getType()
Description copied from class: HierarchicalId
Subclasses must overwrite this method and return a String representation of the ID's type.

Specified by:
getType in class HierarchicalId
Returns:
a String value

getLocalId

protected final java.lang.Object getLocalId()
Description copied from class: HierarchicalId
Subclasses must overwrite this method and return an Object representation of the local id. Notice that, subclasses may actually store such ID using primitive types, in order to be more efficient, and just wrap such values in an Object when getLocalId() is invoked.

Specified by:
getLocalId in class HierarchicalId
Returns:
an Object value