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 viaDiscoverySpiandCommunicationSpimessages.- 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 Modifier and Type Field Description static long[]DEFAULT_INVOCATION_BOUNDSDefault bounds of invocation histogram in nanoseconds.static StringSVCS_VIEWstatic StringSVCS_VIEW_DESC-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description IgniteServiceProcessor(GridKernalContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IgniteInternalFuture<?>cancel(String name)IgniteInternalFuture<?>cancelAll()IgniteInternalFuture<?>cancelAll(@NotNull Collection<String> servicesNames)voidcollectGridNodeData(DiscoveryDataBag dataBag)Collects discovery data on nodes already in grid on receivingTcpDiscoveryNodeAddedMessage.voidcollectJoiningNodeData(DiscoveryDataBag dataBag)Collects discovery data on joining node before sendingTcpDiscoveryJoinRequestMessagerequest.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)ServiceDeploymentManagerdeployment()IgniteInternalFuture<?>deployMultiple(ClusterGroup prj, String name, Service srvc, int totalCnt, int maxPerNodeCnt)IgniteInternalFuture<?>deployNodeSingleton(ClusterGroup prj, String name, Service srvc)@Nullable GridComponent.DiscoveryDataExchangeTypediscoveryDataType()Gets unique component type to distinguish components providing discovery data.voidonActivate(GridKernalContext kctx)Called when cluster performing activation.voidonDeActivate(GridKernalContext kctx)Invokes from services deployment worker.voidonDisconnected(IgniteFuture<?> reconnectFut)Client disconnected callback.voidonGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)Receives discovery data object from remote nodes (called on new node during discovery process).voidonJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)Method is called on nodes that are already in grid (not on joining node).voidonKernalStart(boolean active)Callback that notifies that kernal has successfully started, including all managers and processors.voidonKernalStop(boolean cancel)Callback to notify that kernal is about to stop.voidonLocalJoin(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> Tservice(String name)ServiceContextImplserviceContext(String name)Collection<ServiceDescriptor>serviceDescriptors()static StringserviceMetricRegistryName(String srvcName)Gives proper name for service metric registry.<T> TserviceProxy(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)@Nullable Map<UUID,Integer>serviceTopology(String name, long timeout)voidstart()Starts grid component.@Nullable IgniteNodeValidationResultvalidateNode(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
-
-
-
-
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 IgniteCheckedExceptionStarts grid component.- Specified by:
startin interfaceGridComponent- Overrides:
startin classGridProcessorAdapter- Throws:
IgniteCheckedException- Throws in case of any errors.
-
onKernalStart
public void onKernalStart(boolean active) throws IgniteCheckedExceptionCallback that notifies that kernal has successfully started, including all managers and processors.- Specified by:
onKernalStartin interfaceGridComponent- Overrides:
onKernalStartin classGridProcessorAdapter- 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:
onKernalStopin interfaceGridComponent- Overrides:
onKernalStopin classGridProcessorAdapter- Parameters:
cancel- Flag indicating whether jobs should be canceled.
-
collectGridNodeData
public void collectGridNodeData(DiscoveryDataBag dataBag)
Collects discovery data on nodes already in grid on receivingTcpDiscoveryNodeAddedMessage.- Specified by:
collectGridNodeDatain interfaceGridComponent- Overrides:
collectGridNodeDatain classGridProcessorAdapter- 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:
onGridDataReceivedin interfaceGridComponent- Overrides:
onGridDataReceivedin classGridProcessorAdapter- Parameters:
data-DiscoveryDataBag.GridDiscoveryDatainterface 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 sendingTcpDiscoveryJoinRequestMessagerequest.- Specified by:
collectJoiningNodeDatain interfaceGridComponent- Overrides:
collectJoiningNodeDatain classGridProcessorAdapter- 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:
validateNodein interfaceGridComponent- Overrides:
validateNodein classGridProcessorAdapter- Parameters:
node- Joining node.data- Joining node discovery data.- Returns:
- Validation result or
nullin 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:
onJoiningNodeDataReceivedin interfaceGridComponent- Overrides:
onJoiningNodeDataReceivedin classGridProcessorAdapter- Parameters:
data-DiscoveryDataBag.JoiningNodeDiscoveryDatainterface 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 methodsGridComponent.collectJoiningNodeData(DiscoveryDataBag)orGridComponent.collectGridNodeData(DiscoveryDataBag).- Specified by:
discoveryDataTypein interfaceGridComponent- Overrides:
discoveryDataTypein classGridProcessorAdapter- Returns:
- Unique component type for discovery data exchange.
-
onActivate
public void onActivate(GridKernalContext kctx)
Called when cluster performing activation.- Specified by:
onActivatein interfaceIgniteChangeGlobalStateSupport- Parameters:
kctx- Kernal context.
-
onDeActivate
public void onDeActivate(GridKernalContext kctx)
Invokes from services deployment worker. Called when cluster performing deactivation.- Specified by:
onDeActivatein interfaceIgniteChangeGlobalStateSupport- Parameters:
kctx- Kernal context.
-
onDisconnected
public void onDisconnected(IgniteFuture<?> reconnectFut)
Client disconnected callback.- Specified by:
onDisconnectedin interfaceGridComponent- Overrides:
onDisconnectedin classGridProcessorAdapter- Parameters:
reconnectFut- Reconnect future.
-
onReconnected
public IgniteInternalFuture<?> onReconnected(boolean active) throws IgniteCheckedException
Client reconnected callback.- Specified by:
onReconnectedin interfaceGridComponent- Overrides:
onReconnectedin classGridProcessorAdapter- 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
@Nullable public @Nullable 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.
-
-