org.apache.ignite.internal.processors.service

## Class IgniteServiceProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.service.IgniteServiceProcessor

All Implemented Interfaces:
  GridComponent, IgniteChangeGlobalStateSupport, GridProcessor

    public class IgniteServiceProcessor
    extends GridProcessorAdapter
    implements IgniteChangeGlobalStateSupport

Ignite service processor.

Event-driven implementation of the service processor. Service deployment is managed via `DiscoverySpi` and `CommunicationSpi` messages.

See Also:
  `ServiceDeploymentManager`, `ServiceDeploymentTask`, `ServiceDeploymentActions`, `ServiceChangeBatchRequest`

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

Fields
`static long[]` `DEFAULT_INVOCATION_BOUNDS` Default bounds of invocation histogram in nanoseconds.
`static String` `SVCS_VIEW`
`static String` `SVCS_VIEW_DESC`

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`IgniteServiceProcessor(GridKernalContext ctx)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`IgniteInternalFuture<?>` `cancel(String name)`
`IgniteInternalFuture<?>` `cancelAll()`
`IgniteInternalFuture<?>` `cancelAll(@NotNull Collection<String> servicesNames)`
`void` `collectGridNodeData(DiscoveryDataBag dataBag)` Collects discovery data on nodes already in grid on receiving `TcpDiscoveryNodeAddedMessage`.
`void` `collectJoiningNodeData(DiscoveryDataBag dataBag)` Collects discovery data on joining node before sending `TcpDiscoveryJoinRequestMessage` request.
`IgniteInternalFuture<?>` `deployAll(ClusterGroup prj, Collection<ServiceConfiguration> cfgs)`
`IgniteInternalFuture<?>` `deployClusterSingleton(ClusterGroup prj, String name, Service srvc)`
`IgniteInternalFuture<?>` `deployKeyAffinitySingleton(String name, Service srvc, String cacheName, Object affKey)`
`ServiceDeploymentManager` `deployment()`
`IgniteInternalFuture<?>` `deployMultiple(ClusterGroup prj, String name, Service srvc, int totalCnt, int maxPerNodeCnt)`
`IgniteInternalFuture<?>` `deployNodeSingleton(ClusterGroup prj, String name, Service srvc)`
`@Nullable GridComponent.DiscoveryDataExchangeType` `discoveryDataType()` Gets unique component type to distinguish components providing discovery data.
`void` `onActivate(GridKernalContext kctx)` Called when cluster performing activation.
`void` `onDeActivate(GridKernalContext kctx)` Invokes from services deployment worker.
`void` `onDisconnected(IgniteFuture<?> reconnectFut)` Client disconnected callback.
`void` `onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)` Receives discovery data object from remote nodes (called on new node during discovery process).
`void` `onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)` Method is called on nodes that are already in grid (not on joining node).
`void` `onKernalStart(boolean active)` Callback that notifies that kernal has successfully started, including all managers and processors.
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`void` `onLocalJoin(DiscoveryEvent evt, DiscoCache discoCache)` Callback for local join events for which the regular events are not generated.
`IgniteInternalFuture<?>` `onReconnected(boolean active)` Client reconnected callback.
`<T> T` `service(String name)`
`ServiceContextImpl` `serviceContext(String name)`
`Collection<ServiceDescriptor>` `serviceDescriptors()`
`static String` `serviceMetricRegistryName(String srvcName)` Gives proper name for service metric registry.
`<T> T` `serviceProxy(ClusterGroup prj, String name, Class<? super T> srvcCls, boolean sticky, @Nullable Supplier<Map<String,Object>> callAttrsProvider, long timeout, boolean keepBinary)`
`<T> Collection<T>` `services(String name)`
`Map<UUID,Integer>` `serviceTopology(String name, long timeout)`
`void` `start()` Starts grid component.
`@Nullable IgniteNodeValidationResult` `validateNode(ClusterNode node, DiscoveryDataBag.JoiningNodeDiscoveryData data)` Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, printMemoryStats, stop, toString, validateNode`

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

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

### Field Detail

#### SVCS_VIEW

    public static final String SVCS_VIEW

See Also:
  Constant Field Values

#### SVCS_VIEW_DESC

    public static final String SVCS_VIEW_DESC

See Also:
  Constant Field Values

#### DEFAULT_INVOCATION_BOUNDS

    public static final long[] DEFAULT_INVOCATION_BOUNDS

Default bounds of invocation histogram in nanoseconds.

### Constructor Detail

#### IgniteServiceProcessor

    public IgniteServiceProcessor(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### onKernalStart

    public void onKernalStart(boolean active)
                       throws IgniteCheckedException

Callback that notifies that kernal has successfully started, including all managers and processors.

Specified by:
  `onKernalStart` in interface `GridComponent`
Overrides:
  `onKernalStart` in class `GridProcessorAdapter`
Parameters:
  `active` - Cluster active flag (note: should be used carefully since state can change concurrently).
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### onKernalStop

    public void onKernalStop(boolean cancel)

Callback to notify that kernal is about to stop.

Specified by:
  `onKernalStop` in interface `GridComponent`
Overrides:
  `onKernalStop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - Flag indicating whether jobs should be canceled.

#### collectGridNodeData

    public void collectGridNodeData(DiscoveryDataBag dataBag)

Collects discovery data on nodes already in grid on receiving `TcpDiscoveryNodeAddedMessage`.

Specified by:
  `collectGridNodeData` in interface `GridComponent`
Overrides:
  `collectGridNodeData` in class `GridProcessorAdapter`
Parameters:
  `dataBag` - container object to store discovery data in.

#### onGridDataReceived

    public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)

Receives discovery data object from remote nodes (called on new node during discovery process).

Specified by:
  `onGridDataReceived` in interface `GridComponent`
Overrides:
  `onGridDataReceived` in class `GridProcessorAdapter`
Parameters:
  `data` - `DiscoveryDataBag.GridDiscoveryData` interface to retrieve discovery data collected on remote nodes (data common for all nodes in grid and specific for each node).

#### collectJoiningNodeData

    public void collectJoiningNodeData(DiscoveryDataBag dataBag)

Collects discovery data on joining node before sending `TcpDiscoveryJoinRequestMessage` request.

Specified by:
  `collectJoiningNodeData` in interface `GridComponent`
Overrides:
  `collectJoiningNodeData` in class `GridProcessorAdapter`
Parameters:
  `dataBag` - container object to store discovery data in.

#### validateNode

    @Nullable
    public @Nullable IgniteNodeValidationResult validateNode(ClusterNode node,
                                                                       DiscoveryDataBag.JoiningNodeDiscoveryData data)

Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

Specified by:
  `validateNode` in interface `GridComponent`
Overrides:
  `validateNode` in class `GridProcessorAdapter`
Parameters:
  `node` - Joining node.
  `data` - Joining node discovery data.
Returns:
  Validation result or `null` in case of success.

#### onJoiningNodeDataReceived

    public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)

Method is called on nodes that are already in grid (not on joining node). It receives discovery data from joining node.

Specified by:
  `onJoiningNodeDataReceived` in interface `GridComponent`
Overrides:
  `onJoiningNodeDataReceived` in class `GridProcessorAdapter`
Parameters:
  `data` - `DiscoveryDataBag.JoiningNodeDiscoveryData` interface to retrieve discovery data of joining node.

#### discoveryDataType

    @Nullable
    public @Nullable GridComponent.DiscoveryDataExchangeType discoveryDataType()

Gets unique component type to distinguish components providing discovery data. Must return non-null value if component implements any of methods `GridComponent.collectJoiningNodeData(DiscoveryDataBag)` or `GridComponent.collectGridNodeData(DiscoveryDataBag)`.

Specified by:
  `discoveryDataType` in interface `GridComponent`
Overrides:
  `discoveryDataType` in class `GridProcessorAdapter`
Returns:
  Unique component type for discovery data exchange.

#### onActivate

    public void onActivate(GridKernalContext kctx)

Called when cluster performing activation.

Specified by:
  `onActivate` in interface `IgniteChangeGlobalStateSupport`
Parameters:
  `kctx` - Kernal context.

#### onDeActivate

    public void onDeActivate(GridKernalContext kctx)

Invokes from services deployment worker.

Called when cluster performing deactivation.

Specified by:
  `onDeActivate` in interface `IgniteChangeGlobalStateSupport`
Parameters:
  `kctx` - Kernal context.

#### onDisconnected

    public void onDisconnected(IgniteFuture<?> reconnectFut)

Client disconnected callback.

Specified by:
  `onDisconnected` in interface `GridComponent`
Overrides:
  `onDisconnected` in class `GridProcessorAdapter`
Parameters:
  `reconnectFut` - Reconnect future.

#### onReconnected

    public IgniteInternalFuture<?> onReconnected(boolean active)
                                          throws IgniteCheckedException

Client reconnected callback.

Specified by:
  `onReconnected` in interface `GridComponent`
Overrides:
  `onReconnected` in class `GridProcessorAdapter`
Parameters:
  `active` - Cluster restarted flag.
Returns:
  Future to wait before completing reconnect future.
Throws:
  `IgniteCheckedException` - If failed.

#### deployNodeSingleton

    public IgniteInternalFuture<?> deployNodeSingleton(ClusterGroup prj,
                                                       String name,
                                                       Service srvc)

Parameters:
  `prj` - Grid projection.
  `name` - Service name.
  `srvc` - Service.
Returns:
  Future.

#### deployClusterSingleton

    public IgniteInternalFuture<?> deployClusterSingleton(ClusterGroup prj,
                                                          String name,
                                                          Service srvc)

Parameters:
  `name` - Service name.
  `srvc` - Service instance.
Returns:
  Future.

#### deployMultiple

    public IgniteInternalFuture<?> deployMultiple(ClusterGroup prj,
                                                  String name,
                                                  Service srvc,
                                                  int totalCnt,
                                                  int maxPerNodeCnt)

Parameters:
  `name` - Service name.
  `srvc` - Service.
  `totalCnt` - Total count.
  `maxPerNodeCnt` - Max per-node count.
Returns:
  Future.

#### deployKeyAffinitySingleton

    public IgniteInternalFuture<?> deployKeyAffinitySingleton(String name,
                                                              Service srvc,
                                                              String cacheName,
                                                              Object affKey)

Parameters:
  `name` - Service name.
  `srvc` - Service.
  `cacheName` - Cache name.
  `affKey` - Affinity key.
Returns:
  Future.

#### deployAll

    public IgniteInternalFuture<?> deployAll(ClusterGroup prj,
                                             Collection<ServiceConfiguration> cfgs)

Parameters:
  `prj` - Grid projection.
  `cfgs` - Service configurations.
Returns:
  Future for deployment.

#### cancel

    public IgniteInternalFuture<?> cancel(String name)

Parameters:
  `name` - Service name.
Returns:
  Future.

#### cancelAll

    public IgniteInternalFuture<?> cancelAll()

Returns:
  Future.

#### cancelAll

    public IgniteInternalFuture<?> cancelAll(@NotNull
                                             @NotNull Collection<String> servicesNames)

Parameters:
  `servicesNames` - Name of services to deploy.
Returns:
  Future.

#### serviceTopology

    public Map<UUID,Integer> serviceTopology(String name,
                                             long timeout)
                                      throws IgniteCheckedException

Parameters:
  `name` - Service name.
  `timeout` - If greater than 0 limits task execution time. Cannot be negative.
Returns:
  Service topology.
Throws:
  `IgniteCheckedException` - On error.

#### serviceDescriptors

    public Collection<ServiceDescriptor> serviceDescriptors()

Returns:
  Collection of service descriptors.

#### service

    public <T> T service(String name)

Type Parameters:
  `T` - Service type.
Parameters:
  `name` - Service name.
Returns:
  Service by specified service name.

#### serviceContext

    public ServiceContextImpl serviceContext(String name)

Parameters:
  `name` - Service name.
Returns:
  Service by specified service name.

#### serviceProxy

    public <T> T serviceProxy(ClusterGroup prj,
                              String name,
                              Class<? super T> srvcCls,
                              boolean sticky,
                              @Nullable
                              @Nullable Supplier<Map<String,Object>> callAttrsProvider,
                              long timeout,
                              boolean keepBinary)
                       throws IgniteException

Type Parameters:
  `T` - Service interface type.
Parameters:
  `prj` - Grid projection.
  `name` - Service name.
  `srvcCls` - Service class.
  `sticky` - Whether multi-node request should be done.
  `callAttrsProvider` - Service call context attributes provider.
  `timeout` - If greater than 0 limits service acquire time. Cannot be negative.
Returns:
  The proxy of a service by its name and class.
Throws:
  `IgniteException` - If failed to create proxy.

#### services

    public <T> Collection<T> services(String name)

Type Parameters:
  `T` - Service type.
Parameters:
  `name` - Service name.
Returns:
  Services by specified service name.

#### onLocalJoin

    public void onLocalJoin(DiscoveryEvent evt,
                            DiscoCache discoCache)

Callback for local join events for which the regular events are not generated.

Local join event is expected in cases of joining to topology or client reconnect.

Parameters:
  `evt` - Discovery event.
  `discoCache` - Discovery cache.

#### deployment

    public ServiceDeploymentManager deployment()

Returns:
  Services deployment manager.

#### serviceMetricRegistryName

    public static String serviceMetricRegistryName(String srvcName)

Gives proper name for service metric registry.

Parameters:
  `srvcName` - Name of the service.
Returns:
  registry name for service `srvcName`.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022