org.jacorb.imr
Class ImplementationRepositoryImpl

java.lang.Object
  extended byorg.omg.PortableServer.Servant
      extended byorg.jacorb.imr.ImplementationRepositoryPOA
          extended byorg.jacorb.imr.ImplementationRepositoryImpl
All Implemented Interfaces:
AdminOperations, ImplementationRepositoryOperations, InvokeHandler, RegistrationOperations

public class ImplementationRepositoryImpl
extends ImplementationRepositoryPOA

This is the main class of the JacORB implementation repository. It keeps track of the registered POAs with lifespan policy PERSISTENT and provides a way for migrating and restarting the POAS servers.

Author:
Nicolas Noffke $Id: ImplementationRepositoryImpl.java,v 1.56 2005/02/09 09:54:09 andre.spiegel Exp $

Constructor Summary
ImplementationRepositoryImpl(ORB orb)
          The constructor.
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration myConfiguration)
           
 void edit_server(java.lang.String name, java.lang.String command, java.lang.String host)
          Updates the server with a new command and host.
 ImRInfo get_imr_info()
          Get host and port (wrapped inside an ImRInfo object) of this repository.
 ServerInfo get_server_info(java.lang.String server)
          Get the ServerInfo object of a specific server.
 java.lang.String getIORFile()
           
 void hold_server(java.lang.String name)
          Hold a server.
 HostInfo[] list_hosts()
          List all hosts currently registered with this repository.
 ServerInfo[] list_servers()
          List all registered server.
static void main(java.lang.String[] args)
          The main method.
 void register_host(HostInfo host)
          Register a new host with a server startup daemon.
 void register_poa(java.lang.String name, java.lang.String server, java.lang.String host, int port)
          This method registers a POA.
 void register_server(java.lang.String name, java.lang.String command, java.lang.String host)
          Register a logical server.
 void release_server(java.lang.String name)
          Release a server from state "holding".
 void save_server_table()
          Save the server table to a backup file.
 void set_server_down(java.lang.String server)
          This method sets a server down, i.e. not.active.
 void shutdown(boolean wait)
          Shut the repository down orderly, i.e. with saving of the server table.
 void start_server(java.lang.String name)
          Start a server.
 void unregister_host(java.lang.String name)
          Remove a host from the servertable.
 void unregister_server(java.lang.String name)
          Remove a logical server from the server table.
static void usage()
          Prints the usage screen and exits.
 
Methods inherited from class org.jacorb.imr.ImplementationRepositoryPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _get_interface, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImplementationRepositoryImpl

public ImplementationRepositoryImpl(ORB orb)
The constructor. It builds up the server table and starts up the SocketListener thread.

Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration myConfiguration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getIORFile

public java.lang.String getIORFile()

set_server_down

public void set_server_down(java.lang.String server)
                     throws UnknownServerName
This method sets a server down, i.e. not.active. If a request for that server is encountered, the server is tried to be restarted.

Parameters:
server - the servers name.
Throws:
UnknownServerName - No server with name server has been registered.

register_poa

public void register_poa(java.lang.String name,
                         java.lang.String server,
                         java.lang.String host,
                         int port)
                  throws IllegalPOAName,
                         DuplicatePOAName,
                         UnknownServerName
This method registers a POA. It has actually two functions: The reason for using only one method for those two tasks is that it is much more difficult for the ORB, which does the registering, to distinguish between an newly created POA and a restarted one.

Parameters:
name - the POAs name.
server - the logical server name of the server the running in.
host - the POAs host.
port - the POas port.
Throws:
IllegalPOAName - the POAs name is not valid.
DuplicatePOAName - an active POA with name is currently registered.
UnknownServerName - The server has not been registered.

register_host

public void register_host(HostInfo host)
                   throws IllegalHostName,
                          InvalidSSDRef
Register a new host with a server startup daemon.

Parameters:
host - a HostInfo object containing the hosts name and a reference to its ServerStartupDaemon object.
Throws:
IllegalHostName - name is not valid.
InvalidSSDRef - It was impossible to connect to the daemon.

get_imr_info

public ImRInfo get_imr_info()
Get host and port (wrapped inside an ImRInfo object) of this repository.

Returns:
the ImRInfo object of this repository.

list_hosts

public HostInfo[] list_hosts()
List all hosts currently registered with this repository. It is not guaranteed that the references inside the HostInfo objects are still valid.

Returns:
an array containing all known hosts.

list_servers

public ServerInfo[] list_servers()
List all registered server. The ServerInfo objects contain also a list of the associated POAs.

Returns:
an array containing all registered servers.

get_server_info

public ServerInfo get_server_info(java.lang.String server)
                           throws UnknownServerName
Get the ServerInfo object of a specific server.

Parameters:
server - the servers name.
Returns:
the ServerInfo object of the server with name server
Throws:
UnknownServerName - the server server has not been registered.

register_server

public void register_server(java.lang.String name,
                            java.lang.String command,
                            java.lang.String host)
                     throws IllegalServerName,
                            DuplicateServerName
Register a logical server. The logical server corresponds to a process which has a number of POAs.

Parameters:
name - the servers name.
command - the startup command for this server if it should be restarted on demand. Has to be empty (NOT null) if the server should not be restarted.
host - the host on which the server should be restarted. Should not be null, but is ignored if no startup command is specified.
Throws:
IllegalServerName - the servers name is not valid.
DuplicateServerName - a server with name has already been registered.

unregister_server

public void unregister_server(java.lang.String name)
                       throws UnknownServerName
Remove a logical server from the server table. If a server is removed, all of its POAs are removed as well.

Parameters:
name - the servers name.
Throws:
UnknownServerName - a server with name has not been registered.

edit_server

public void edit_server(java.lang.String name,
                        java.lang.String command,
                        java.lang.String host)
                 throws UnknownServerName
Updates the server with a new command and host. For migrating purposes.

Parameters:
name - the servers name.
command - the new startup command for this server.
host - the new host.
Throws:
org.jacorb.imr.AdminPackage.UnknownServerName - a server with name has not been registered.
UnknownServerName

hold_server

public void hold_server(java.lang.String name)
                 throws UnknownServerName
Hold a server. This causes all requests for this server to be delayed until it is released. Holding a server is useful for migrating or maintaining it. There is not timeout set, so requests might be delayed indefinetly (or, at least, until the communication layer protests;-).

Parameters:
name - the servers name.
Throws:
UnknownServerName - a server with name has not been registered.

release_server

public void release_server(java.lang.String name)
                    throws UnknownServerName
Release a server from state "holding".

Parameters:
name - the servers name.
Throws:
UnknownServerName - a server with name has not been registered.

start_server

public void start_server(java.lang.String name)
                  throws UnknownServerName,
                         ServerStartupFailed
Start a server.

Parameters:
name - the servers name.
Throws:
UnknownServerName - a server with name has not been registered.
ServerStartupFailed

save_server_table

public void save_server_table()
                       throws FileOpFailed
Save the server table to a backup file.

Throws:
FileOpFailed - something went wrong.

shutdown

public void shutdown(boolean wait)
Shut the repository down orderly, i.e. with saving of the server table. The actual shutdown is done in the SocketListener thread because, if done from here, the orb wont shut don correctly because this connection is still active. (See end of SocketListener.run())

Parameters:
wait - wait_for_completion (from ORB.shutdown()). If false, then the ORB is forced down, ignoring any open connection.

unregister_host

public void unregister_host(java.lang.String name)
                     throws UnknownHostName
Remove a host from the servertable. Hosts are removed automatically on server startup, if they can't be accessed.

Parameters:
name - the hosts name.
Throws:
no - host with that name known.
UnknownHostName

usage

public static void usage()
Prints the usage screen and exits.


main

public static void main(java.lang.String[] args)
The main method. "Parses" the arguments and sets the corresponding attributes up, creates a new ImplementationRepositoryImpl instance and runs the ORB.