jgroup.relacs.config
Class Domain

java.lang.Object
  extended by jgroup.relacs.types.EndPointImpl
      extended by jgroup.relacs.config.Domain
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, EndPoint

public class Domain
extends EndPointImpl
implements java.lang.Cloneable, java.lang.Comparable, java.io.Externalizable

Class for holding domain information.

Since:
Jgroup 1.2
Author:
Hein Meling
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jgroup.relacs.types.EndPointImpl
address, local, port, SIZE
 
Constructor Summary
Domain()
          Constructor for deserialization.
Domain(Domain domain, boolean copyHosts)
          Constructs a domain from another domain object.
Domain(java.lang.String domainName)
           
Domain(java.lang.String domainName, java.lang.String mcastAdr, int mcastPort)
           
Domain(java.lang.String domainName, java.lang.String mcastAdr, int mcastPort, int jdaemons)
           
 
Method Summary
 boolean addHost(Host host)
          Add a host to this domain.
 boolean allDaemons()
          Returns true if all hosts in this domain should have a daemon.
 void clearStatus()
          Clear out the status map to avoid that the socket status remote reference objects are propagated from one experiment to the next.
 java.lang.Object clone()
          Returns a shallow copy of this Domain instance.
static void commit(java.lang.String pattern)
          Commit the currently configured reachability pattern, essentially activating the pattern.
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for ordering the objects.
 void decReplicaCount()
           
 java.lang.Object get(java.lang.String key)
          Retrieve the value associated with this domain for the given key.
 EndPoint getEndpoint()
           
 HostSet getHostSet()
          Returns the HostSet for the hosts in this domain.
 java.lang.String getName()
          Returns the domain name.
 int getReplicaCount()
           
 boolean hasNoDaemons()
          Returns true if this domain should not have any daemons.
 void incReplicaCount()
           
 boolean isEmpty()
          Returns true if there are no hosts in this domain; false otherwise.
 boolean isLocal()
          Returns true if this is a local domain.
 boolean isMulticastEndPoint()
          Returns true always, since a domain endpoint must be a multicast endpoint.
 void merge(Domain domain)
          Inject a merge on this domain so that it becomes reachable from the given domain.
 int numOfDaemons()
          Returns the number of daemons that should reside in this domain.
 void partition(Domain domain)
          Inject a partition on this domain so that it becomes unreachable from the given domain.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Associate the given value with this domain under the given key.
 void readExternal(java.io.ObjectInput in)
          Restores the content of this object from the marshalled data contained in the specified input stream.
 void setLocal(boolean local)
          Set the local flag for this domain.
 void setReplicaCount(int newReplicaCount)
           
 int size()
          Returns the number of hosts contained in this domain.
 java.lang.String toString()
          Returns a string representation of this object
 java.lang.String toString(boolean full)
          Returns a string representation of this object
 void writeExternal(java.io.ObjectOutput out)
          Marshals the content of this object to the specified output stream.
 
Methods inherited from class jgroup.relacs.types.EndPointImpl
equals, getAddress, getIntAddress, getPort, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Domain

public Domain()
Constructor for deserialization.


Domain

public Domain(Domain domain,
              boolean copyHosts)
Constructs a domain from another domain object. If the copyHosts parameter is set to false, no hosts will be copied from the domain object.

Parameters:
domain - the domain to copy
copyHosts - if true, the internal host set of the provided domain is also copied; otherwise the internal host set will be empty.

Domain

public Domain(java.lang.String domainName)
       throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

Domain

public Domain(java.lang.String domainName,
              java.lang.String mcastAdr,
              int mcastPort)
       throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

Domain

public Domain(java.lang.String domainName,
              java.lang.String mcastAdr,
              int mcastPort,
              int jdaemons)
       throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException
Method Detail

isLocal

public boolean isLocal()
Returns true if this is a local domain.

Specified by:
isLocal in interface EndPoint
Overrides:
isLocal in class EndPointImpl

isMulticastEndPoint

public boolean isMulticastEndPoint()
Returns true always, since a domain endpoint must be a multicast endpoint. There is a check for this in the class constructor.

Specified by:
isMulticastEndPoint in interface EndPoint
Overrides:
isMulticastEndPoint in class EndPointImpl

setLocal

public void setLocal(boolean local)
Set the local flag for this domain.


getName

public java.lang.String getName()
Returns the domain name.


getEndpoint

public EndPoint getEndpoint()

size

public int size()
Returns the number of hosts contained in this domain.


isEmpty

public boolean isEmpty()
Returns true if there are no hosts in this domain; false otherwise.


getHostSet

public HostSet getHostSet()
Returns the HostSet for the hosts in this domain.


addHost

public boolean addHost(Host host)
Add a host to this domain.

Parameters:
host - The host to add to this domain.
Returns:
True if the Domain did not already contain this host.

get

public java.lang.Object get(java.lang.String key)
Retrieve the value associated with this domain for the given key.


put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Associate the given value with this domain under the given key.


allDaemons

public boolean allDaemons()
Returns true if all hosts in this domain should have a daemon.


hasNoDaemons

public boolean hasNoDaemons()
Returns true if this domain should not have any daemons.


numOfDaemons

public int numOfDaemons()
Returns the number of daemons that should reside in this domain. A value of -1 indicates that all hosts in this domain should have a Jgroup daemon. A value of 0 indicates that this domain have no daemons, and that we should look in other domains for a daemon.


decReplicaCount

public void decReplicaCount()

incReplicaCount

public void incReplicaCount()

getReplicaCount

public int getReplicaCount()

setReplicaCount

public void setReplicaCount(int newReplicaCount)

clone

public java.lang.Object clone()
Returns a shallow copy of this Domain instance. (The elements themselves are not copied.)

Overrides:
clone in class java.lang.Object
Returns:
a clone of this Domain instance.

compareTo

public int compareTo(java.lang.Object obj)
Compares this object with the specified object for ordering the objects. The replicaCount is the primary ordering value; the size of the domain (the number of hosts in the domain) is the secondary ordering value, while the multicast IP and port number is the third ordering value. Note that we rank domains with the largest number of hosts first.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class EndPointImpl

toString

public java.lang.String toString()
Returns a string representation of this object

Overrides:
toString in class EndPointImpl

toString

public java.lang.String toString(boolean full)
Returns a string representation of this object


readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.lang.ClassNotFoundException,
                         java.io.IOException
Restores the content of this object from the marshalled data contained in the specified input stream.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class EndPointImpl
Parameters:
in - the stream to be read
Throws:
java.lang.ClassNotFoundException
java.io.IOException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Marshals the content of this object to the specified output stream.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class EndPointImpl
Parameters:
out - the stream to be written
Throws:
java.io.IOException

partition

public void partition(Domain domain)
Inject a partition on this domain so that it becomes unreachable from the given domain. This method will only configure the reachability pattern, and thus it must be followed by an invocation of the commit() method below.


merge

public void merge(Domain domain)
Inject a merge on this domain so that it becomes reachable from the given domain. This method will only configure the reachability pattern, and thus it must be followed by an invocation of the commit() method below.


commit

public static void commit(java.lang.String pattern)
Commit the currently configured reachability pattern, essentially activating the pattern. Calls to this method must only occur after a call to either the partition() or merge() method, otherwise an IllegalStateException is thrown. It cannot be called multiple times per call to partition() or merge().


clearStatus

public void clearStatus()
Clear out the status map to avoid that the socket status remote reference objects are propagated from one experiment to the next.



Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.