ibis.util
Class PoolInfo

java.lang.Object
  extended byibis.util.PoolInfo
Direct Known Subclasses:
PoolInfoClient

public class PoolInfo
extends java.lang.Object

The PoolInfo class provides a utility for finding out information about the nodes involved in a closed-world run. This class can be used when the names of the nodes involved in the run are known in advance, and can be given in the ibis.pool.host_names property. If these names are not known in advance, a PoolInfoClient can be used instead. The createPoolInfo static method can be used to take care of this automatically.
The PoolInfo class depends on the following system properties:

ibis.pool.total_hosts
must contain the total number of hosts involved in the run.
ibis.pool.host_names
must contain a space-separated list of hostnames. The number of hostnames in the list must at least be equal to the number of hosts involved in the run as given by the ibis.pool.total_hosts property. Any additional host names are ignored.
ibis.pool.host_number
optional, gives the index of the current host in the list of host names. Should be between 0 and ibis.pool.total_hosts (inclusive). If not supplied, it is determined by looking up the current host in the list of host names.


Method Summary
 int[] clusterIPRank()
          Return a Grid Cluster rank based on the lower IP byte of the host names
 int clusterIPSize()
          Return the number of Grid Clusters based on the lower IP byte of the host names
 java.lang.String clusterName()
          Returns the cluster name for the current host.
 java.lang.String clusterName(int rank)
          Returns the cluster name for the host specified by the rank number.
 java.lang.String[] clusterNames()
          Returns an array of cluster names, one for each host involved in the run.
static PoolInfo createPoolInfo()
          Creates and returns a PoolInfo.
static PoolInfo createPoolInfo(boolean forceSeq)
          Creates and returns a PoolInfo.
 java.lang.String hostName()
          Returns the name of the current host.
 java.lang.String hostName(int rank)
          Returns the name of the host with the given rank.
 java.lang.String[] hostNames()
          Returns an array of hostnames of the hosts.
 void printTime(java.lang.String id, long time)
          Utility method to print the time used in a uniform format.
 int rank()
          Returns the rank number in the pool of the current host.
 int size()
          Returns the number of nodes in the pool.
 java.lang.String toString()
          Returns a string representation of the information in this PoolInfo.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

size

public int size()
Returns the number of nodes in the pool.

Returns:
the total number of nodes.

rank

public int rank()
Returns the rank number in the pool of the current host.

Returns:
the rank number.

hostName

public java.lang.String hostName()
Returns the name of the current host.

Returns:
the name of the current host.

clusterName

public java.lang.String clusterName()
Returns the cluster name for the current host.

Returns:
the cluster name.

clusterName

public java.lang.String clusterName(int rank)
Returns the cluster name for the host specified by the rank number.

Parameters:
rank - the rank number.
Returns:
the cluster name.

clusterIPRank

public int[] clusterIPRank()
Return a Grid Cluster rank based on the lower IP byte of the host names


clusterIPSize

public int clusterIPSize()
Return the number of Grid Clusters based on the lower IP byte of the host names


clusterNames

public java.lang.String[] clusterNames()
Returns an array of cluster names, one for each host involved in the run.

Returns:
the cluster names

hostName

public java.lang.String hostName(int rank)
Returns the name of the host with the given rank.

Parameters:
rank - the rank number.
Returns:
the name of the host with the given rank.

hostNames

public java.lang.String[] hostNames()
Returns an array of hostnames of the hosts.

Returns:
an array of hostnames of the hosts.

printTime

public void printTime(java.lang.String id,
                      long time)
Utility method to print the time used in a uniform format.

Parameters:
id - name of the application
time - the time used, in milliseconds.

createPoolInfo

public static PoolInfo createPoolInfo(boolean forceSeq)
Creates and returns a PoolInfo. The parameter indicates wether a pool for a sequential run must be created. If not, if the system property ibis.pool.host_names is set, a PoolInfo is created. If not, a PoolInfoClient is created.

Parameters:
forceSeq - indicates wether a pool for a sequential run must be created.
Returns:
the resulting PoolInfo object.

createPoolInfo

public static PoolInfo createPoolInfo()
Creates and returns a PoolInfo. If the system property ibis.pool.host_names is set, a PoolInfo is created. If not, a PoolInfoClient is created.

Returns:
the resulting PoolInfo object.

toString

public java.lang.String toString()
Returns a string representation of the information in this PoolInfo.

Returns:
a string representation.


The Ibis project