Interface IWorkerProcess
IHomeLayout
.
Worker process component definitions have no resources beyond a property sheet. A worker process definition typically looks like this:
com.zfabrik.component.type=com.zfabrik.worker # worker configuration # # target states # worker.states=environment/webWorkerUp # # max worker thread pool concurrency # worker.concurrency=15 # # debug port # worker.debug.port=5001 # # timeout (in ms) before the worker will be forcefully killed at worker stop # worker.process.timeouts.termination=20000 # # vm options # worker.process.vmOptions=\ -Xmx128m -Xms128m -XX:+HeapDumpOnOutOfMemoryError \ -Duser.language=en \ -Dcom.sun.management.jmxremote.port=7778
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
("worker.class.path") Classpath setting for the worker process.static final String
("worker.debug.params") In case debugging is enabled (seeWORKER_DEBUG
the params specified by this property will be added.static final String
("-agentlib:jdwp=transport=dt_socket,suspend=n,server=y,address={0}") Default value forDEBUG_PARAMS
.static final String
("worker.debug.port") The debug port to use for this worker process.static final short
static final String
("worker.inheritedSystemProperties") A comma-separated list of system properties for the worker process.static final String
Default value ofINHERITED_SYSPROPS
.static final String
("worker.jmx.params") In case remote JMX access is enabled (seeWORKER_REMOTE_JMX
the params specified by this property will be added.static final String
("-Dcom.sun.management.jmxremote.port={0}") Default value forJMX_PARAMS
.static final String
("worker.jmx.port") The jmx port to use for this worker process.static final String
msg header providing id of target node if one specificstatic final String
msg header describing the target of a messagestatic final String
static final String
static final String
static final String
msg header providing the time out of the message operation (per node).static final short
static final short
static final short
static final String
("worker.states") Target states (or dependency components) of the worker process (see above).static final short
static final String
("worker.process.timeouts.communication") Timeout in milliseconds.static final String
static final String
("worker.process.timeouts.start") Timeout in milliseconds.static final String
static final String
("worker.process.timeouts.termination") Timeout in milliseconds.static final String
static final String
("worker.process.vmOptions") General virtual machine parameters for the worker process.static final String
("worker.concurrency") Size of application thread pool (seeApplicationThreadPool
).static final String
("worker.debug") Debugging for the worker process will be configured if this system property is set totrue
in the home process, e.g.static final String
("worker.remoteJmx") JMX remote access for the worker process will be configured if this system property is set totrue
in the home process, e.g. -
Method Summary
Modifier and TypeMethodDescriptionvoid
detach()
Detach this worker.Get the worker process' component namelong
Get the creation date of the worker process object (this is not necessarily the time it got started)long
Get the time of detachment (if any).getName()
Get the worker process's instance technical nameshort
getState()
get the state of this workerboolean
Returns whether the current process is running.sendMessage
(Map<String, Serializable> args, long timeout) send a message to the process.sendMessage
(Map<String, Serializable> args, long timeout, boolean killOnTimeOut) send a message to the process.void
start()
start this workervoid
stop()
Stop this workervoid
stop
(long timeout) Stop this worker with a non-default timeout.
-
Field Details
-
VMOPTS
("worker.process.vmOptions") General virtual machine parameters for the worker process. See for example http://blogs.sun.com/watt/resource/jvm-options-list.html for a general overview. These params may be qualified further with the value of the system property "os.name" in the form of e.g.worker.process.vmOptions.Windows\ 7=...
In the presence of the latter these will be considered with preference.Note: Virtual machine parameters will be split by separator characters as in
StringTokenizer
. Test enclosed in double quotes will be considered a single token (embracing double quotes excluded). If it is necessary to pass parameters containing a space character for example, use quotes to enclose the option. If the option in turn requires to specify quotes, escape those using the backslash \ character.For example,
worker.process.vmOptions=-Dprop1=A -Dprop2=it works
would resolve to system propertiesprop1="A"
,prop2="it"
and a probably unexpected optionworks
. Using insteadworker.process.vmOptions=-Dprop1=A "-Dprop2=it works"
would resolve to system propertiesprop1="A"
,prop2="it works"
as desired. If we intend to getprop2="it \"works\""
, i.e. the string (delimited with single quotes for clarity) 'it "works"', we would useworker.process.vmOptions=-Dprop1=A "-Dprop2=\"it works\""
- See Also:
-
STATES
("worker.states") Target states (or dependency components) of the worker process (see above). The worker process, when starting, will try to attain these target states (or prepare these dependency components) and will try so again during each verification and synchronization.- See Also:
-
TO_START
("worker.process.timeouts.start") Timeout in milliseconds. This time out determines when the worker process implementation will forcibly kill the worker process if it has not reported startup completion until then.- See Also:
-
TO_TERM
("worker.process.timeouts.termination") Timeout in milliseconds. This time out determines when the worker process implementation will forcibly kill the worker process if it has not terminated after this timeout has passed since it was asked to terminate.- See Also:
-
TO_MSG
("worker.process.timeouts.communication") Timeout in milliseconds. This time out is the default timeout that determines the time passed after which the worker process implementation will forcibly kill a worker process if a message request has not returned.- See Also:
-
WORKER_CONCURRENCY
("worker.concurrency") Size of application thread pool (seeApplicationThreadPool
). In general this thread pool is used for application type work (e.g. for web requests or parallel execution within the application). This property helps achieving a simple but effective concurrent load control- See Also:
-
WORKER_DEBUG
("worker.debug") Debugging for the worker process will be configured if this system property is set totrue
in the home process, e.g. by setting "-Dworker.debug=true" in the home process command line.This is not a profile parameter for the worker process definition. This is strictly the method to enable debugging for worker processes as launched by the home process. Otherwise the worker process will not be configured for debugging.
- See Also:
-
DEBUG_PORT
("worker.debug.port") The debug port to use for this worker process. If this configuration is present and the home process is configured for debugging, so will the worker process. This port is subject to variant computation in the presence of detached worker processes. That is, this base port number will be increased by the variant number of the worker process that increases with every added instance, starting at 0. The variant number is the @-separated tail of the worker process name. SeeDEBUG_PARAMS
for actual parameters added to the worker process command line.- See Also:
-
DEBUG_PARAMS
("worker.debug.params") In case debugging is enabled (seeWORKER_DEBUG
the params specified by this property will be added. These default to"-agentlib:jdwp=transport=dt_socket,suspend=n,server=y,address={0}"
The substitution {0} will be replaced by a debug port computed as inDEBUG_PORT
.- See Also:
-
DEBUG_PARAMS_DEFAULT
("-agentlib:jdwp=transport=dt_socket,suspend=n,server=y,address={0}") Default value forDEBUG_PARAMS
.- See Also:
-
CLASSPATH
("worker.class.path") Classpath setting for the worker process. By default, the worker process inherits the class path from the home process. If that is not desired this setting allows to specify a different classpath. All paths should be specified relative to the current working folder which is typically the ${Z2_HOME}/bin folder. If the property value has a substitution field {0} it will be replaced by the home process classpath- See Also:
-
INHERITED_SYSPROPS
("worker.inheritedSystemProperties") A comma-separated list of system properties for the worker process. The value of some system properties may be forwarded on to the worker process. Currently this defaults to "com.sun.management.config.file,com.zfabrik.config,java.util.logging.config.file,com.zfabrik.dev.local.workspace,com.zfabrik.dev.local.repo,com.zfabrik.repo.mode,com.zfabrik.proxy.auth,java.library.path,com.zfabrik.mode,https.proxyPort,https.proxyHost,http.proxyPort,http.proxyHost,proxyPort,proxyHost,proxyUser,proxyPassword"- See Also:
-
INHERITED_SYSPROPS_DEFAULT
Default value ofINHERITED_SYSPROPS
.- See Also:
-
WORKER_REMOTE_JMX
("worker.remoteJmx") JMX remote access for the worker process will be configured if this system property is set totrue
in the home process, e.g. by setting "-Dworker.remoteJMX=true" in the home process command line.This is not a profile parameter for the worker process definition. This is strictly the method to enable remote JMX port setting for worker processes as launched by the home process.
- See Also:
-
JMX_PORT
("worker.jmx.port") The jmx port to use for this worker process. If this is set, the system property "com.sun.management.jmxremote.port" will be set via a system property declaration in the worker process command line. This port is subject to variant computation in the presence of detached worker processes. That is, this base port number will be increased by the variant number of the worker process that increases with every added instance, starting at 0. The variant number is the @-separated tail of the worker process name.- See Also:
-
JMX_PARAMS
("worker.jmx.params") In case remote JMX access is enabled (seeWORKER_REMOTE_JMX
the params specified by this property will be added. These default to"-Dcom.sun.management.jmxremote.port={0}"
The substitution {0} will be replaced by a debug port computed as inJMX_PORT
.- See Also:
-
JMX_PARAMS_DEFAULT
("-Dcom.sun.management.jmxremote.port={0}") Default value forJMX_PARAMS
.- See Also:
-
TO_START_DEF
- See Also:
-
TO_TERM_DEF
- See Also:
-
TO_MSG_DEF
- See Also:
-
MSG_TARGET
msg header describing the target of a message- See Also:
-
MSG_TARGET_NODE
- See Also:
-
MSG_TARGET_ALL
- See Also:
-
MSG_TARGET_HOME
- See Also:
-
MSG_NODE
msg header providing id of target node if one specific- See Also:
-
MSG_TIMEOUT
msg header providing the time out of the message operation (per node). Can be provided as long or as string- See Also:
-
NOT_STARTED
static final short NOT_STARTED- See Also:
-
STARTING
static final short STARTING- See Also:
-
STARTED
static final short STARTED- See Also:
-
DETACHED
static final short DETACHED- See Also:
-
STOPPING
static final short STOPPING- See Also:
-
-
Method Details
-
sendMessage
Map<String,Serializable> sendMessage(Map<String, Serializable> args, long timeout) throws IOExceptionsend a message to the process. Note: message sending happens completely synchronously. A message is just a name value map. All content must be serializable (preferrably string). Its return value is also just a map.- Parameters:
args
- a map of name value pairs that will be serialized as strings to the slavetimeout
- timeout for message answering in ms.- Returns:
- a result map
- Throws:
IOException
-
sendMessage
Map<String,Serializable> sendMessage(Map<String, Serializable> args, long timeout, boolean killOnTimeOut) throws IOExceptionsend a message to the process. Note: message sending happens completely synchronously. A message is just a name value map. All content must be serializable (preferrably string). Its return value is also just a map.- Parameters:
args
- a map of name value pairs that will be serialized as strings to the slavetimeout
- timeout for message answering in ms.killOnTimeOut
- iftrue
a timeout will lead to a process termination.- Returns:
- a result map
- Throws:
IOException
-
stop
void stop()Stop this worker -
stop
void stop(long timeout) Stop this worker with a non-default timeout. A timeout greater than 0 will ask the worker process to terminate gracefully. A timeout of 0 will stop the process immediately -
start
void start()start this worker -
detach
void detach()Detach this worker. Detaching means that this worker will no longer receive synchronization notifications from the home process. This worker is meant to complete its work and terminate gracefully. -
isRunning
boolean isRunning()Returns whether the current process is running. This is equivalent to being the latest and up or up and detached. -
getState
short getState()get the state of this worker -
getComponentName
String getComponentName()Get the worker process' component name -
getName
String getName()Get the worker process's instance technical name -
getCreated
long getCreated()Get the creation date of the worker process object (this is not necessarily the time it got started) -
getDetachTime
long getDetachTime()Get the time of detachment (if any). Returns <0 if not detached.
-