public class ServiceConfiguration extends Object implements Serializable
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.
Modifier and Type | Field and Description |
---|---|
protected Object |
affKey
Affinity key.
|
protected String |
cacheName
Cache name.
|
protected ServiceCallInterceptor[] |
interceptors
Interceptor.
|
protected boolean |
isStatisticsEnabled
Enables or disables service statistics.
|
protected int |
maxPerNodeCnt
Max per-node count.
|
protected String |
name
Service name.
|
protected IgnitePredicate<ClusterNode> |
nodeFilter
Node filter.
|
protected int |
totalCnt
Total count.
|
Constructor and Description |
---|
ServiceConfiguration() |
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.
|
ServiceCallInterceptor[] |
getInterceptors()
Gets service call interceptors.
|
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() |
boolean |
isStatisticsEnabled()
Tells wheter statistics for this service is enabled.
|
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 |
setInterceptors(ServiceCallInterceptor... interceptors)
Sets service call interceptors.
|
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 |
setStatisticsEnabled(boolean enabled)
Enables or disables statistics for the service.
|
ServiceConfiguration |
setTotalCount(int totalCnt)
Sets total number of deployed service instances in the cluster,
0 for unlimited. |
String |
toString() |
protected String name
protected int totalCnt
protected int maxPerNodeCnt
protected String cacheName
protected Object affKey
@GridToStringExclude protected IgnitePredicate<ClusterNode> nodeFilter
protected boolean isStatisticsEnabled
@GridToStringExclude protected ServiceCallInterceptor[] interceptors
public String getName()
This parameter is mandatory when deploying a service.
public ServiceConfiguration setName(String name)
This parameter is mandatory when deploying a service.
name
- Service name.this
for chaining.public Service getService()
This parameter is mandatory when deploying a service.
public ServiceConfiguration setService(Service svc)
This parameter is mandatory when deploying a service.
svc
- Service instance.this
for chaining.public int getTotalCount()
0
for unlimited.
At least one of getTotalCount()
or getMaxPerNodeCount()
values must be positive.
0
for unlimited.public ServiceConfiguration setTotalCount(int totalCnt)
0
for unlimited.
At least one of getTotalCount()
or getMaxPerNodeCount()
values must be positive.
totalCnt
- Total number of deployed service instances in the cluster, 0
for unlimited.this
for chaining.public int getMaxPerNodeCount()
0
for unlimited.
At least one of getMaxPerNodeCount()
or getTotalCount()
values must be positive.
0
for unlimited.public ServiceConfiguration setMaxPerNodeCount(int maxPerNodeCnt)
0
for unlimited.
At least one of getMaxPerNodeCount()
or getTotalCount()
values must be positive.
maxPerNodeCnt
- Maximum number of deployed service instances on each node, 0
for unlimited.this
for chaining.public String getCacheName()
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.null
.public ServiceConfiguration setCacheName(String cacheName)
This parameter is optional and is set only when deploying service based on key-affinity.
cacheName
- Cache name, possibly null
.this
for chaining.public Object getAffinityKey()
This parameter is optional and is set only when deploying service based on key-affinity.
null
.public ServiceConfiguration setAffinityKey(Object affKey)
This parameter is optional and is set only when deploying service based on key-affinity.
affKey
- Affinity key, possibly null
.this
for chaining.public IgnitePredicate<ClusterNode> getNodeFilter()
This parameter is optional. If not provided service may be deployed on any or all nodes in the grid, based on configuration.
null
.public ServiceConfiguration setNodeFilter(IgnitePredicate<ClusterNode> nodeFilter)
This parameter is optional. If not provided service may be deployed on any or all nodes in the grid, based on configuration.
nodeFilter
- Node filter used to filter nodes on which the service will be deployed, possibly null
.this
for chaining.public ServiceConfiguration setStatisticsEnabled(boolean enabled)
IgniteServiceProcessor.SERVICE_METRIC_REGISTRY
by service name.
NOTE: Statistics are collected only with service proxies obtaining by methods like
IgniteServices.serviceProxy(String, Class, boolean)
and won't work for direct reference of local
services which you can get by, for example, IgniteServices.service(String)
.
NOTE: Statistics are collected only for all service's interfaces except Service
and
Externalizable
if implemented. Statistics are not collected for methods not declared in any interface.
enabled
- If true
, enables service statistics. Disables otherwise.this
for chaining.public boolean isStatisticsEnabled()
True
, if statistics for this service will be enabled. False
otherwise.public ServiceCallInterceptor[] getInterceptors()
public ServiceConfiguration setInterceptors(ServiceCallInterceptor... interceptors)
interceptors
- Service call interceptors.this
for chaining.public boolean equalsIgnoreNodeFilter(Object o)
o
- Other configuration.True
if configurations are equal, false
otherwise.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023