org.jacorb.imr
Class ImRServerInfo

java.lang.Object
  extended byorg.jacorb.imr.ImRServerInfo
All Implemented Interfaces:
java.io.Serializable

public class ImRServerInfo
extends java.lang.Object
implements java.io.Serializable

This class contains the information about a logical server. It has methods for managing the associated POAs, holding and releasing the server, and, for the "client side", a method that blocks until the server is released.

Version:
$Id: ImRServerInfo.java,v 1.11 2004/05/06 12:39:59 nicolas Exp $
Author:
Nicolas Noffke
See Also:
Serialized Form

Field Summary
protected  boolean active
           
protected  java.lang.String command
           
protected  boolean holding
           
protected  java.lang.String host
           
protected  java.lang.String name
           
protected  boolean restarting
           
 
Constructor Summary
ImRServerInfo(java.lang.String name, java.lang.String host, java.lang.String command)
          The Constructor.
 
Method Summary
 void addPOA(ImRPOAInfo poa)
          Adds a POA to this server.
 void awaitRelease()
          This method blocks until the server is released, i.e. set to not holding.
protected  java.lang.String[] getPOANames()
          Builds an array of of the names of the POAs associated with this server.
 void release()
          Release the server and unblock all waiting threads.
 void setDown()
          Sets the server down, i.e. not active.
 void setNotRestarting()
           
 boolean shouldBeRestarted()
          Tests if this server should be restarted.
 ServerInfo toServerInfo()
          "Converts" this Object to a ServerInfo instance containing the same info as this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

command

protected java.lang.String command

holding

protected boolean holding

host

protected java.lang.String host

name

protected java.lang.String name

active

protected boolean active

restarting

protected boolean restarting
Constructor Detail

ImRServerInfo

public ImRServerInfo(java.lang.String name,
                     java.lang.String host,
                     java.lang.String command)
              throws IllegalServerName
The Constructor. It sets up the internal attributes.

Parameters:
name - the logical server name
host - the name of the host on which the server should be restarted (ignored when no startup command is specified).
command - the startup command for this server, passed to the server startup daemon on host (in case there is one active).
Throws:
IllegalServerName - thrown when name is null or of length zero.
Method Detail

toServerInfo

public ServerInfo toServerInfo()
"Converts" this Object to a ServerInfo instance containing the same info as this object.

Returns:
a ServerInfo object.

addPOA

public void addPOA(ImRPOAInfo poa)
Adds a POA to this server.

Parameters:
poa - the POA to add.

getPOANames

protected java.lang.String[] getPOANames()
Builds an array of of the names of the POAs associated with this server.
This method is needed for deleting a server since its POAs have to be as well removed from the central storage.

Returns:
an array of POA names

setDown

public void setDown()
Sets the server down, i.e. not active. If a request for a POA of this server is received, the repository tries to restart the server.
The server is automatically set back to active when the first of its POAs gets reregistered.


awaitRelease

public void awaitRelease()
This method blocks until the server is released, i.e. set to not holding.
This will not time out since holding a server is only done by administrators.


release

public void release()
Release the server and unblock all waiting threads.


shouldBeRestarted

public boolean shouldBeRestarted()
Tests if this server should be restarted. That is the case if the server is not active and nobody else is currently trying to restart it.
If true is returned the server is set to restarting. That means the thread calling this method has to restart the server, otherwise it will stay down indefinetly.

Returns:
true, if the server should be restarted by the calling thread.

setNotRestarting

public void setNotRestarting()