ParkNPark.middletier
Class ReplicationManager

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by ParkNPark.interfaces.ReplicationManagerPOA
          extended by ParkNPark.middletier.ReplicationManager
All Implemented Interfaces:
InvokeHandler, ReplicationManagerOperations

public class ReplicationManager
extends ReplicationManagerPOA


Nested Class Summary
protected  class ReplicationManager.StartupListener
          Listens on a server process to determine if it started up successfully or not
 
Field Summary
protected static PrintStream inputEater
          Shared static instance of the input eater output stream wrapped in a PrintStream
protected  int interRequestTime
          Time between requests
private  NamingContextExt nameServer
          Naming context
protected  int numClients
          Number of clients
private  ORB orb
          Object request broker
private  NamingContext parkNParkContext
          Our naming service's ParkNPark context, which contains server registrations
protected  String projectRoot
          The project root, which is used when restarting a failed server
protected  int replySize
          Size of reply
private  POA rootPOA
          Root POA
private  ArrayList<ServerState> servers
          List of active servers
 
Constructor Summary
ReplicationManager()
           
 
Method Summary
 void checkServers()
          Check whether or not servers are active
protected  void initializeServerListFromParkNParkContext()
          Initializes the server List from the ParkNParkContext in the name service.
static void main(String[] args)
          Entry point of replication manager
private  boolean refreshParkNParkContext()
          Refreshes the parkNParkContext name service object that we use to get server bindings on.
protected  boolean registerReplicationManager()
          Registers the replication manager's name with the name service.
protected  boolean removeExistingEntries(String serviceName)
          Removes existing server entries that match the given service name.
 void serverRegistered(String ipAddress, String serviceName, ClientManagerFactory cmf)
          Called by servers when they start up.
 void setPrimary(int index)
          Set one of the active servers as the primary
protected  void setupReplicationManagerCORBAObjects(String[] args)
          Setup CORBA objects
 void startServer(ServerState s, boolean corrupted)
          Start a new server or restart a corrupted server
 void unbindServer(ServerState s)
          Unbind the failed server's service name from the naming service
 
Methods inherited from class ParkNPark.interfaces.ReplicationManagerPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _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
 

Field Detail

servers

private ArrayList<ServerState> servers
List of active servers


nameServer

private NamingContextExt nameServer
Naming context


parkNParkContext

private NamingContext parkNParkContext
Our naming service's ParkNPark context, which contains server registrations


orb

private ORB orb
Object request broker


rootPOA

private POA rootPOA
Root POA


projectRoot

protected String projectRoot
The project root, which is used when restarting a failed server


numClients

protected int numClients
Number of clients


interRequestTime

protected int interRequestTime
Time between requests


replySize

protected int replySize
Size of reply


inputEater

protected static PrintStream inputEater
Shared static instance of the input eater output stream wrapped in a PrintStream

Constructor Detail

ReplicationManager

public ReplicationManager()
Method Detail

main

public static void main(String[] args)
Entry point of replication manager

Parameters:
args -

serverRegistered

public void serverRegistered(String ipAddress,
                             String serviceName,
                             ClientManagerFactory cmf)
Called by servers when they start up.

Parameters:
ipAddress -
serviceName -
cmf -

checkServers

public void checkServers()
Check whether or not servers are active


setPrimary

public void setPrimary(int index)
Set one of the active servers as the primary

Parameters:
index -

unbindServer

public void unbindServer(ServerState s)
Unbind the failed server's service name from the naming service

Parameters:
s -

startServer

public void startServer(ServerState s,
                        boolean corrupted)
Start a new server or restart a corrupted server

Parameters:
s -
corrupted -

removeExistingEntries

protected boolean removeExistingEntries(String serviceName)
Removes existing server entries that match the given service name. If a match is the current primary, this method returns true

Parameters:
serviceName - The service name to remove matching entries of

setupReplicationManagerCORBAObjects

protected void setupReplicationManagerCORBAObjects(String[] args)
Setup CORBA objects


registerReplicationManager

protected boolean registerReplicationManager()
Registers the replication manager's name with the name service. You must have called refreshParkNParkContext() before calling this method

Returns:

refreshParkNParkContext

private boolean refreshParkNParkContext()
Refreshes the parkNParkContext name service object that we use to get server bindings on. The name service is contacted from scratch in this method

Returns:
True if the parkNParkContext was refreshed or false if it was not

initializeServerListFromParkNParkContext

protected void initializeServerListFromParkNParkContext()
Initializes the server List from the ParkNParkContext in the name service. As a prerequisite, the caller must ensure that parkNParkContext is not null