org.apache.ignite.services

## Class ServiceConfiguration

- java.lang.Object
- - org.apache.ignite.services.ServiceConfiguration

- All Implemented Interfaces:
    Serializable

      public class ServiceConfiguration
      extends Object
      implements Serializable

  Managed service configuration. In addition to deploying managed services by calling any of the provided `deploy(...)` methods, managed services can also be automatically deployed on startup by specifying them in `IgniteConfiguration` like so:

       IgniteConfiguration gridCfg = new IgniteConfiguration();

       GridServiceConfiguration svcCfg1 = new GridServiceConfiguration();

       svcCfg1.setName("myClusterSingletonService");
       svcCfg1.setMaxPerNodeCount(1);
       svcCfg1.setTotalCount(1);
       svcCfg1.setService(new MyClusterSingletonService());

       GridServiceConfiguration svcCfg2 = new GridServiceConfiguration();

       svcCfg2.setName("myNodeSingletonService");
       svcCfg2.setMaxPerNodeCount(1);
       svcCfg2.setService(new MyNodeSingletonService());

       gridCfg.setServiceConfiguration(svcCfg1, svcCfg2);
       ...
       Ignition.start(gridCfg);

  The above configuration can also be specified in a Spring configuration file.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Object` | `affKey` Affinity key.
    `protected String` | `cacheName` Cache name.
    `protected int` | `maxPerNodeCnt` Max per-node count.
    `protected String` | `name` Service name.
    `protected IgnitePredicate<ClusterNode>` | `nodeFilter` Node filter.
    `protected int` | `totalCnt` Total count.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceConfiguration()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `boolean` | `equalsIgnoreNodeFilter(Object o)` Checks if configurations are equal ignoring the node filter.
    `Object` | `getAffinityKey()` Gets affinity key used for key-to-node affinity calculation.
    `String` | `getCacheName()` Gets cache name used for key-to-node affinity calculation.
    `int` | `getMaxPerNodeCount()` Gets maximum number of deployed service instances on each node, `0` for unlimited.
    `String` | `getName()` Gets service name.
    `IgnitePredicate<ClusterNode>` | `getNodeFilter()` Gets node filter used to filter nodes on which the service will be deployed.
    `Service` | `getService()` Gets service instance.
    `int` | `getTotalCount()` Gets total number of deployed service instances in the cluster, `0` for unlimited.
    `int` | `hashCode()`
    `ServiceConfiguration` | `setAffinityKey(Object affKey)` Sets affinity key used for key-to-node affinity calculation.
    `ServiceConfiguration` | `setCacheName(String cacheName)` Sets cache name used for key-to-node affinity calculation.
    `ServiceConfiguration` | `setMaxPerNodeCount(int maxPerNodeCnt)` Sets maximum number of deployed service instances on each node, `0` for unlimited.
    `ServiceConfiguration` | `setName(String name)` Sets service name.
    `ServiceConfiguration` | `setNodeFilter(IgnitePredicate<ClusterNode> nodeFilter)` Sets node filter used to filter nodes on which the service will be deployed.
    `ServiceConfiguration` | `setService(Service svc)` Sets service instance.
    `ServiceConfiguration` | `setTotalCount(int totalCnt)` Sets total number of deployed service instances in the cluster, `0` for unlimited.
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### name

          protected String name

      Service name.

    - #### totalCnt

          protected int totalCnt

      Total count.

    - #### maxPerNodeCnt

          protected int maxPerNodeCnt

      Max per-node count.

    - #### cacheName

          protected String cacheName

      Cache name.

    - #### affKey

          protected Object affKey

      Affinity key.

    - #### nodeFilter

          @GridToStringExclude
          protected IgnitePredicate<ClusterNode> nodeFilter

      Node filter.

  - ### Constructor Detail

    - #### ServiceConfiguration

          public ServiceConfiguration()

  - ### Method Detail

    - #### getName

          public String getName()

      Gets service name.

      This parameter is mandatory when deploying a service.

      Returns:
        Service name.

    - #### setName

          public ServiceConfiguration setName(String name)

      Sets service name.

      This parameter is mandatory when deploying a service.

      Parameters:
        `name` - Service name.
      Returns:
        `this` for chaining.

    - #### getService

          public Service getService()

      Gets service instance.

      This parameter is mandatory when deploying a service.

      Returns:
        Service instance.

    - #### setService

          public ServiceConfiguration setService(Service svc)

      Sets service instance.

      This parameter is mandatory when deploying a service.

      Parameters:
        `svc` - Service instance.
      Returns:
        `this` for chaining.

    - #### getTotalCount

          public int getTotalCount()

      Gets total number of deployed service instances in the cluster, `0` for unlimited.

      At least one of `getTotalCount()` or `getMaxPerNodeCount()` values must be positive.

      Returns:
        Total number of deployed service instances in the cluster, `0` for unlimited.

    - #### setTotalCount

          public ServiceConfiguration setTotalCount(int totalCnt)

      Sets total number of deployed service instances in the cluster, `0` for unlimited.

      At least one of `getTotalCount()` or `getMaxPerNodeCount()` values must be positive.

      Parameters:
        `totalCnt` - Total number of deployed service instances in the cluster, `0` for unlimited.
      Returns:
        `this` for chaining.

    - #### getMaxPerNodeCount

          public int getMaxPerNodeCount()

      Gets maximum number of deployed service instances on each node, `0` for unlimited.

      At least one of `getMaxPerNodeCount()` or `getTotalCount()` values must be positive.

      Returns:
        Maximum number of deployed service instances on each node, `0` for unlimited.

    - #### setMaxPerNodeCount

          public ServiceConfiguration setMaxPerNodeCount(int maxPerNodeCnt)

      Sets maximum number of deployed service instances on each node, `0` for unlimited.

      At least one of `getMaxPerNodeCount()` or `getTotalCount()` values must be positive.

      Parameters:
        `maxPerNodeCnt` - Maximum number of deployed service instances on each node, `0` for unlimited.
      Returns:
        `this` for chaining.

    - #### getCacheName

          public String getCacheName()

      Gets cache name used for key-to-node affinity calculation.

      This parameter is optional and is set only when deploying service based on key-affinity.

      NOTE: If the cache is destroyed, the service will be undeployed automatically.
      Returns:
        Cache name, possibly `null`.

    - #### setCacheName

          public ServiceConfiguration setCacheName(String cacheName)

      Sets cache name used for key-to-node affinity calculation.

      This parameter is optional and is set only when deploying service based on key-affinity.

      Parameters:
        `cacheName` - Cache name, possibly `null`.
      Returns:
        `this` for chaining.

    - #### getAffinityKey

          public Object getAffinityKey()

      Gets affinity key used for key-to-node affinity calculation.

      This parameter is optional and is set only when deploying service based on key-affinity.

      Returns:
        Affinity key, possibly `null`.

    - #### setAffinityKey

          public ServiceConfiguration setAffinityKey(Object affKey)

      Sets affinity key used for key-to-node affinity calculation.

      This parameter is optional and is set only when deploying service based on key-affinity.

      Parameters:
        `affKey` - Affinity key, possibly `null`.
      Returns:
        `this` for chaining.

    - #### getNodeFilter

          public IgnitePredicate<ClusterNode> getNodeFilter()

      Gets node filter used to filter nodes on which the service will be deployed.

      This parameter is optional. If not provided service may be deployed on any or all nodes in the grid, based on configuration.

      Returns:
        Node filter used to filter nodes on which the service will be deployed, possibly `null`.

    - #### setNodeFilter

          public ServiceConfiguration setNodeFilter(IgnitePredicate<ClusterNode> nodeFilter)

      Sets node filter used to filter nodes on which the service will be deployed.

      This parameter is optional. If not provided service may be deployed on any or all nodes in the grid, based on configuration.

      Parameters:
        `nodeFilter` - Node filter used to filter nodes on which the service will be deployed, possibly `null`.
      Returns:
        `this` for chaining.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### equalsIgnoreNodeFilter

          public boolean equalsIgnoreNodeFilter(Object o)

      Checks if configurations are equal ignoring the node filter. Node filters control on which nodes the services are deployed and often can be ignored for equality checks.
      Parameters:
        `o` - Other configuration.
      Returns:
        `True` if configurations are equal, `false` otherwise.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021