Job Forking: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
As of Obsidian 3.0.0, Obsidian can run each job in its own JVM. This allows for a number of possibilities, not the least of which is supporting dynamic changes to your deployed, compiled jobs, also known as hot-swapping of JARs. | As of Obsidian 3.0.0, Obsidian can run each job in its own JVM. This allows for a number of possibilities, not the least of which is supporting dynamic changes to your deployed, compiled jobs, also known as hot-swapping of JARs. In theory, you could even specialize classpaths on a per job basis by customizing the executions scripts provided or writing your own. | ||
To ensure backwards compatibility and controlled usage of this functionality, it is disabled by default for the cluster. Standalone deployments are configured to have it enabled, but are not active until you enable it for the cluster. | To ensure backwards compatibility and controlled usage of this functionality, it is disabled by default for the cluster. Standalone deployments are configured to have it enabled, but are not active until you enable it for the cluster. | ||
| Line 21: | Line 21: | ||
<code>com.carfey.obsidian.forkedJobScriptLocation=/Obsidian-3.0.0</code> | <code>com.carfey.obsidian.forkedJobScriptLocation=/Obsidian-3.0.0</code> | ||
This property is the location of the fork scripts. Obsidian is bundled with '''obsidianForkedJob.bat''' and '''obsidianForkedJob.sh'''. These are the '''expected''' script names. | This property is the location of the fork scripts. Obsidian is bundled with '''<code>obsidianForkedJob.bat</code>''' and '''<code>obsidianForkedJob.sh</code>'''. These are the '''expected''' script names. | ||
If you wish to customize these scripts or use your own, you are free to do so. But the script names must be as specified. Details about the [[#Forked Obsidian Job Runner | Forked Obsidian Job Runner]] will be helpful in your customization efforts. | If you wish to customize these scripts or use your own, you are free to do so. But the script names must be as specified. Details about the [[#Forked Obsidian Job Runner | Forked Obsidian Job Runner]] will be helpful in your customization efforts. | ||
=== Classpath Override === | === Classpath Override === | ||
You may wish to override the default classpath that is used by the forked execution instance. Or for deployment types other than [[Getting_Started#Standalone_Scheduler | Standalone Scheduler]], you can use this property to specify the classpath. | |||
<code>com.carfey.obsidian.forkedJobscriptClasspathOverride=/home/user/workspace/obsidian/bin:/home/user/workspace/obsidian/lib/activation-1.1.jar:/home/user/workspace/obsidian/lib/mail-1.4.jar:/home/user/workspace/obsidian/lib/dom4j-1.6.1.jar:/home/user/workspace/obsidian/lib/obsidian.jar:/home/user/workspace/obsidian/lib/log4j-1.2.9.jar:/home/user/workspace/obsidian/lib/gson-2.2.2.jar:/home/user/workspace/obsidian/lib/bsh-2.0b4.jar:/home/user/workspace/obsidian/lib/groovy-all-2.1.8.jar:/home/user/workspace/obsidian/lib/jython-standalone-2.5.3.jar:/home/user/workspace/obsidian/lib/mariadb-java-client-1.1.5.jar | <code>com.carfey.obsidian.forkedJobscriptClasspathOverride=/home/user/workspace/obsidian/bin:/home/user/workspace/obsidian/lib/activation-1.1.jar:/home/user/workspace/obsidian/lib/mail-1.4.jar:/home/user/workspace/obsidian/lib/dom4j-1.6.1.jar:/home/user/workspace/obsidian/lib/obsidian.jar:/home/user/workspace/obsidian/lib/log4j-1.2.9.jar:/home/user/workspace/obsidian/lib/gson-2.2.2.jar:/home/user/workspace/obsidian/lib/bsh-2.0b4.jar:/home/user/workspace/obsidian/lib/groovy-all-2.1.8.jar:/home/user/workspace/obsidian/lib/jython-standalone-2.5.3.jar:/home/user/workspace/obsidian/lib/mariadb-java-client-1.1.5.jar | ||
</code> | </code> | ||
The sample demonstrates usage in an embedded Obsidian instance running inside an Eclipse project. The default classpath used in the <code>obsidianForkedJob.sh/.bat</code> script is built automatically assuming a [[Getting_Started#Standalone_Scheduler | Standalone Scheduler]] deployment. As such, it uses the jars in the <code>standalone/</code> directory for building the classpath. If you require custom classpath on a per job basis, modification of the script(s) will be required. | |||
= What is Job Forking Doing? = | = What is Job Forking Doing? = | ||
Job Forking is implemented by calling | Job Forking is implemented by the Obsidian runtime invoking a script for each job execution to be forked. This script in turn invokes a JVM calling an Obsidian class' main method providing the appropriate arguments to start the single-job execution Obsidian runtime | ||
== Script Arguments == | |||
Obsidian calls the script with 15 arguments. | |||
# job_history_id - the job execution instance identifier | |||
# job_nickname | |||
# job_class | |||
# running_host | |||
# stack_file - used by the Scheduler Node to be aware of execution exceptions | |||
# db_url | |||
# db_jndi | |||
# db_user | |||
# db_pass | |||
# db_max_conn | |||
# db_conn_timeout | |||
# db_unused_conn_timeout | |||
# db_table_prefix | |||
# db_schema | |||
# classpath_override - optionally provided if the <code>com.carfey.obsidian.forkedJobscriptClasspathOverride</code> property is present. | |||
= Forked Obsidian Job Runner = | = Forked Obsidian Job Runner = | ||
The Obsidian class that is a Forked Obsidian Job Runtime is <code>com.carfey.ops.job.ForkedJob</code>. Its main method must be called with 2 arguments. | |||
# job_history_id | |||
# stack_file | |||
The other arguments provided are for either customization efforts or available to be passed as System Properties for db connectivity (if required). | |||
-Dcom.carfey.obsidian.db.url=$6 -Dcom.carfey.obsidian.db.jndiType=$7 -Dcom.carfey.obsidian.db.userId=$8 \ | |||
-Dcom.carfey.obsidian.db.password=$9 -Dcom.carfey.obsidian.db.maxConnections=${10} -Dcom.carfey.obsidian.db.connectionTimeout=${11} \ | |||
-Dcom.carfey.obsidian.db.unusedPoolConnectionTimeoutSeconds=${12} -Dcom.carfey.obsidian.db.tablePrefix=${13} -Dcom.carfey.obsidian.db.schema=${14} | |||
Revision as of 13:48, 30 January 2015
As of Obsidian 3.0.0, Obsidian can run each job in its own JVM. This allows for a number of possibilities, not the least of which is supporting dynamic changes to your deployed, compiled jobs, also known as hot-swapping of JARs. In theory, you could even specialize classpaths on a per job basis by customizing the executions scripts provided or writing your own.
To ensure backwards compatibility and controlled usage of this functionality, it is disabled by default for the cluster. Standalone deployments are configured to have it enabled, but are not active until you enable it for the cluster.
Configuring Job Forking
Enabling Job Forking - Cluster
First you must enable the functionality on the cluster. This is a System Parameter found in the JobSpawner category. You may enable it via the Admin UI, via one of the provided APIs (Embedded API or REST API) or the Initializing and Restoring support.
Enabling Job Forking - Node
Once you've done that, you'll need to enable it on each desired node. Standalone Schedulers are already thus enabled. For other nodes, you will need to set the appropriate properties value entry.
com.carfey.obsidian.jvmJobForkingEnabledOnThisNode=true
In a Standalone Scheduler, Job Forking will be functional on next start/restart.
Script Location
You may wish to specify the forking script location for other deployments ( Embedded, Scheduler with Admin WebApp, or for other reasons.
com.carfey.obsidian.forkedJobScriptLocation=/Obsidian-3.0.0
This property is the location of the fork scripts. Obsidian is bundled with obsidianForkedJob.bat and obsidianForkedJob.sh. These are the expected script names.
If you wish to customize these scripts or use your own, you are free to do so. But the script names must be as specified. Details about the Forked Obsidian Job Runner will be helpful in your customization efforts.
Classpath Override
You may wish to override the default classpath that is used by the forked execution instance. Or for deployment types other than Standalone Scheduler, you can use this property to specify the classpath.
com.carfey.obsidian.forkedJobscriptClasspathOverride=/home/user/workspace/obsidian/bin:/home/user/workspace/obsidian/lib/activation-1.1.jar:/home/user/workspace/obsidian/lib/mail-1.4.jar:/home/user/workspace/obsidian/lib/dom4j-1.6.1.jar:/home/user/workspace/obsidian/lib/obsidian.jar:/home/user/workspace/obsidian/lib/log4j-1.2.9.jar:/home/user/workspace/obsidian/lib/gson-2.2.2.jar:/home/user/workspace/obsidian/lib/bsh-2.0b4.jar:/home/user/workspace/obsidian/lib/groovy-all-2.1.8.jar:/home/user/workspace/obsidian/lib/jython-standalone-2.5.3.jar:/home/user/workspace/obsidian/lib/mariadb-java-client-1.1.5.jar
The sample demonstrates usage in an embedded Obsidian instance running inside an Eclipse project. The default classpath used in the obsidianForkedJob.sh/.bat script is built automatically assuming a Standalone Scheduler deployment. As such, it uses the jars in the standalone/ directory for building the classpath. If you require custom classpath on a per job basis, modification of the script(s) will be required.
What is Job Forking Doing?
Job Forking is implemented by the Obsidian runtime invoking a script for each job execution to be forked. This script in turn invokes a JVM calling an Obsidian class' main method providing the appropriate arguments to start the single-job execution Obsidian runtime
Script Arguments
Obsidian calls the script with 15 arguments.
- job_history_id - the job execution instance identifier
- job_nickname
- job_class
- running_host
- stack_file - used by the Scheduler Node to be aware of execution exceptions
- db_url
- db_jndi
- db_user
- db_pass
- db_max_conn
- db_conn_timeout
- db_unused_conn_timeout
- db_table_prefix
- db_schema
- classpath_override - optionally provided if the
com.carfey.obsidian.forkedJobscriptClasspathOverrideproperty is present.
Forked Obsidian Job Runner
The Obsidian class that is a Forked Obsidian Job Runtime is com.carfey.ops.job.ForkedJob. Its main method must be called with 2 arguments.
- job_history_id
- stack_file
The other arguments provided are for either customization efforts or available to be passed as System Properties for db connectivity (if required).
-Dcom.carfey.obsidian.db.url=$6 -Dcom.carfey.obsidian.db.jndiType=$7 -Dcom.carfey.obsidian.db.userId=$8 \ -Dcom.carfey.obsidian.db.password=$9 -Dcom.carfey.obsidian.db.maxConnections=${10} -Dcom.carfey.obsidian.db.connectionTimeout=${11} \ -Dcom.carfey.obsidian.db.unusedPoolConnectionTimeoutSeconds=${12} -Dcom.carfey.obsidian.db.tablePrefix=${13} -Dcom.carfey.obsidian.db.schema=${14}