com.hazelcast.jet.config

## Class JobConfig

- java.lang.Object
- - com.hazelcast.jet.config.JobConfig

- All Implemented Interfaces:
    DataSerializable, IdentifiedDataSerializable

      public class JobConfig
      extends Object
      implements IdentifiedDataSerializable

  Contains the configuration specific to one Hazelcast Jet job.
  Since:
    3.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobConfig()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JobConfig` | `addClass(Class... classes)` Adds the supplied classes to the list of resources that will be available on the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addJar(File file)` Adds the supplied JAR file to the list of JARs that will be a part of the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addJar(String path)` Adds the JAR identified by the supplied pathname to the list of JARs that will be a part of the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addJar(URL url)` Adds the JAR identified by the supplied URL to the list of JARs that will be a part of the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addResource(File file)` Adds the supplied file to the list of resources that will be on the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addResource(File file, String id)` Adds the supplied file to the list of resources that will be on the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addResource(String path)` Adds the resource identified by the supplied pathname to the list of resources that will be on the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addResource(String path, String id)` Adds the resource identified by the supplied pathname to the list of resources that will be on the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addResource(URL url)` Adds the resource identified by the supplied URL to the list of resources that will be on the job's classpath while it's executing in the Jet cluster.
    `JobConfig` | `addResource(URL url, String id)` Adds the resource identified by the supplied URL to the list of resources that will be on the job's classpath while it's executing in the Jet cluster.
    `boolean` | `equals(Object o)`
    `JobClassLoaderFactory` | `getClassLoaderFactory()` Returns the configured `JobClassLoaderFactory`.
    `int` | `getFactoryId()` Returns DataSerializableFactory factory ID for this class.
    `int` | `getId()` Returns type identifier for this class.
    `String` | `getInitialSnapshotName()` Returns the configured initial snapshot name or `null` if no initial snapshot is configured.
    `String` | `getName()` Returns the name of the job or `null` if no name was given.
    `ProcessingGuarantee` | `getProcessingGuarantee()` Returns the configured `processing guarantee`.
    `List<ResourceConfig>` | `getResourceConfigs()` Returns all the registered resource configurations.
    `long` | `getSnapshotIntervalMillis()` Returns the configured `snapshot interval`.
    `int` | `hashCode()`
    `boolean` | `isAutoScaling()` Returns whether auto scaling is enabled, see `setAutoScaling(boolean)`.
    `boolean` | `isMetricsEnabled()` Returns if metrics collection is enabled for the job.
    `boolean` | `isSplitBrainProtectionEnabled()` Tells whether `split brain protection` is enabled.
    `boolean` | `isStoreMetricsAfterJobCompletion()` Returns whether metrics should be stored in the cluster after the job completes.
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `JobConfig` | `setAutoScaling(boolean enabled)` Sets whether Jet will scale the job up or down when a member is added or removed from the cluster.
    `JobConfig` | `setClassLoaderFactory(JobClassLoaderFactory classLoaderFactory)` Sets a custom `JobClassLoaderFactory` that will be used to load job classes and resources on Jet members.
    `JobConfig` | `setInitialSnapshotName(String initialSnapshotName)` Sets the exported state snapshot name to restore the initial job state from.
    `JobConfig` | `setMetricsEnabled(boolean enabled)` Sets whether metrics collection should be enabled for the job.
    `JobConfig` | `setName(String name)` Sets the name of the job.
    `JobConfig` | `setProcessingGuarantee(ProcessingGuarantee processingGuarantee)` Set the `processing guarantee` for the job.
    `JobConfig` | `setSnapshotIntervalMillis(long snapshotInterval)` Sets the snapshot interval in milliseconds — the interval between the completion of the previous snapshot and the start of a new one.
    `JobConfig` | `setSplitBrainProtection(boolean isEnabled)` Configures the split brain protection feature.
    `JobConfig` | `setStoreMetricsAfterJobCompletion(boolean storeMetricsAfterJobCompletion)` Sets whether metrics should be stored in the cluster after the job completes.
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JobConfig

          public JobConfig()

  - ### Method Detail

    - #### getName

          @Nullable
          public String getName()

      Returns the name of the job or `null` if no name was given.

    - #### setName

          @Nonnull
          public JobConfig setName(@Nullable
                                            String name)

      Sets the name of the job. There can be at most one active job in the cluster with particular name, however, the name can be reused after the previous job with that name completed or failed. See `JetInstance.newJobIfAbsent(com.hazelcast.jet.core.DAG, com.hazelcast.jet.config.JobConfig)`. An active job is a job that is running, suspended or waiting to be run.

      The job name is printed in logs and is visible in Jet Management Center.

      The default value is `null`.

      Returns:
        `this` instance for fluent API
      Since:
        3.0

    - #### isSplitBrainProtectionEnabled

          public boolean isSplitBrainProtectionEnabled()

      Tells whether `split brain protection` is enabled.

    - #### setSplitBrainProtection

          @Nonnull
          public JobConfig setSplitBrainProtection(boolean isEnabled)

      Configures the split brain protection feature. When enabled, Jet will restart the job after a topology change only if the cluster quorum is satisfied. The quorum value is

      `cluster size at job submission time / 2 + 1`.

      The job can be restarted only if the size of the cluster after restart is at least the quorum value. Only one of the clusters formed due to a split-brain condition can satisfy the quorum. For example, if at the time of job submission the cluster size was 5 and a network partition causes two clusters with sizes 3 and 2 to form, the job will restart only on the cluster with size 3.

      Adding new nodes to the cluster after starting the job may defeat this mechanism. For instance, if there are 5 members at submission time (i.e., the quorum value is 3) and later a new node joins, a split into two clusters of size 3 will allow the job to be restarted on both sides.

      Split-brain protection is disabled by default.

      If auto scaling is disabled and you manually `Job.resume()` the job, the job won't start executing until the quorum is met, but will remain in the resumed state.

      Returns:
        `this` instance for fluent API

    - #### setAutoScaling

          public JobConfig setAutoScaling(boolean enabled)

      Sets whether Jet will scale the job up or down when a member is added or removed from the cluster. Enabled by default.

           +--------------------------+-----------------------+----------------+
           |       Auto scaling       |     Member added      | Member removed |
           +--------------------------+-----------------------+----------------+
           | Enabled                  | restart (after delay) | restart        |
           | Disabled - snapshots on  | no action             | suspend        |
           | Disabled - snapshots off | no action             | fail           |
           +--------------------------+-----------------------+----------------+

      Returns:
        `this` instance for fluent API
      See Also:
        `Configuring the scale-up delay`, `Enabling/disabling snapshots`

    - #### isAutoScaling

          public boolean isAutoScaling()

      Returns whether auto scaling is enabled, see `setAutoScaling(boolean)`.

    - #### getProcessingGuarantee

          @Nonnull
          public ProcessingGuarantee getProcessingGuarantee()

      Returns the configured `processing guarantee`.

    - #### setProcessingGuarantee

          @Nonnull
          public JobConfig setProcessingGuarantee(@Nonnull
                                                           ProcessingGuarantee processingGuarantee)

      Set the `processing guarantee` for the job. When the processing guarantee is set to at-least-once or exactly-once, the snapshot interval can be configured via `setSnapshotIntervalMillis(long)`, otherwise it will default to 10 seconds.

      The default value is `ProcessingGuarantee.NONE`.

      Returns:
        `this` instance for fluent API

    - #### getSnapshotIntervalMillis

          public long getSnapshotIntervalMillis()

      Returns the configured `snapshot interval`.

    - #### setSnapshotIntervalMillis

          @Nonnull
          public JobConfig setSnapshotIntervalMillis(long snapshotInterval)

      Sets the snapshot interval in milliseconds — the interval between the completion of the previous snapshot and the start of a new one. Must be set to a positive value. This setting is only relevant with at-least-once or exactly-once processing guarantees.

      Default value is set to 10 seconds.

      Returns:
        `this` instance for fluent API

    - #### addClass

          @Nonnull
          public JobConfig addClass(@Nonnull
                                             Class... classes)

      Adds the supplied classes to the list of resources that will be available on the job's classpath while it's executing in the Jet cluster.

      See also `addJar(java.net.URL)` and `addResource(java.net.URL)`.

      Returns:
        `this` instance for fluent API

    - #### addJar

          @Nonnull
          public JobConfig addJar(@Nonnull
                                           URL url)

      Adds the JAR identified by the supplied URL to the list of JARs that will be a part of the job's classpath while it's executing in the Jet cluster.
      Returns:
        `this` instance for fluent API

    - #### addJar

          @Nonnull
          public JobConfig addJar(@Nonnull
                                           File file)

      Adds the supplied JAR file to the list of JARs that will be a part of the job's classpath while it's executing in the Jet cluster. The JAR filename will be used as the ID of the resource.
      Returns:
        `this` instance for fluent API

    - #### addJar

          @Nonnull
          public JobConfig addJar(@Nonnull
                                           String path)

      Adds the JAR identified by the supplied pathname to the list of JARs that will be a part of the job's classpath while it's executing in the Jet cluster. The JAR filename will be used as the ID of the resource.
      Returns:
        `this` instance for fluent API

    - #### addResource

          @Nonnull
          public JobConfig addResource(@Nonnull
                                                URL url)

      Adds the resource identified by the supplied URL to the list of resources that will be on the job's classpath while it's executing in the Jet cluster. The resource's filename will be used as its ID.
      Returns:
        `this` instance for fluent API

    - #### addResource

          @Nonnull
          public JobConfig addResource(@Nonnull
                                                URL url,
                                                @Nonnull
                                                String id)

      Adds the resource identified by the supplied URL to the list of resources that will be on the job's classpath while it's executing in the Jet cluster. The resource will be registered under the supplied ID.
      Returns:
        `this` instance for fluent API

    - #### addResource

          @Nonnull
          public JobConfig addResource(@Nonnull
                                                File file)

      Adds the supplied file to the list of resources that will be on the job's classpath while it's executing in the Jet cluster. The resource's filename will be used as its ID.
      Returns:
        `this` instance for fluent API

    - #### addResource

          @Nonnull
          public JobConfig addResource(@Nonnull
                                                File file,
                                                @Nonnull
                                                String id)

      Adds the supplied file to the list of resources that will be on the job's classpath while it's executing in the Jet cluster. The resource will be registered under the supplied ID.
      Returns:
        `this` instance for fluent API

    - #### addResource

          @Nonnull
          public JobConfig addResource(@Nonnull
                                                String path)

      Adds the resource identified by the supplied pathname to the list of resources that will be on the job's classpath while it's executing in the Jet cluster. The resource's filename will be used as its ID.
      Returns:
        `this` instance for fluent API

    - #### addResource

          @Nonnull
          public JobConfig addResource(@Nonnull
                                                String path,
                                                @Nonnull
                                                String id)

      Adds the resource identified by the supplied pathname to the list of resources that will be on the job's classpath while it's executing in the Jet cluster. The resource will be registered under the supplied ID.
      Returns:
        `this` instance for fluent API

    - #### getResourceConfigs

          @Nonnull
          public List<ResourceConfig> getResourceConfigs()

      Returns all the registered resource configurations.

    - #### setClassLoaderFactory

          @Nonnull
          public JobConfig setClassLoaderFactory(@Nullable
                                                          JobClassLoaderFactory classLoaderFactory)

      Sets a custom `JobClassLoaderFactory` that will be used to load job classes and resources on Jet members.
      Returns:
        `this` instance for fluent API

    - #### getClassLoaderFactory

          @Nullable
          public JobClassLoaderFactory getClassLoaderFactory()

      Returns the configured `JobClassLoaderFactory`.

    - #### getInitialSnapshotName

          @Nullable
          public String getInitialSnapshotName()

      Returns the configured initial snapshot name or `null` if no initial snapshot is configured.

    - #### setInitialSnapshotName

          @Nonnull
          public JobConfig setInitialSnapshotName(@Nullable
                                                           String initialSnapshotName)

      Sets the exported state snapshot name to restore the initial job state from. This state will be used for initial state and also for the case when the execution restarts before it produces first snapshot.

      The job will use the state even if processing guarantee is set to `NONE`.

      Parameters:
        `initialSnapshotName` - the snapshot name given to `Job.exportSnapshot(String)`
      Returns:
        `this` instance for fluent API
      Since:
        3.0

    - #### setMetricsEnabled

          @Nonnull
          public JobConfig setMetricsEnabled(boolean enabled)

      Sets whether metrics collection should be enabled for the job. Needs `MetricsConfig.isEnabled()` to be on in order to function.

      Metrics for running jobs can be queried using `Job.getMetrics()` It's enabled by default.

      Since:
        3.2

    - #### isMetricsEnabled

          public boolean isMetricsEnabled()

      Returns if metrics collection is enabled for the job.
      Since:
        3.2

    - #### isStoreMetricsAfterJobCompletion

          public boolean isStoreMetricsAfterJobCompletion()

      Returns whether metrics should be stored in the cluster after the job completes. Needs both `MetricsConfig.isEnabled()` and `isMetricsEnabled()` to be on in order to function.

      If enabled, metrics can be retrieved by calling `Job.getMetrics()`.

      It's disabled by default.

      Since:
        3.2

    - #### setStoreMetricsAfterJobCompletion

          public JobConfig setStoreMetricsAfterJobCompletion(boolean storeMetricsAfterJobCompletion)

      Sets whether metrics should be stored in the cluster after the job completes. If enabled, metrics can be retrieved for the configured job even if it's no longer running (has completed successfully, has failed, has been cancelled or suspended) by calling `Job.getMetrics()`.

      If disabled, once the configured job stops running `Job.getMetrics()` will always return empty metrics for it, regardless of the settings for `global metrics collection` or `per job metrics collection`.

      It's disabled by default.

      Since:
        3.2

    - #### getFactoryId

          public int getFactoryId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
        `getFactoryId` in interface `IdentifiedDataSerializable`
      Returns:
        factory ID

    - #### getId

          public int getId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
        `getId` in interface `IdentifiedDataSerializable`
      Returns:
        type ID

    - #### writeData

          public void writeData(ObjectDataOutput out)
                         throws IOException

      Description copied from interface: `DataSerializable`
      Writes object fields to output stream
      Specified by:
        `writeData` in interface `DataSerializable`
      Parameters:
        `out` - output
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the output stream has been closed.

    - #### readData

          public void readData(ObjectDataInput in)
                        throws IOException

      Description copied from interface: `DataSerializable`
      Reads fields from the input stream
      Specified by:
        `readData` in interface `DataSerializable`
      Parameters:
        `in` - input
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the input stream has been closed.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2019. All rights reserved.