github.com/dkerwin/nomad@v0.3.3-0.20160525181927-74554135514b/website/source/docs/drivers/java.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Drivers: Java"
     4  sidebar_current: "docs-drivers-java"
     5  description: |-
     6    The Java task driver is used to run Jars using the JVM.
     7  ---
     8  
     9  # Java Driver
    10  
    11  Name: `java`
    12  
    13  The `Java` driver is used to execute Java applications packaged into a Java Jar
    14  file. The driver requires the Jar file to be accessible from the Nomad
    15  client via the [`artifact` downloader](/docs/jobspec/index.html#artifact_doc). 
    16  
    17  ## Task Configuration
    18  
    19  The `java` driver supports the following configuration in the job spec:
    20  
    21  * `jar_path` - The path to the downloaded Jar. In most cases this will just be
    22    the name of the Jar. However, if the supplied artifact is an archive that
    23    contains the Jar in a subfolder, the path will need to be the relative path
    24    (`subdir/from_archive/my.jar`).
    25  
    26  *   `args` - (Optional) A list of arguments to the optional `command`.
    27      References to environment variables or any [intepretable Nomad
    28      variables](/docs/jobspec/interpreted.html) will be interpreted
    29      before launching the task. For example:
    30  
    31      ```
    32          args = ["${nomad.datacenter}", "${MY_ENV}", "${meta.foo}"]
    33      ```
    34  
    35  * `jvm_options` - (Optional) A list of JVM options to be passed while invoking
    36    java. These options are passed not validated in any way in Nomad.
    37  
    38  ## Examples
    39  
    40  A simple config block to run a Java Jar:
    41  
    42  ```
    43  task "web" {
    44    driver = "java"
    45  
    46    config {
    47      jar_path = "local/hello.jar"
    48      jvm_options = "-Xmx2048m -Xms256m"
    49    }
    50  
    51    # Specifying an artifact is required with the "java"
    52    # driver. This is the # mechanism to ship the Jar to be run.
    53    artifact {
    54      source = "https://dl.dropboxusercontent.com/u/1234/hello.jar"
    55  
    56      options {
    57        checksum = "md5:123445555555555"
    58      }
    59    }
    60  ```
    61  
    62  ## Client Requirements
    63  
    64  The `java` driver requires Java to be installed and in your systems `$PATH`. The
    65  task must also specify at least one artifact to download as this is the only way
    66  to retrieve the Jar being run.
    67  
    68  ## Client Attributes
    69  
    70  The `java` driver will set the following client attributes:
    71  
    72  * `driver.java` - Set to `1` if Java is found on the host node. Nomad determines
    73  this by executing `java -version` on the host and parsing the output
    74  * `driver.java.version` - Version of Java, ex: `1.6.0_65`
    75  * `driver.java.runtime` - Runtime version, ex: `Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)`
    76  * `driver.java.vm` - Virtual Machine information, ex: `Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)`
    77  
    78  ## Resource Isolation
    79  
    80  The resource isolation provided varies by the operating system of
    81  the client and the configuration.
    82  
    83  On Linux, Nomad will attempt to use cgroups, namespaces, and chroot
    84  to isolate the resources of a process. If the Nomad agent is not
    85  running as root many of these mechanisms cannot be used.
    86  
    87  As a baseline, the Java jars will be run inside a Java Virtual Machine,
    88  providing a minimum amount of isolation.
    89