SmartFrog 3.10.000

org.smartfrog.sfcore.processcompound
Class ProcessCompoundImpl

java.lang.Object
  extended by org.smartfrog.sfcore.reference.RemoteReferenceResolverHelperImpl
      extended by org.smartfrog.sfcore.prim.PrimImpl
          extended by org.smartfrog.sfcore.compound.CompoundImpl
              extended by org.smartfrog.sfcore.processcompound.ProcessCompoundImpl
All Implemented Interfaces:
java.rmi.Remote, MessageKeys, Compound, ChildMinder, Diagnostics, Liveness, Prim, ProcessCompound, RemoteReferenceResolver, RemoteReferenceResolverHelper

public class ProcessCompoundImpl
extends CompoundImpl
implements ProcessCompound, MessageKeys

Implements deployment behaviour for a process. There is a single process compound allowed per process. SFSystem asks SFProcess to make the processcompound on startup. SFProcess also holds the logic for making a process compound a root for a host. A single root process compound (defined as owning a particular port) is allowed per host. Every processcompound tries to locate its parent on deployment, if there is none, it tries to become the root of the host.

Through the deployer class used for primitives "PrimProcessDeployerImpl" the registration of components on deployment is guaranteed. A component being registered only means that the component is known to the process compound and will receive liveness from it. When the process compound is asked to terminate (ie. asked to terminate the process) all components are terminated.

You do not need to instantiate this class in order to get new processes. In your component description that you want to deploy, simply define sfProcessName with a string name of the processname that you want to deploy your component in. If the process does not exist, and processes are allowed by the root compound on the host, the process will be created and your component deployed.


Field Summary
protected  int countdown
          The countdown to check the gcTimeout.
protected  int gcTimeout
          On liveness check on a process compound checks if it has any components registered.
protected  java.util.Set processLocks
          A set that contains the names of the sub-processes that have been requested, but not yet ready
static long registrationNumber
          A number used to generate a unique ID for registration
protected  boolean sfIsRoot
          Whether the process is a Root (whether is starts and registers with a registry).
protected  java.lang.String sfProcessName
          Name of this processcompound.
protected  boolean systemExit
          Whether the ProcessCompound should cause the JVM to exit on termination.
 
Fields inherited from class org.smartfrog.sfcore.compound.CompoundImpl
childCap, childInc, lifecycleChildren, sfChildren, sfSyncTerminate
 
Fields inherited from class org.smartfrog.sfcore.prim.PrimImpl
refLivenessDelay, refLivenessFactor, sfCompleteName, sfContext, sfDeployHooks, sfDeployWithHooks, sfExportRef, sfIsDeployed, sfIsStarted, sfIsTerminated, sfIsTerminating, sfLivenessCount, sfLivenessDelay, sfLivenessFactor, sfLivenessSender, sfParent, sfStartHooks, sfTerminateWithHooks, termLock
 
Fields inherited from interface org.smartfrog.sfcore.common.MessageKeys
CANNOT_LINK_TO_PREDICATE, COMPONENT_TERMINATED, COPY_FAILED, COPY_SERIALIZE_FAILED, ERROR_NO_SECURITY_BUT_REQUIRED, ILLEGAL_BOOLEAN_PARAMETER, ILLEGAL_NUMERIC_PARAMETER, ILLEGAL_STRING_PARAMETER, ILLEGAL_VECTOR_PARAMETER, LIVENESS_SEND_FAILURE, LIVENESS_SEND_FAILURE_IN, MISSING_PARAMETER, MSG_CLASS_NOT_FOUND, MSG_CONNECT_ERR, MSG_CONT_OTHER_DEPLOY, MSG_DEPLOY_COMP_TERMINATED, MSG_DEPLOY_SUCCESS, MSG_DEPLOYWITH_PHASE_FAILED, MSG_DETACH_SUCCESS, MSG_DETACH_TERMINATE_SUCCESS, MSG_ERR_DEPLOY_FROM_URL, MSG_ERR_PARSE, MSG_ERR_RESOLVE_PHASE, MSG_ERR_SF_RUNNING, MSG_ERR_TERM, MSG_FAILED_INET_ADDRESS_LOOKUP, MSG_FAILED_TO_CONTACT_PARENT, MSG_FILE_NOT_FOUND, MSG_HOOK_ACTION_FAILED, MSG_ILLEGAL_ACCESS, MSG_ILLEGAL_CLASS_TYPE, MSG_ILLEGAL_CLASS_TYPE_EXPECTING_GOT, MSG_ILLEGAL_REFERENCE, MSG_INPUTSTREAM_NULL, MSG_INSTANTIATION_ERROR, MSG_INVALID_OBJECT_TYPE, MSG_INVOCATION_TARGET, MSG_LANG_NOT_FOUND, MSG_LIVENESS_START_FAILED, MSG_LOADING_URL, MSG_METHOD_NOT_FOUND, MSG_NON_REP_ATTRIB, MSG_NOT_COMPONENT_REFERENCE, MSG_NOT_FOUND_ATTRIBUTE, MSG_NOT_FOUND_REFERENCE, MSG_NOT_VALUE_REFERENCE, MSG_NULL_DEF_METHOD, MSG_NULL_URL, MSG_OBJECT_REGISTRATION_FAILED, MSG_PARENT_LOCATION_FAILED, MSG_PING_SUCCESS, MSG_RANDM_ERR, MSG_REMOTE_CONNECT_ERR, MSG_REPEATED_ATTRIBUTE, MSG_SF_DEAD, MSG_SF_READY, MSG_SF_TERMINATED, MSG_STACKTRACE_FOLLOWS, MSG_START_COMP_TERMINATED, MSG_TERMINATE_SUCCESS, MSG_UNHANDLED_EXCEPTION, MSG_UNKNOWN_HOST, MSG_UNRESOLVED_REFERENCE, MSG_UNRESOLVED_REFERENCE_IN, MSG_UPDATE_SUCCESS, MSG_URL_NOT_FOUND, MSG_URL_TO_PARSE_NOT_FOUND, MSG_WARNING_LIVENESS_ENABLED, MSG_WARNING_STACKTRACE_DISABLED, MSG_WARNING_STACKTRACE_ENABLED, ROOT_MUST_BE_COMPONENT, WARN_NO_SECURITY
 
Constructor Summary
ProcessCompoundImpl()
           
 
Method Summary
protected  ProcessCompound addNewProcessCompound(java.lang.Object name, ComponentDescription cd)
          Checks is sub-processes are allowed through attribute system property sfProcessAllow and checks that it is the root process compound.
protected  void addProcessAttributes(java.util.Vector cmd, java.lang.Object name, ComponentDescription cd)
          Constructs sequence of -D statements for the new sub-process by iterating over the sfProcessConfig ComponentDescription.
protected  void addProcessClassName(java.util.Vector cmd, ComponentDescription cd)
          Get the class name for the subprocess.
protected  void addProcessClassPath(java.util.Vector cmd, java.lang.Object name, ComponentDescription cd)
          Gets the current class path out of the system properties and returns it as a command line parameter for the subprocess.
protected  void addProcessDefines(java.util.Vector cmd, java.lang.Object name)
          Constructs sequence of -D statements for the new sub-process by iterating over the current process' properties and looking for those prefixed by org.smartfrog (and not security properties) and creating an entry for each of these.
protected  void addProcessEnvVars(java.util.Vector cmd, ComponentDescription cd)
          Constructs sequence of -D statements for the new sub-process by iterating over the sfProcessEnvVars ComponentDescription
protected  void addProcessJava(java.util.Vector cmd, ComponentDescription cd)
          Gets the process java start command.
protected  void addProcessSFCodeBase(java.util.Vector cmd, java.lang.Object name, ComponentDescription cd)
          Gets the current org.smartfrog.codebase out of the system properties and returns it as a command line parameter for the subprocess.
protected  void registerWithProcessCompound()
          Registers component with local ProcessCompound only if it is root component, its parent is remote or the attribute sfProcessComponentName is defined.
protected  void sfASyncTerminateWith(TerminationRecord status)
          Terminate children asynchronously using a seperate thread for each call.
 Reference sfCompleteName()
          Returns the complete name for this component from the root of the application.
 Prim sfDeployComponentDescription(java.lang.Object name, Prim parent, ComponentDescription cmp, Context parms)
          Override standard compound behaviour to register all components that go throug here as a child compound.
 void sfDeployWith(Prim parent, Context cxt)
          Creates itself as the right form of process: root, sub or independant.
 boolean sfDeRegister(Prim comp)
          DeRegisters a deployed component
 void sfDetach()
          Detach the process compound from its parent.
protected  java.lang.Object sfExport(java.lang.Object portObj)
          Exports this component using portObj.
 boolean sfIsRoot()
          Test whether the Process Compound is the root process compound or not.
 void sfLivenessFailure(java.lang.Object source, java.lang.Object target, java.lang.Throwable failure)
          Override liveness sending failures to just remove component from table, Does NOT to call termination since a child terminating does not mean that this proces should die.
protected  ProcessCompound sfLocateParent()
          Locate the parent process compound.
 void sfNotifySubprocessReady(java.lang.String name)
          Allows a sub-process to notify the root process compound that it is now ready to receive deployment requests.
 void sfPing(java.lang.Object source)
          Implements ping for a compound.
 java.lang.String sfProcessName()
          Returns the processname for this process.
 java.lang.Object sfRegister(java.lang.Object name, Prim comp)
          Register a component under given name.
protected  void sfRegisterWithParent(ProcessCompound parent)
          Parent process compoound can not add me to the attribute list since he did not create me.
 java.lang.Object sfResolveHereOrWait(java.lang.Object name, long timeout)
          Tries to find an attribute in the local context.
 ProcessCompound sfResolveProcess(java.lang.Object name, ComponentDescription cd)
          Find a process for a given name in the root process compound.
 void sfStart()
          Starts the process compound.
protected  void sfSyncTerminateWith(TerminationRecord status)
          Iterates over children telling each of them to terminate quietly with given status.
 void sfTerminatedWith(TerminationRecord rec, Prim comp)
          Process compound sub-component termination policy is currently not to terminate itself (which is default compound behaviour.
 void sfTerminateWith(TerminationRecord rec)
          Termination call.
protected  java.lang.Process startProcess(java.lang.Object name, ComponentDescription cd)
          Does the work of starting up a new process.
 void systemExitOnTermination(boolean exit)
          Sets whether or not the ProcessCompound should terminate the JVM on exit.
 
Methods inherited from class org.smartfrog.sfcore.compound.CompoundImpl
sfAddChild, sfChildren, sfContainsChild, sfCreateNewApp, sfCreateNewChild, sfCreateNewChild, sfDeploy, sfDeployChildren, sfDeployWithChildren, sfDumpState, sfParentageChanged, sfPingChild, sfRemoveAttribute, sfRemoveChild, sfStartChildren
 
Methods inherited from class org.smartfrog.sfcore.prim.PrimImpl
equals, hashCode, sfAddAttribute, sfAttributeKeyFor, sfAttributes, sfCompleteNameSafe, sfContainsAttribute, sfContainsValue, sfContext, sfDeployedHost, sfDeployedProcessName, sfDetachAndTerminate, sfDiagnosticsReport, sfExportRef, sfExportRef, sfGetApplicationLog, sfGetCoreLog, sfGetLog, sfIsDeployed, sfIsRemote, sfIsStarted, sfIsTerminated, sfIsTerminating, sfLog, sfParent, sfReplaceAttribute, sfResolve, sfResolve, sfResolveHere, sfResolveHere, sfResolveParent, sfSetLog, sfStartLivenessSender, sfStopLivenessSender, sfTerminate, sfTerminateQuietlyWith, sfValues, terminateComponent, terminateNotifying, toString
 
Methods inherited from class org.smartfrog.sfcore.reference.RemoteReferenceResolverHelperImpl
sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolveWithParser
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.smartfrog.sfcore.compound.Compound
sfCreateNewApp, sfCreateNewChild, sfCreateNewChild
 
Methods inherited from interface org.smartfrog.sfcore.prim.Prim
sfAddAttribute, sfAttributeKeyFor, sfAttributes, sfContainsAttribute, sfContainsValue, sfContext, sfDeploy, sfDeployedHost, sfDeployedProcessName, sfDetachAndTerminate, sfDumpState, sfIsDeployed, sfIsStarted, sfIsTerminated, sfIsTerminating, sfParent, sfParentageChanged, sfRemoveAttribute, sfReplaceAttribute, sfTerminate, sfTerminateQuietlyWith, sfValues
 
Methods inherited from interface org.smartfrog.sfcore.reference.RemoteReferenceResolver
sfResolve, sfResolve, sfResolveHere, sfResolveHere, sfResolveParent
 
Methods inherited from interface org.smartfrog.sfcore.reference.RemoteReferenceResolverHelper
sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolveWithParser
 
Methods inherited from interface org.smartfrog.sfcore.prim.Diagnostics
sfDiagnosticsReport
 
Methods inherited from interface org.smartfrog.sfcore.prim.ChildMinder
sfAddChild, sfChildren, sfContainsChild, sfRemoveChild
 

Field Detail

registrationNumber

public static long registrationNumber
A number used to generate a unique ID for registration


sfProcessName

protected java.lang.String sfProcessName
Name of this processcompound. If one is present it is a subprocess.


sfIsRoot

protected boolean sfIsRoot
Whether the process is a Root (whether is starts and registers with a registry). Default is not. set using property org.smartfrog.sfcore.processcompound.sfProcessName="rootProcess"


systemExit

protected boolean systemExit
Whether the ProcessCompound should cause the JVM to exit on termination. By default set to true.


gcTimeout

protected int gcTimeout
On liveness check on a process compound checks if it has any components registered. If not, the process compound \"garbage collects\" itself (causing exit!). Since root process compound does not receive liveness it will never do this. The GC is controlled by an attribute in processcompound.sf "sfSubprocessGCTimeout" which indicates the number of pings for which it should be consecutively with no components for the process to be GCed. If this is set to 0, the GC is disabled.


countdown

protected int countdown
The countdown to check the gcTimeout.


processLocks

protected java.util.Set processLocks
A set that contains the names of the sub-processes that have been requested, but not yet ready

Constructor Detail

ProcessCompoundImpl

public ProcessCompoundImpl()
                    throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
Method Detail

sfIsRoot

public boolean sfIsRoot()
                 throws java.rmi.RemoteException
Test whether the Process Compound is the root process compound or not.

Specified by:
sfIsRoot in interface ProcessCompound
Returns:
true if it is the root
Throws:
java.rmi.RemoteException - In case of network/rmi error

sfRegisterWithParent

protected void sfRegisterWithParent(ProcessCompound parent)
                             throws SmartFrogException
Parent process compoound can not add me to the attribute list since he did not create me. Uses sfRegister with specific name to register with parent compound.

Parameters:
parent - parent process compound to register with
Throws:
SmartFrogException - failed to register with parent

sfLocateParent

protected ProcessCompound sfLocateParent()
                                  throws SmartFrogException,
                                         java.rmi.RemoteException
Locate the parent process compound. If sfParent is already set, it is returned, otherwise the parent is looked up using local host process compound, sitting on port given by sfRootLocatorPort attribute.

Returns:
parent process compound or null if root
Throws:
java.rmi.RemoteException - In case of network/rmi error
SmartFrogException - In case of SmartFrog system error

sfDeployComponentDescription

public Prim sfDeployComponentDescription(java.lang.Object name,
                                         Prim parent,
                                         ComponentDescription cmp,
                                         Context parms)
                                  throws SmartFrogDeploymentException
Override standard compound behaviour to register all components that go throug here as a child compound. Sub-components of given description will not go through here, and so will not be registered here. A component is registered through sfRegister. The component can define its name in the process compound through the sfProcessComponentName attribute.

Specified by:
sfDeployComponentDescription in interface Compound
Overrides:
sfDeployComponentDescription in class CompoundImpl
Parameters:
name - name to name deployed component under in context
parent - of deployer component
cmp - compiled component to deploy
parms - parameters for description
Returns:
newly deployed component
Throws:
SmartFrogDeploymentException - failed to deploy compiled component

sfDeployWith

public void sfDeployWith(Prim parent,
                         Context cxt)
                  throws SmartFrogDeploymentException,
                         java.rmi.RemoteException
Creates itself as the right form of process: root, sub or independant. If sfProcessName is an empty string: independant if is rootProcess: become the root process anything else is subprocess and register with parent.

Specified by:
sfDeployWith in interface Prim
Overrides:
sfDeployWith in class CompoundImpl
Parameters:
parent - parent prim. always null (and ignored) for this component
cxt - context for deployement
Throws:
java.rmi.RemoteException - In case of network/rmi error
SmartFrogDeploymentException - In case of any error while deploying the component

sfExport

protected java.lang.Object sfExport(java.lang.Object portObj)
                             throws java.rmi.RemoteException,
                                    java.rmi.RemoteException,
                                    SmartFrogException
Exports this component using portObj. portObj can be a port or a vector containing a set of valid ports. If a vector is used the component tries to see if the port used by the local ProcessCompound is in the vector set and use that if so. If not tries to use the first one avaible

Overrides:
sfExport in class PrimImpl
Parameters:
portObj - Object
Returns:
Object Reference to exported object
Throws:
java.rmi.RemoteException
java.rmi.RemoteException
SmartFrogException

registerWithProcessCompound

protected void registerWithProcessCompound()
                                    throws java.rmi.RemoteException,
                                           SmartFrogException
Description copied from class: PrimImpl
Registers component with local ProcessCompound only if it is root component, its parent is remote or the attribute sfProcessComponentName is defined.

Overrides:
registerWithProcessCompound in class PrimImpl
Throws:
java.rmi.RemoteException - In case of Remote/nework error
SmartFrogException - if failed to register

sfStart

public void sfStart()
             throws SmartFrogException,
                    java.rmi.RemoteException
Starts the process compound. In addition to the normal Compound sfStart, it notifes the root process compound (if it is a sub-process) that it is now ready for action by calling sfNotifySubprocessReady.

Specified by:
sfStart in interface Prim
Overrides:
sfStart in class CompoundImpl
Throws:
SmartFrogException - failed to start compound
java.rmi.RemoteException - In case of Remote/nework error

sfTerminatedWith

public void sfTerminatedWith(TerminationRecord rec,
                             Prim comp)
Process compound sub-component termination policy is currently not to terminate itself (which is default compound behaviour. Component is removed from liveness and attribute table (if present).

Specified by:
sfTerminatedWith in interface Prim
Overrides:
sfTerminatedWith in class CompoundImpl
Parameters:
rec - termination record
comp - component that terminated

sfLivenessFailure

public void sfLivenessFailure(java.lang.Object source,
                              java.lang.Object target,
                              java.lang.Throwable failure)
Override liveness sending failures to just remove component from table, Does NOT to call termination since a child terminating does not mean that this proces should die. If, however, the process is a sub-process, and the failure is from the parent root process, then the process will carry out normal component failure behaviour.

Overrides:
sfLivenessFailure in class PrimImpl
Parameters:
source - sender that failed
target - target for the failure
failure - The error

sfTerminateWith

public void sfTerminateWith(TerminationRecord rec)
Termination call. Could be due to parent failing or management interface. In any case it means terminating all registered components and exiting this process.

Overrides:
sfTerminateWith in class CompoundImpl
Parameters:
rec - termination record

sfSyncTerminateWith

protected void sfSyncTerminateWith(TerminationRecord status)
Iterates over children telling each of them to terminate quietly with given status. It iterates from the last one created to the first one.

Overrides:
sfSyncTerminateWith in class CompoundImpl
Parameters:
status - status to terminate with

sfASyncTerminateWith

protected void sfASyncTerminateWith(TerminationRecord status)
Terminate children asynchronously using a seperate thread for each call. It iterates from the last one created to the first one.

Overrides:
sfASyncTerminateWith in class CompoundImpl
Parameters:
status - status to terminate with

systemExitOnTermination

public void systemExitOnTermination(boolean exit)
                             throws java.rmi.RemoteException
Sets whether or not the ProcessCompound should terminate the JVM on exit. This is, by default, set to true. It is used if the ProcessCompound is created and managed by other code.

Specified by:
systemExitOnTermination in interface ProcessCompound
Parameters:
exit - whether or not to exit (true = exit)
Throws:
java.rmi.RemoteException - In case of network/rmi error

sfDetach

public void sfDetach()
              throws SmartFrogException,
                     java.rmi.RemoteException
Detach the process compound from its parent. The process compound will try to become root process compound for this host. This might fail if the root locator can not make this process compound root.

Specified by:
sfDetach in interface Prim
Overrides:
sfDetach in class PrimImpl
Throws:
SmartFrogException - failed detaching process compound
java.rmi.RemoteException - In case of network/rmi error

sfPing

public void sfPing(java.lang.Object source)
            throws SmartFrogLivenessException,
                   java.rmi.RemoteException
Description copied from class: CompoundImpl
Implements ping for a compound. A compound extends prim functionality by pinging each of its children, any failure to do so will call sfLivenessFailure with the compound as source and the errored child as target. The exception that ocurred is also passed in. This check is only done if the source is non-null and if the source is the parent (if parent exists). If there is no parent and the source is non-null the check is still done.

Specified by:
sfPing in interface Liveness
Overrides:
sfPing in class CompoundImpl
Parameters:
source - source of ping
Throws:
SmartFrogLivenessException - liveness failed
java.rmi.RemoteException - for consistency with the Liveness interface

sfProcessName

public java.lang.String sfProcessName()
Returns the processname for this process. Reference is be empty if this compound is the root for the host.

Specified by:
sfProcessName in interface ProcessCompound
Returns:
process name for this process

sfCompleteName

public Reference sfCompleteName()
                         throws java.rmi.RemoteException
Returns the complete name for this component from the root of the application.

Specified by:
sfCompleteName in interface Prim
Overrides:
sfCompleteName in class PrimImpl
Returns:
reference of attribute names to this component
Throws:
java.rmi.RemoteException - In case of network/rmi error

sfRegister

public java.lang.Object sfRegister(java.lang.Object name,
                                   Prim comp)
                            throws SmartFrogException,
                                   java.rmi.RemoteException
Register a component under given name. Exception is thrown if the name is already used. If name is null a name is made up for the component. Consisting of the complete name of the component concatenated with the current time.

Specified by:
sfRegister in interface ProcessCompound
Parameters:
name - name for component or null for made up name
comp - component to register
Returns:
name of component used
Throws:
SmartFrogException - In case of resolution failure
java.rmi.RemoteException - In case of network/rmi error

sfDeRegister

public boolean sfDeRegister(Prim comp)
                     throws SmartFrogException,
                            java.rmi.RemoteException
DeRegisters a deployed component

Specified by:
sfDeRegister in interface ProcessCompound
Parameters:
comp - component to register
Returns:
true if child is removed successfully else false
Throws:
SmartFrogException - when component was not registered
java.rmi.RemoteException - In case of network/rmi error

sfResolveHereOrWait

public java.lang.Object sfResolveHereOrWait(java.lang.Object name,
                                            long timeout)
                                     throws java.lang.Exception
Tries to find an attribute in the local context. If the attribute is not found the thread will wait for a notification from sfNotifySubprocessReady or until given timeout expires. Used to wait for a new process compound to appear.

Specified by:
sfResolveHereOrWait in interface ProcessCompound
Parameters:
name - name of attribute to wait for
timeout - max time to wait in millis
Returns:
The object found
Throws:
java.lang.Exception - attribute not found after timeout
java.rmi.RemoteException - if there is any network or remote error

sfNotifySubprocessReady

public void sfNotifySubprocessReady(java.lang.String name)
                             throws java.rmi.RemoteException
Allows a sub-process to notify the root process compound that it is now ready to receive deployment requests.

Specified by:
sfNotifySubprocessReady in interface ProcessCompound
Parameters:
name - the name of the subprocess
Throws:
java.rmi.RemoteException - if there is any network or remote error

sfResolveProcess

public ProcessCompound sfResolveProcess(java.lang.Object name,
                                        ComponentDescription cd)
                                 throws java.lang.Exception
Find a process for a given name in the root process compound. If the process is not found it is created.

Specified by:
sfResolveProcess in interface ProcessCompound
Parameters:
name - name of process
cd - component description with extra process configuration (ex. sfProcessAttributes)
Returns:
ProcessCompound associated with the input name
Throws:
java.lang.Exception - failed to deploy process

addNewProcessCompound

protected ProcessCompound addNewProcessCompound(java.lang.Object name,
                                                ComponentDescription cd)
                                         throws java.lang.Exception
Checks is sub-processes are allowed through attribute system property sfProcessAllow and checks that it is the root process compound. Uses startProcess to start the actual sub-process. Then uses sfProcessTimeout to wait for the new process compound to appear in attribute table. If this does not happen the process is killed, and an exception is thrown.

Parameters:
name - name of new compound
Returns:
ProcessCompound
Throws:
java.lang.Exception - failed to deploy new naming compound

startProcess

protected java.lang.Process startProcess(java.lang.Object name,
                                         ComponentDescription cd)
                                  throws java.lang.Exception
Does the work of starting up a new process. Looks up sfProcessJava, sfProcessClass and sfProcessTimeout in the process compound to find out which java to use, which class to start up and how long to max. wait for it to appear in the compounds attribute table. Classpath is looked up through standard system property java.class.path. The process is started up with a -D option containing a quoted reference string giving the full name for the new process. sfProcessINI attribute is passed as the -i URL option to the sub-process indicating system properties to use for the new process. Any property prefixed by 'org.smartfrog.sfcore.processcompound.jvm.'+NAME+property=value will be added only to the subprocess named 'NAME' as a parameter for the JVM. The parameter will be "property+value". @see addProcessDefines Every attribute described by cd.sfProcessConfig will be added to the command line as "-Dorg.smartfrog.processcompound.ATTRIBUTE_NAME=ATTRIBUTE_VALUE"

Parameters:
name - name of new process
cd - component description with extra process configuration (ex. sfProcessConfig)
Returns:
new process
Throws:
java.lang.Exception - failed to locate all attributes, or start process

addProcessJava

protected void addProcessJava(java.util.Vector cmd,
                              ComponentDescription cd)
                       throws java.lang.Exception
Gets the process java start command. Looks up the sfProcessJava attribute. sfProcessJava could be a String or a Collection

Parameters:
cmd - cmd to append to
cd - component description with extra process configuration (ex. sfProcessConfig)
Throws:
java.lang.Exception - failed to construct java command

addProcessClassName

protected void addProcessClassName(java.util.Vector cmd,
                                   ComponentDescription cd)
                            throws java.lang.Exception
Get the class name for the subprocess. Looks up the sfProcessClass attribute out of the current target

Parameters:
cmd - command to append to
cd - component description with extra process configuration (ex. sfProcessClass)
Throws:
java.lang.Exception - failed to construct classname

addProcessClassPath

protected void addProcessClassPath(java.util.Vector cmd,
                                   java.lang.Object name,
                                   ComponentDescription cd)
                            throws java.lang.Exception
Gets the current class path out of the system properties and returns it as a command line parameter for the subprocess. The class path is created reading one of the following in order selection: 1.- from a property named sfcore.processcompound.PROCESS_NAME.java.class.path. 2.- attribute java.class.path inside sfProcessAttribute componentDescription The result if any is added (default) to the system property: System property java.class.path or replaced if sfProcessReplaceClassPath=true

Parameters:
cmd - command to append ro
name - process name
cd - component description with extra process configuration
Throws:
java.lang.Exception - failed to construct classpath

addProcessSFCodeBase

protected void addProcessSFCodeBase(java.util.Vector cmd,
                                    java.lang.Object name,
                                    ComponentDescription cd)
                             throws java.lang.Exception
Gets the current org.smartfrog.codebase out of the system properties and returns it as a command line parameter for the subprocess. The class path is created reading one of the following in order selection: 1.- from a property named sfcore.processcompound.PROCESS_NAME.'org.smartfrog.codebase'. 2.- attribute 'org.smartfrog.codebase' inside sfProcessAttribute componentDescription The result if any is added (default) to the system property: System property 'org.smartfrog.codebase' or replaced if sfProcessReplaceCodeBase=true

Parameters:
cmd - command to append ro
name - process name
cd - component description with extra process configuration
Throws:
java.lang.Exception - failed to construct classpath

addProcessDefines

protected void addProcessDefines(java.util.Vector cmd,
                                 java.lang.Object name)
                          throws java.lang.Exception
Constructs sequence of -D statements for the new sub-process by iterating over the current process' properties and looking for those prefixed by org.smartfrog (and not security properties) and creating an entry for each of these. It modifies the sfProcessName property to be that required. If security is on, you also pass some security related properties. System properties are ordered alfabetically before they are processed. Any property prefixed by 'org.smartfrog.sfcore.processcompound.jvm.'+NAME+.property=value will be added only to the subprocess named 'NAME' as a parameter for the JVM. The parameter will be "value", "property" is only used to name different properties in the initial command line. The property name is important because all sys properties are ordered before they are processed To change the class path in a SubProcess use: 'org.smartfrog.sfcore.processcompound.java.class.path.NAME' Example: org.smartfrog.sfcore.processcompound.jvm.test.propertyname_A=-Xrunpri will add the property '-Xrunpri' to the processCompound named 'test'.

Parameters:
cmd - command to append to
name - name for subprocess
Throws:
java.lang.Exception - failed to construct defines

addProcessAttributes

protected void addProcessAttributes(java.util.Vector cmd,
                                    java.lang.Object name,
                                    ComponentDescription cd)
                             throws java.lang.Exception
Constructs sequence of -D statements for the new sub-process by iterating over the sfProcessConfig ComponentDescription.

Parameters:
cmd - command to append to
cd - component description with extra process configuration (ex. sfProcessConfig)
Throws:
java.lang.Exception - failed to construct defines

addProcessEnvVars

protected void addProcessEnvVars(java.util.Vector cmd,
                                 ComponentDescription cd)
                          throws java.lang.Exception
Constructs sequence of -D statements for the new sub-process by iterating over the sfProcessEnvVars ComponentDescription

Parameters:
cmd - command to append to
cd - component description with extra process configuration (ex. sfProcessConfig)
Throws:
java.lang.Exception - failed to construct defines

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP