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 provideddeploy(...)methods, managed services can also be automatically deployed on startup by specifying them inIgniteConfigurationlike 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 SummaryFields Modifier and Type Field Description protected ObjectaffKeyAffinity key.protected StringcacheNameCache name.protected ServiceCallInterceptor[]interceptorsInterceptor.protected booleanisStatisticsEnabledEnables or disables service statistics.protected intmaxPerNodeCntMax per-node count.protected StringnameService name.protected IgnitePredicate<ClusterNode>nodeFilterNode filter.protected inttotalCntTotal count.
 - 
Constructor SummaryConstructors Constructor Description ServiceConfiguration()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)booleanequalsIgnoreNodeFilter(Object o)Checks if configurations are equal ignoring the node filter.ObjectgetAffinityKey()Gets affinity key used for key-to-node affinity calculation.StringgetCacheName()Gets cache name used for key-to-node affinity calculation.ServiceCallInterceptor[]getInterceptors()Gets service call interceptors.intgetMaxPerNodeCount()Gets maximum number of deployed service instances on each node,0for unlimited.StringgetName()Gets service name.IgnitePredicate<ClusterNode>getNodeFilter()Gets node filter used to filter nodes on which the service will be deployed.ServicegetService()Gets service instance.intgetTotalCount()Gets total number of deployed service instances in the cluster,0for unlimited.inthashCode()booleanisStatisticsEnabled()Tells wheter statistics for this service is enabled.ServiceConfigurationsetAffinityKey(Object affKey)Sets affinity key used for key-to-node affinity calculation.ServiceConfigurationsetCacheName(String cacheName)Sets cache name used for key-to-node affinity calculation.ServiceConfigurationsetInterceptors(ServiceCallInterceptor... interceptors)Sets service call interceptors.ServiceConfigurationsetMaxPerNodeCount(int maxPerNodeCnt)Sets maximum number of deployed service instances on each node,0for unlimited.ServiceConfigurationsetName(String name)Sets service name.ServiceConfigurationsetNodeFilter(IgnitePredicate<ClusterNode> nodeFilter)Sets node filter used to filter nodes on which the service will be deployed.ServiceConfigurationsetService(Service svc)Sets service instance.ServiceConfigurationsetStatisticsEnabled(boolean enabled)Enables or disables statistics for the service.ServiceConfigurationsetTotalCount(int totalCnt)Sets total number of deployed service instances in the cluster,0for unlimited.StringtoString()
 
- 
- 
- 
Field Detail- 
nameprotected String name Service name.
 - 
totalCntprotected int totalCnt Total count.
 - 
maxPerNodeCntprotected int maxPerNodeCnt Max per-node count.
 - 
cacheNameprotected String cacheName Cache name.
 - 
affKeyprotected Object affKey Affinity key.
 - 
nodeFilter@GridToStringExclude protected IgnitePredicate<ClusterNode> nodeFilter Node filter.
 - 
isStatisticsEnabledprotected boolean isStatisticsEnabled Enables or disables service statistics.
 - 
interceptors@GridToStringExclude protected ServiceCallInterceptor[] interceptors Interceptor.
 
- 
 - 
Method Detail- 
getNamepublic String getName() Gets service name.This parameter is mandatory when deploying a service. - Returns:
- Service name.
 
 - 
setNamepublic ServiceConfiguration setName(String name) Sets service name.This parameter is mandatory when deploying a service. - Parameters:
- name- Service name.
- Returns:
- thisfor chaining.
 
 - 
getServicepublic Service getService() Gets service instance.This parameter is mandatory when deploying a service. - Returns:
- Service instance.
 
 - 
setServicepublic ServiceConfiguration setService(Service svc) Sets service instance.This parameter is mandatory when deploying a service. - Parameters:
- svc- Service instance.
- Returns:
- thisfor chaining.
 
 - 
getTotalCountpublic int getTotalCount() Gets total number of deployed service instances in the cluster,0for unlimited.At least one of getTotalCount()orgetMaxPerNodeCount()values must be positive.- Returns:
- Total number of deployed service instances in the cluster, 0for unlimited.
 
 - 
setTotalCountpublic ServiceConfiguration setTotalCount(int totalCnt) Sets total number of deployed service instances in the cluster,0for unlimited.At least one of getTotalCount()orgetMaxPerNodeCount()values must be positive.- Parameters:
- totalCnt- Total number of deployed service instances in the cluster,- 0for unlimited.
- Returns:
- thisfor chaining.
 
 - 
getMaxPerNodeCountpublic int getMaxPerNodeCount() Gets maximum number of deployed service instances on each node,0for unlimited.At least one of getMaxPerNodeCount()orgetTotalCount()values must be positive.- Returns:
- Maximum number of deployed service instances on each node, 0for unlimited.
 
 - 
setMaxPerNodeCountpublic ServiceConfiguration setMaxPerNodeCount(int maxPerNodeCnt) Sets maximum number of deployed service instances on each node,0for unlimited.At least one of getMaxPerNodeCount()orgetTotalCount()values must be positive.- Parameters:
- maxPerNodeCnt- Maximum number of deployed service instances on each node,- 0for unlimited.
- Returns:
- thisfor chaining.
 
 - 
getCacheNamepublic 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.
 
 - 
setCacheNamepublic 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:
- thisfor chaining.
 
 - 
getAffinityKeypublic 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.
 
 - 
setAffinityKeypublic 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:
- thisfor chaining.
 
 - 
getNodeFilterpublic 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.
 
 - 
setNodeFilterpublic 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:
- thisfor chaining.
 
 - 
setStatisticsEnabledpublic ServiceConfiguration setStatisticsEnabled(boolean enabled) Enables or disables statistics for the service. If enabled, durations of the service's methods invocations are measured (in milliseconds) and stored in histograms of metric registryIgniteServiceProcessor.SERVICE_METRIC_REGISTRYby 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 ServiceandExternalizableif implemented. Statistics are not collected for methods not declared in any interface.- Parameters:
- enabled- If- true, enables service statistics. Disables otherwise.
- Returns:
- thisfor chaining.
 
 - 
isStatisticsEnabledpublic boolean isStatisticsEnabled() Tells wheter statistics for this service is enabled.- Returns:
- True, if statistics for this service will be enabled.- Falseotherwise.
 
 - 
getInterceptorspublic ServiceCallInterceptor[] getInterceptors() Gets service call interceptors.- Returns:
- Service call interceptors.
 
 - 
setInterceptorspublic ServiceConfiguration setInterceptors(ServiceCallInterceptor... interceptors) Sets service call interceptors.- Parameters:
- interceptors- Service call interceptors.
- Returns:
- thisfor chaining.
 
 - 
equalsIgnoreNodeFilterpublic 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:
- Trueif configurations are equal,- falseotherwise.
 
 
- 
 
-