jpl.mipl.pgs.core
Class ServiceFactory

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.activation.Activatable
              extended by jpl.mipl.pgs.core.ActivatableServerBase
                  extended by jpl.mipl.pgs.core.ServiceFactory
All Implemented Interfaces:
Serializable, Remote, ProcessControl_IF, ServerBase_IF, ServiceFactory_IF

public class ServiceFactory
extends ActivatableServerBase
implements ServiceFactory_IF

The Service Factory processes requests assigned to it by the Controller. It maintains it's load factor using the supplied load calculator.


      Copyright 2004-PRESENT, California Institute of Technology. 
      ALL RIGHTS RESERVED.
      U.S. Government Sponsorship acknowledge.
 
 

Author:
Elias Sayfi {ems@mipl.jpl.nasa.gov}, Raj Patel {rrp@jpl.nasa.gov}
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jpl.mipl.pgs.core.ActivatableServerBase
currentStatus, logger, mission, serverName, startUpData, userPassWd
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface jpl.mipl.pgs.core.ServiceFactory_IF
CANNOT_HANDLE_THIS_REQUEST
 
Constructor Summary
ServiceFactory(ActivationID id, MarshalledObject data)
          Default constructor
 
Method Summary
 void abort(String processName, Long pIID, String reason)
          Abort the specified process instance.
protected  void checkRequests()
           
 void configure(PGSSession tsession, Map ht)
          For configuring ServiceFactory.
 int getActiveRequestsCount()
          Returns number of requests this SF is running.
 Map getInfo()
          Return the startup data
 float getLoadFactor(Map request)
          Get the load factor from the Load Calculator
 void pause(String processName, Long pIID, String reason, String nodeName)
          Pause either all or specified process instance.
 void requestCompleted(String processInstanceId)
           
 void reRunAbortedRequests()
          Execute all stopped requests belonging to this service factory.
 void reRunStoppedRequests()
          Execute all stopped requests belonging to this service factory.
 void resume(String processName, Long pIID, String nodeName)
          Resume the specified process instance.
 void runRequest(PGSSession tsession, Map request)
          Starts the request specified my the parameter.
 void setController(Controller_IF controller)
          Set the reference to the controller
 boolean shutdown(PGSSession tsession, String explanation, boolean forceExit)
          Shut down this service factory
 void stop(PGSSession tsession, boolean waitForAll)
          Stop the factory and all request it is running.
 void stop(String processName, Long pIID, String reason)
          Stop the specified process instance.
 
Methods inherited from class jpl.mipl.pgs.core.ActivatableServerBase
getStatus, shutDown
 
Methods inherited from class java.rmi.activation.Activatable
exportObject, exportObject, exportObject, exportObject, getID, inactive, register, unexportObject, unregister
 
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jpl.mipl.pgs.core.ServerBase_IF
getStatus
 

Constructor Detail

ServiceFactory

public ServiceFactory(ActivationID id,
                      MarshalledObject data)
               throws RemoteException,
                      ActivationException
Default constructor

Parameters:
id - activation id
data - A marshalled object containing startup data
Throws:
RemoteException - if the parent class throws remote exception or for other reasons.
ActivationException - if the parent class throws activation exception or for other reasons.
Method Detail

configure

public void configure(PGSSession tsession,
                      Map ht)
               throws RemoteException
For configuring ServiceFactory.

Specified by:
configure in interface ServiceFactory_IF
Parameters:
tsession - A valid PGSSession.
ht - Containing the following parameters:
Monitor Frequency
Throws:
RemoteException

reRunStoppedRequests

public void reRunStoppedRequests()
                          throws RemoteException
Execute all stopped requests belonging to this service factory.

Specified by:
reRunStoppedRequests in interface ServiceFactory_IF
Throws:
RemoteException

reRunAbortedRequests

public void reRunAbortedRequests()
                          throws RemoteException
Execute all stopped requests belonging to this service factory.

Specified by:
reRunAbortedRequests in interface ServiceFactory_IF
Throws:
RemoteException

checkRequests

protected final void checkRequests()

getInfo

public Map getInfo()
            throws RemoteException
Return the startup data

Specified by:
getInfo in interface ServiceFactory_IF
Returns:
this.startUpData start up parameters
Throws:
RemoteException

getLoadFactor

public float getLoadFactor(Map request)
                    throws RemoteException
Get the load factor from the Load Calculator

Specified by:
getLoadFactor in interface ServiceFactory_IF
Returns:
a value between 0 and 1 where higher number indicates higher load Return ServiceFactory_IF.CANNOT_HANDLE_THIS_REQUEST to indicate that this SF is either too busy or not configured to run request of this type.
Throws:
RemoteException

runRequest

public void runRequest(PGSSession tsession,
                       Map request)
                throws RemoteException
Starts the request specified my the parameter.

Specified by:
runRequest in interface ServiceFactory_IF
Parameters:
tsession - The PGS session object to be used to authenticate the user
request - The request to be processed. When database is in use, this method first looks for USERID, if not found, it uses the id and password of the user that started this SF. If USERID is specified then PASSWD must also be specified.
Throws:
RemoteException

requestCompleted

public void requestCompleted(String processInstanceId)
                      throws Exception
Throws:
Exception

stop

public void stop(PGSSession tsession,
                 boolean waitForAll)
          throws RemoteException
Stop the factory and all request it is running. This call will block till all requests completes.

Specified by:
stop in interface ServiceFactory_IF
Parameters:
tsession - A session object created by using PersistentStore
waitForAll - If true, the SF will wait for all request to complete before returning. If false, the SF will just signal each running request to stop and return.
Throws:
RemoteException

setController

public void setController(Controller_IF controller)
                   throws RemoteException
Set the reference to the controller

Specified by:
setController in interface ServiceFactory_IF
Throws:
RemoteException

shutdown

public boolean shutdown(PGSSession tsession,
                        String explanation,
                        boolean forceExit)
                 throws RemoteException
Shut down this service factory

Specified by:
shutdown in interface ServerBase_IF
Specified by:
shutdown in class ActivatableServerBase
Parameters:
tsession - A session object created by PersistentStore
explanation - The reason for shutdown
forceExit - If set to true, each running request will be aborted. If false each running request is stopped. In either case this method waits for all running request to halt.
Returns:
false if an error occurs. True otherwise.
Throws:
RemoteException - If the user is not authorized or an error occurs in shutdown.

getActiveRequestsCount

public int getActiveRequestsCount()
                           throws RemoteException
Description copied from interface: ServiceFactory_IF
Returns number of requests this SF is running.

Specified by:
getActiveRequestsCount in interface ServiceFactory_IF
Throws:
RemoteException
See Also:
ServiceFactory_IF.getActiveRequestsCount()

pause

public void pause(String processName,
                  Long pIID,
                  String reason,
                  String nodeName)
           throws RemoteException
Pause either all or specified process instance. Any null parameters are ignored.

Specified by:
pause in interface ProcessControl_IF
Parameters:
processName - the name of the process that is to be stopped.
pIID - the ID of the process instance that is to be stopped.
reason - an explanation, if appropriate, for the pause.
nodeName - the name of the node where the process is to pause. The algorithm is as follows: -- if process id is not null, then pause it at the specified node. -- else if process name is not null, then pause all processes with that given name at the specified node -- else pause all process instances at specified node. if nodeName is null, process instances are paused at current state.
Throws:
RemoteException

resume

public void resume(String processName,
                   Long pIID,
                   String nodeName)
            throws RemoteException
Resume the specified process instance. See #pause for parameter documentation.

Specified by:
resume in interface ProcessControl_IF
Throws:
RemoteException

stop

public void stop(String processName,
                 Long pIID,
                 String reason)
          throws RemoteException
Stop the specified process instance. See #pause for parameter documentation.

Specified by:
stop in interface ProcessControl_IF
Throws:
RemoteException

abort

public void abort(String processName,
                  Long pIID,
                  String reason)
           throws RemoteException
Abort the specified process instance. See #pause for parameter documentation.

Specified by:
abort in interface ProcessControl_IF
Throws:
RemoteException