Service Configuration

Service grid configuration.

❗️

This is a legacy Apache Ignite documentation

The new documentation is hosted here: https://ignite.apache.org/docs/latest/

Configuration

In addition to deploying managed services by calling any of the provided IgniteServices.deploy(...) methods, you can also automatically deploy services on startup by setting serviceConfiguration property of IgniteConfiguration:

<bean class="org.apache.ignite.IgniteConfiguration">
    ...  
    <!-- Distributed Service configuration. -->
    <property name="serviceConfiguration">
        <list>
            <bean class="org.apache.ignite.services.ServiceConfiguration">
                <property name="name" value="MyClusterSingletonSvc"/>
                <property name="maxPerNodeCount" value="1"/>
                <property name="totalCount" value="1"/>
                <property name="service">
                  <ref bean="myServiceImpl"/>
                </property>
            </bean>
        </list>
    </property>
</bean>
 
<bean id="myServiceImpl" class="foo.bar.MyServiceImpl">
  ...
</bean>
ServiceConfiguration svcCfg1 = new ServiceConfiguration();
 
// Cluster-wide singleton configuration.
svcCfg1.setName("MyClusterSingletonSvc");
svcCfg1.setMaxPerNodeCount(1);
svcCfg1.setTotalCount(1);
svcCfg1.setService(new MyClusterSingletonImpl());
 
ServiceConfiguration svcCfg2 = new ServiceConfiguration();
 
// Per-node singleton configuration.
svcCfg2.setName("MyNodeSingletonSvc");
svcCfg2.setMaxPerNodeCount(1);
svcCfg2.setService(new MyNodeSingletonImpl());

IgniteConfiguration igniteCfg = new IgniteConfiguration();
 
igniteCfg.setServiceConfiguration(svcCfg1, svcCfg2);
...

// Start Ignite node.
Ignition.start(gridCfg);

Deploying After Startup

You can configure and deploy services after the startup of Ignite nodes. Besides multiple convenience methods that allow deployment of various cluster singletons, you can also create and deploy service with custom configuration.

ServiceConfiguration cfg = new ServiceConfiguration();
 
cfg.setName("myService");
cfg.setService(new MyService());

// Maximum of 4 service instances within cluster.
cfg.setTotalCount(4);

// Maximum of 2 service instances per each Ignite node.
cfg.setMaxPerNodeCount(2);
 
ignite.services().deploy(cfg);