wt.manager
Class ServerManagerImpl

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended bywt.util.RMIServer
              extended bywt.manager.ServerManagerImpl
All Implemented Interfaces:
Remote, Serializable, ServerManager, Unreferenced

public class ServerManagerImpl
extends RMIServer
implements ServerManager, Unreferenced

The server manager object. This is an RMI server object that exposes server manager operations to remote clients via the RemoteServerManager class.

See Also:
RemoteServerManager, Serialized Form

Field Summary
private  int activeLaunchCount
           
private static int getAllServersCalls
           
private static int getInfoCalls
           
private static Object getInfoCountLock
           
private static int getNextServerCalls
           
private static int getServerCalls
           
private  Hashtable launchLocks
           
private static int PING_TIMEOUT
           
private  String previousClientHost
           
private static int registerServerCalls
           
private static int reportDeadServerCalls
           
private static String RESOURCE
           
private static int RMI_OBJ_ID
           
private static int SERVER_START_TIMEOUT
           
private static int serverLaunchCount
           
private  ServerTable serverTable
           
private static Date startDate
           
private  Object stopLock
           
private static boolean VERBOSE_SERVER
           
private static boolean VERIFY_DEAD_SERVERS
           
 
Fields inherited from class wt.util.RMIServer
csf, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface wt.manager.ServerManager
SERVER_NAME, versionID
 
Constructor Summary
ServerManagerImpl()
          Construct a RMI Server Manager object.
 
Method Summary
static boolean alive(String service_name, ManagedServer server)
          Test if a given manager server is still alive.
protected  void checkAccess()
          Method to validate access to secure methods such as registerServer or stop.
 Vector getAllServers(String service_name)
          Get all servers for the requested service_name
static int getGetInfoCalls()
           
static int getGetServerCalls()
           
 ServerManagerInfo getInfo()
          Get usage information.
private  Object getLaunchLock(String service_name)
           
static ServerManagerInfo getLocalInfo()
          Get usage information.
 Remote getNextServer(String service_name, Remote server)
          Get the next available server for the requested service_name.
static int getRegisterServerCalls()
           
static int getReportDeadServerCalls()
           
 Remote getServer(String service_name)
          Get reference to a remote server object.
 Remote getServer(String service_name, int start_num)
          Get reference to a remote server object.
static int getServerLaunchCount()
           
static Date getStartDate()
           
 void ping()
          A no-op method available for testing communication.
 void registerServer(String service_name, Remote server)
          Register a new server instance.
 void reportDeadServer(String service_name, Remote server)
          Report a bad remote server reference.
 void reportDeadServer(String service_name, Remote server, Exception report_exception)
          Report a bad remote server reference.
 void stop()
          Stop this server manager.
 void stopAllServers()
          Stop all servers this server manager has started.
 void unreferenced()
          Called when this RMI server object is no longer referenced by any RMI clients.
 
Methods inherited from class wt.util.RMIServer
clone, exportObject, exportObject, exportObject, getClientSocketFactory, getPort, getServerSocketFactory, getStub, isHostInList, isLocalHost, setPort, writeReplace
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

SERVER_START_TIMEOUT

private static final int SERVER_START_TIMEOUT

VERBOSE_SERVER

private static final boolean VERBOSE_SERVER

VERIFY_DEAD_SERVERS

private static final boolean VERIFY_DEAD_SERVERS

RMI_OBJ_ID

private static final int RMI_OBJ_ID

PING_TIMEOUT

private static final int PING_TIMEOUT

startDate

private static Date startDate

registerServerCalls

private static int registerServerCalls

getServerCalls

private static int getServerCalls

getNextServerCalls

private static int getNextServerCalls

getAllServersCalls

private static int getAllServersCalls

reportDeadServerCalls

private static int reportDeadServerCalls

getInfoCalls

private static int getInfoCalls

serverLaunchCount

private static int serverLaunchCount

serverTable

private ServerTable serverTable

launchLocks

private Hashtable launchLocks

stopLock

private Object stopLock

activeLaunchCount

private int activeLaunchCount

getInfoCountLock

private static final Object getInfoCountLock

previousClientHost

private String previousClientHost
Constructor Detail

ServerManagerImpl

public ServerManagerImpl()
                  throws RemoteException
Construct a RMI Server Manager object.

Method Detail

registerServer

public void registerServer(String service_name,
                           Remote server)
                    throws RemoteException
Register a new server instance. Called when servers are started and initialized. Only servers on the local host are allowed to register.

Specified by:
registerServer in interface ServerManager
Parameters:
service_name - service name corresponding to this remote server instance
server - the remote server instance
Throws:
RemoteException

getServer

public Remote getServer(String service_name)
                 throws RemoteException,
                        Exception
Get reference to a remote server object. A service name is used to identify the type of server desired. If a server instance is not already available, a new server is started using an instance of the ServerLauncher class.

Specified by:
getServer in interface ServerManager
Parameters:
service_name - the corresponding service name
Returns:
a remote server reference
Throws:
RemoteException
Exception
See Also:
ServerLauncher

getServer

public Remote getServer(String service_name,
                        int start_num)
                 throws RemoteException,
                        Exception
Get reference to a remote server object. A service name is used to identify the type of server desired. If a server instance is not already available, a new server is started using an instance of the ServerLauncher class.

Specified by:
getServer in interface ServerManager
Parameters:
service_name - the corresponding service name
start_num - used in start up of multiple servers for this service
Returns:
a remote server reference
Throws:
RemoteException
Exception
See Also:
ServerLauncher

getLaunchLock

private Object getLaunchLock(String service_name)

getNextServer

public Remote getNextServer(String service_name,
                            Remote server)
                     throws RemoteException
Get the next available server for the requested service_name. The previous server is used for a reference and if no other server is available, null is returned. This method is used by servers that wish to redirect clients to other servers when doing load leveling.

Specified by:
getNextServer in interface ServerManager
Parameters:
service_name - corresponding service name
server - previous server
Returns:
a remote server reference
Throws:
RemoteException

getAllServers

public Vector getAllServers(String service_name)
                     throws RemoteException
Get all servers for the requested service_name

Specified by:
getAllServers in interface ServerManager
Parameters:
service_name - corresponding service name
Returns:
a vector of remote server references
Throws:
RemoteException

reportDeadServer

public void reportDeadServer(String service_name,
                             Remote server,
                             Exception report_exception)
                      throws RemoteException
Report a bad remote server reference. A bad reference is one that is no longer alive or is throwing unexpected exceptions when trying to invoke services. The bad reference is removed from the server table. Subsequent requests for the given service will return a new server.

Specified by:
reportDeadServer in interface ServerManager
Parameters:
service_name - corresponding service name
server - the remote server reference
Throws:
RemoteException

alive

public static boolean alive(String service_name,
                            ManagedServer server)
Test if a given manager server is still alive. Pings the server with a timeout.

Parameters:
server - the remote server reference

reportDeadServer

public void reportDeadServer(String service_name,
                             Remote server)
                      throws RemoteException
Report a bad remote server reference. A bad reference is one that is no longer alive or is throwing unexpected exceptions when trying to invoke services. The bad reference is removed from the server table. Subsequent requests for the given service will return a new server.

Specified by:
reportDeadServer in interface ServerManager
Parameters:
service_name - corresponding service name
server - the remote server reference
Throws:
RemoteException

getInfo

public ServerManagerInfo getInfo()
Get usage information.

Specified by:
getInfo in interface ServerManager

getLocalInfo

public static ServerManagerInfo getLocalInfo()
Get usage information.


getStartDate

public static Date getStartDate()

getRegisterServerCalls

public static int getRegisterServerCalls()

getGetServerCalls

public static int getGetServerCalls()

getReportDeadServerCalls

public static int getReportDeadServerCalls()

getGetInfoCalls

public static int getGetInfoCalls()

getServerLaunchCount

public static int getServerLaunchCount()

ping

public void ping()
A no-op method available for testing communication.

Specified by:
ping in interface ServerManager

stop

public void stop()
          throws RemoteException
Stop this server manager. WTContext.stop is called to signal shutdown. Only calls originating from the local host will be honored.

Specified by:
stop in interface ServerManager
Throws:
RemoteException

stopAllServers

public void stopAllServers()
                    throws RemoteException
Stop all servers this server manager has started. Only calls originating from the local host will be honored.

Specified by:
stopAllServers in interface ServerManager
Throws:
RemoteException

unreferenced

public void unreferenced()
Called when this RMI server object is no longer referenced by any RMI clients. This is a no-op that simply prints a corresponding log message.

Specified by:
unreferenced in interface Unreferenced

checkAccess

protected void checkAccess()
Method to validate access to secure methods such as registerServer or stop. This implementation assumes this is an RMI call and allows access only from clients that are running on the local (server) host.

Throws:
SecurityException - if check fails and/or access is denied