blob: 03005cd2e30f37282955ebae6e593e9ff8a8f74e [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX">
<link rel="canonical" href="https://ignite.apache.org/releases/1.7.0/javadoc/org/apache/ignite/IgniteServices.html" />
<!-- Generated by javadoc (version 1.7.0_80) on Mon Aug 01 20:32:31 MSK 2016 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>IgniteServices (Ignite 1.7.0)</title>
<meta name="date" content="2016-08-01">
<link rel="stylesheet" type="text/css" href="../../../javadoc.css" title="Style">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-61232409-1', 'auto');
ga('send', 'pageview');
</script></head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="IgniteServices (Ignite 1.7.0)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/IgniteServices.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em>Ignite - In-Memory Data Fabric</em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../org/apache/ignite/IgniteSemaphore.html" title="interface in org.apache.ignite"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../org/apache/ignite/IgniteSet.html" title="interface in org.apache.ignite"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/apache/ignite/IgniteServices.html" target="_top">Frames</a></li>
<li><a href="IgniteServices.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.ignite</div>
<h2 title="Interface IgniteServices" class="title">Interface IgniteServices</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Superinterfaces:</dt>
<dd><a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html" title="interface in org.apache.ignite.lang">IgniteAsyncSupport</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="strong">IgniteServices</span>
extends <a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html" title="interface in org.apache.ignite.lang">IgniteAsyncSupport</a></pre>
<div class="block">Defines functionality necessary to deploy distributed services on the grid.
<p>
Instance of <code>IgniteServices</code> which spans all cluster nodes can be obtained from Ignite as follows:
<pre class="brush:java">
Ignite ignite = Ignition.ignite();
IgniteServices svcs = ignite.services();
</pre>
You can also obtain an instance of the services facade over a specific cluster group:
<pre class="brush:java">
// Cluster group over remote nodes (excluding the local node).
ClusterGroup remoteNodes = ignite.cluster().forRemotes();
// Services instance spanning all remote cluster nodes.
IgniteServices svcs = ignite.services(remoteNodes);
</pre>
<p>
With distributed services you can do the following:
<ul>
<li>Automatically deploy any number of service instances on the grid.</li>
<li>
Automatically deploy singletons, including <b>cluster-singleton</b>,
<b>node-singleton</b>, or <b>key-affinity-singleton</b>.
</li>
<li>Automatically deploy services on node start-up by specifying them in grid configuration.</li>
<li>Undeploy any of the deployed services.</li>
<li>Get information about service deployment topology within the grid.</li>
</ul>
<h1 class="header">Deployment From Configuration</h1>
In addition to deploying managed services by calling any of the provided <code>deploy(...)</code> methods,
you can also automatically deploy services on startup by specifying them in <a href="../../../org/apache/ignite/configuration/IgniteConfiguration.html" title="class in org.apache.ignite.configuration"><code>IgniteConfiguration</code></a>
like so:
<pre name="code" class="java">
IgniteConfiguration gridCfg = new IgniteConfiguration();
GridServiceConfiguration svcCfg1 = new GridServiceConfiguration();
// Cluster-wide singleton configuration.
svcCfg1.setName("myClusterSingletonService");
svcCfg1.setMaxPerNodeCount(1);
svcCfg1.setTotalCount(1);
svcCfg1.setService(new MyClusterSingletonService());
GridServiceConfiguration svcCfg2 = new GridServiceConfiguration();
// Per-node singleton configuration.
svcCfg2.setName("myNodeSingletonService");
svcCfg2.setMaxPerNodeCount(1);
svcCfg2.setService(new MyNodeSingletonService());
gridCfg.setServiceConfiguration(svcCfg1, svcCfg2);
...
Ignition.start(gridCfg);
</pre>
<h1 class="header">Load Balancing</h1>
In all cases, other than singleton service deployment, Ignite will automatically make sure that
an about equal number of services are deployed on each node within the grid. Whenever cluster topology
changes, Ignite will re-evaluate service deployments and may re-deploy an already deployed service
on another node for better load balancing.
<h1 class="header">Fault Tolerance</h1>
Ignite guarantees that services are deployed according to specified configuration regardless
of any topology changes, including node crashes.
<h1 class="header">Resource Injection</h1>
All distributed services can be injected with
ignite resources. Both, field and method based injections are supported. The following ignite
resources can be injected:
<ul>
<li><a href="../../../org/apache/ignite/resources/IgniteInstanceResource.html" title="annotation in org.apache.ignite.resources"><code>IgniteInstanceResource</code></a></li>
<li><a href="../../../org/apache/ignite/resources/LoggerResource.html" title="annotation in org.apache.ignite.resources"><code>LoggerResource</code></a></li>
<li><a href="../../../org/apache/ignite/resources/SpringApplicationContextResource.html" title="annotation in org.apache.ignite.resources"><code>SpringApplicationContextResource</code></a></li>
<li><a href="../../../org/apache/ignite/resources/SpringResource.html" title="annotation in org.apache.ignite.resources"><code>SpringResource</code></a></li>
</ul>
Refer to corresponding resource documentation for more information.
<h1 class="header">Service Example</h1>
Here is an example of how an distributed service may be implemented and deployed:
<pre name="code" class="java">
// Simple service implementation.
public class MyGridService implements GridService {
...
// Example of ignite resource injection. All resources are optional.
// You should inject resources only as needed.
&#64;IgniteInstanceResource
private Grid grid;
...
&#64;Override public void cancel(GridServiceContext ctx) {
// No-op.
}
&#64;Override public void execute(GridServiceContext ctx) {
// Loop until service is cancelled.
while (!ctx.isCancelled()) {
// Do something.
...
}
}
}
...
GridServices svcs = grid.services();
svcs.deployClusterSingleton("mySingleton", new MyGridService());
</pre></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#cancel(java.lang.String)">cancel</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</code>
<div class="block">Cancels service deployment.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#cancelAll()">cancelAll</a></strong>()</code>
<div class="block">Cancels all deployed services.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../org/apache/ignite/cluster/ClusterGroup.html" title="interface in org.apache.ignite.cluster">ClusterGroup</a></code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#clusterGroup()">clusterGroup</a></strong>()</code>
<div class="block">Gets the cluster group to which this <code>GridServices</code> instance belongs.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#deploy(org.apache.ignite.services.ServiceConfiguration)">deploy</a></strong>(<a href="../../../org/apache/ignite/services/ServiceConfiguration.html" title="class in org.apache.ignite.services">ServiceConfiguration</a>&nbsp;cfg)</code>
<div class="block">Deploys multiple instances of the service on the grid according to provided
configuration.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#deployClusterSingleton(java.lang.String,%20org.apache.ignite.services.Service)">deployClusterSingleton</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc)</code>
<div class="block">Deploys a cluster-wide singleton service.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#deployKeyAffinitySingleton(java.lang.String,%20org.apache.ignite.services.Service,%20java.lang.String,%20java.lang.Object)">deployKeyAffinitySingleton</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;cacheName,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;affKey)</code>
<div class="block">Deploys one instance of this service on the primary node for a given affinity key.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#deployMultiple(java.lang.String,%20org.apache.ignite.services.Service,%20int,%20int)">deployMultiple</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc,
int&nbsp;totalCnt,
int&nbsp;maxPerNodeCnt)</code>
<div class="block">Deploys multiple instances of the service on the grid.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#deployNodeSingleton(java.lang.String,%20org.apache.ignite.services.Service)">deployNodeSingleton</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc)</code>
<div class="block">Deploys a per-node singleton service.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>&lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#service(java.lang.String)">service</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</code>
<div class="block">Gets deployed service with specified name.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../org/apache/ignite/services/ServiceDescriptor.html" title="interface in org.apache.ignite.services">ServiceDescriptor</a>&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#serviceDescriptors()">serviceDescriptors</a></strong>()</code>
<div class="block">Gets metadata about all deployed services.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>&lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#serviceProxy(java.lang.String,%20java.lang.Class,%20boolean)">serviceProxy</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;? super T&gt;&nbsp;svcItf,
boolean&nbsp;sticky)</code>
<div class="block">Gets a remote handle on the service.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>&lt;T&gt;&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;T&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#services(java.lang.String)">services</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</code>
<div class="block">Gets all deployed services with specified name.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../org/apache/ignite/IgniteServices.html" title="interface in org.apache.ignite">IgniteServices</a></code></td>
<td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteServices.html#withAsync()">withAsync</a></strong>()</code>
<div class="block">Gets instance of this component with asynchronous mode enabled.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_org.apache.ignite.lang.IgniteAsyncSupport">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;org.apache.ignite.lang.<a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html" title="interface in org.apache.ignite.lang">IgniteAsyncSupport</a></h3>
<code><a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html#future()">future</a>, <a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html#isAsync()">isAsync</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="clusterGroup()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clusterGroup</h4>
<pre><a href="../../../org/apache/ignite/cluster/ClusterGroup.html" title="interface in org.apache.ignite.cluster">ClusterGroup</a>&nbsp;clusterGroup()</pre>
<div class="block">Gets the cluster group to which this <code>GridServices</code> instance belongs.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>Cluster group to which this <code>GridServices</code> instance belongs.</dd></dl>
</li>
</ul>
<a name="deployClusterSingleton(java.lang.String, org.apache.ignite.services.Service)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>deployClusterSingleton</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;deployClusterSingleton(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Deploys a cluster-wide singleton service. Ignite will guarantee that there is always
one instance of the service in the cluster. In case if grid node on which the service
was deployed crashes or stops, Ignite will automatically redeploy it on another node.
However, if the node on which the service is deployed remains in topology, then the
service will always be deployed on that node only, regardless of topology changes.
<p>
Note that in case of topology changes, due to network delays, there may be a temporary situation
when a singleton service instance will be active on more than one node (e.g. crash detection delay).
<p>
This method is analogous to calling
<a href="../../../org/apache/ignite/IgniteServices.html#deployMultiple(java.lang.String,%20org.apache.ignite.services.Service,%20int,%20int)"><code>deployMultiple(name, svc, 1, 1)</code></a> method.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd><dd><code>svc</code> - Service instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to deploy service.</dd></dl>
</li>
</ul>
<a name="deployNodeSingleton(java.lang.String, org.apache.ignite.services.Service)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>deployNodeSingleton</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;deployNodeSingleton(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Deploys a per-node singleton service. Ignite will guarantee that there is always
one instance of the service running on each node. Whenever new nodes are started
within the underlying cluster group, Ignite will automatically deploy one instance of
the service on every new node.
<p>
This method is analogous to calling
<a href="../../../org/apache/ignite/IgniteServices.html#deployMultiple(java.lang.String,%20org.apache.ignite.services.Service,%20int,%20int)"><code>deployMultiple(name, svc, 0, 1)</code></a> method.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd><dd><code>svc</code> - Service instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to deploy service.</dd></dl>
</li>
</ul>
<a name="deployKeyAffinitySingleton(java.lang.String, org.apache.ignite.services.Service, java.lang.String, java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>deployKeyAffinitySingleton</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;deployKeyAffinitySingleton(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc,
@Nullable
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;cacheName,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;affKey)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Deploys one instance of this service on the primary node for a given affinity key.
Whenever topology changes and primary node assignment changes, Ignite will always
make sure that the service is undeployed on the previous primary node and deployed
on the new primary node.
<p>
Note that in case of topology changes, due to network delays, there may be a temporary situation
when a service instance will be active on more than one node (e.g. crash detection delay).
<p>
This method is analogous to the invocation of <a href="../../../org/apache/ignite/IgniteServices.html#deploy(org.apache.ignite.services.ServiceConfiguration)"><code>deploy(org.apache.ignite.services.ServiceConfiguration)</code></a> method
as follows:
<pre name="code" class="java">
GridServiceConfiguration cfg = new GridServiceConfiguration();
cfg.setName(name);
cfg.setService(svc);
cfg.setCacheName(cacheName);
cfg.setAffinityKey(affKey);
cfg.setTotalCount(1);
cfg.setMaxPerNodeCount(1);
grid.services().deploy(cfg);
</pre></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd><dd><code>svc</code> - Service instance.</dd><dd><code>cacheName</code> - Name of the cache on which affinity for key should be calculated, <code>null</code> for
default cache.</dd><dd><code>affKey</code> - Affinity cache key.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to deploy service.</dd></dl>
</li>
</ul>
<a name="deployMultiple(java.lang.String, org.apache.ignite.services.Service, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>deployMultiple</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;deployMultiple(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../org/apache/ignite/services/Service.html" title="interface in org.apache.ignite.services">Service</a>&nbsp;svc,
int&nbsp;totalCnt,
int&nbsp;maxPerNodeCnt)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Deploys multiple instances of the service on the grid. Ignite will deploy a
maximum amount of services equal to <code>'totalCnt'</code> parameter making sure that
there are no more than <code>'maxPerNodeCnt'</code> service instances running
on each node. Whenever topology changes, Ignite will automatically rebalance
the deployed services within cluster to make sure that each node will end up with
about equal number of deployed instances whenever possible.
<p>
Note that at least one of <code>'totalCnt'</code> or <code>'maxPerNodeCnt'</code> parameters must have
value greater than <code>0</code>.
<p>
This method is analogous to the invocation of <a href="../../../org/apache/ignite/IgniteServices.html#deploy(org.apache.ignite.services.ServiceConfiguration)"><code>deploy(org.apache.ignite.services.ServiceConfiguration)</code></a> method
as follows:
<pre name="code" class="java">
GridServiceConfiguration cfg = new GridServiceConfiguration();
cfg.setName(name);
cfg.setService(svc);
cfg.setTotalCount(totalCnt);
cfg.setMaxPerNodeCount(maxPerNodeCnt);
grid.services().deploy(cfg);
</pre></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd><dd><code>svc</code> - Service instance.</dd><dd><code>totalCnt</code> - Maximum number of deployed services in the grid, <code>0</code> for unlimited.</dd><dd><code>maxPerNodeCnt</code> - Maximum number of deployed services on each node, <code>0</code> for unlimited.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to deploy service.</dd></dl>
</li>
</ul>
<a name="deploy(org.apache.ignite.services.ServiceConfiguration)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>deploy</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;deploy(<a href="../../../org/apache/ignite/services/ServiceConfiguration.html" title="class in org.apache.ignite.services">ServiceConfiguration</a>&nbsp;cfg)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Deploys multiple instances of the service on the grid according to provided
configuration. Ignite will deploy a maximum amount of services equal to
<a href="../../../org/apache/ignite/services/ServiceConfiguration.html#getTotalCount()"><code>cfg.getTotalCount()</code></a> parameter
making sure that there are no more than <a href="../../../org/apache/ignite/services/ServiceConfiguration.html#getMaxPerNodeCount()"><code>cfg.getMaxPerNodeCount()</code></a>
service instances running on each node. Whenever topology changes, Ignite will automatically rebalance
the deployed services within cluster to make sure that each node will end up with
about equal number of deployed instances whenever possible.
<p>
If <a href="../../../org/apache/ignite/services/ServiceConfiguration.html#getAffinityKey()"><code>cfg.getAffinityKey()</code></a> is not <code>null</code>, then Ignite
will deploy the service on the primary node for given affinity key. The affinity will be calculated
on the cache with <a href="../../../org/apache/ignite/services/ServiceConfiguration.html#getCacheName()"><code>cfg.getCacheName()</code></a> name.
<p>
If <a href="../../../org/apache/ignite/services/ServiceConfiguration.html#getNodeFilter()"><code>cfg.getNodeFilter()</code></a> is not <code>null</code>, then
Ignite will deploy service on all grid nodes for which the provided filter evaluates to <code>true</code>.
The node filter will be checked in addition to the underlying cluster group filter, or the
whole grid, if the underlying cluster group includes all the cluster nodes.
<p>
Note that at least one of <code>'totalCnt'</code> or <code>'maxPerNodeCnt'</code> parameters must have
value greater than <code>0</code>.
<p>
Here is an example of creating service deployment configuration:
<pre name="code" class="java">
GridServiceConfiguration cfg = new GridServiceConfiguration();
cfg.setName(name);
cfg.setService(svc);
cfg.setTotalCount(0); // Unlimited.
cfg.setMaxPerNodeCount(2); // Deploy 2 instances of service on each node.
grid.services().deploy(cfg);
</pre></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>cfg</code> - Service configuration.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to deploy service.</dd></dl>
</li>
</ul>
<a name="cancel(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>cancel</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;cancel(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Cancels service deployment. If a service with specified name was deployed on the grid,
then <a href="../../../org/apache/ignite/services/Service.html#cancel(org.apache.ignite.services.ServiceContext)"><code>Service.cancel(org.apache.ignite.services.ServiceContext)</code></a> method will be called on it.
<p>
Note that Ignite cannot guarantee that the service exits from <a href="../../../org/apache/ignite/services/Service.html#execute(org.apache.ignite.services.ServiceContext)"><code>Service.execute(org.apache.ignite.services.ServiceContext)</code></a>
method whenever <a href="../../../org/apache/ignite/services/Service.html#cancel(org.apache.ignite.services.ServiceContext)"><code>Service.cancel(org.apache.ignite.services.ServiceContext)</code></a> is called. It is up to the user to
make sure that the service code properly reacts to cancellations.
<p>
Supports asynchronous execution (see <a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html" title="interface in org.apache.ignite.lang"><code>IgniteAsyncSupport</code></a>).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Name of service to cancel.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to cancel service.</dd></dl>
</li>
</ul>
<a name="cancelAll()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>cancelAll</h4>
<pre><a href="../../../org/apache/ignite/lang/IgniteAsyncSupported.html" title="annotation in org.apache.ignite.lang">@IgniteAsyncSupported</a>
void&nbsp;cancelAll()
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Cancels all deployed services.
<p>
Note that depending on user logic, it may still take extra time for a service to
finish execution, even after it was cancelled.
<p>
Supports asynchronous execution (see <a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html" title="interface in org.apache.ignite.lang"><code>IgniteAsyncSupport</code></a>).</div>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to cancel services.</dd></dl>
</li>
</ul>
<a name="serviceDescriptors()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>serviceDescriptors</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../org/apache/ignite/services/ServiceDescriptor.html" title="interface in org.apache.ignite.services">ServiceDescriptor</a>&gt;&nbsp;serviceDescriptors()</pre>
<div class="block">Gets metadata about all deployed services.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>Metadata about all deployed services.</dd></dl>
</li>
</ul>
<a name="service(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>service</h4>
<pre>&lt;T&gt;&nbsp;T&nbsp;service(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</pre>
<div class="block">Gets deployed service with specified name.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - Service type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd>
<dt><span class="strong">Returns:</span></dt><dd>Deployed service with specified name.</dd></dl>
</li>
</ul>
<a name="services(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>services</h4>
<pre>&lt;T&gt;&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;T&gt;&nbsp;services(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</pre>
<div class="block">Gets all deployed services with specified name.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - Service type.</dd><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd>
<dt><span class="strong">Returns:</span></dt><dd>all deployed services with specified name.</dd></dl>
</li>
</ul>
<a name="serviceProxy(java.lang.String, java.lang.Class, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>serviceProxy</h4>
<pre>&lt;T&gt;&nbsp;T&nbsp;serviceProxy(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;? super T&gt;&nbsp;svcItf,
boolean&nbsp;sticky)
throws <a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></pre>
<div class="block">Gets a remote handle on the service. If service is available locally,
then local instance is returned, otherwise, a remote proxy is dynamically
created and provided for the specified service.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - Service name.</dd><dd><code>svcItf</code> - Interface for the service.</dd><dd><code>sticky</code> - Whether or not Ignite should always contact the same remote
service or try to load-balance between services.</dd>
<dt><span class="strong">Returns:</span></dt><dd>Either proxy over remote service or local service if it is deployed locally.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If failed to create service proxy.</dd></dl>
</li>
</ul>
<a name="withAsync()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>withAsync</h4>
<pre><a href="../../../org/apache/ignite/IgniteServices.html" title="interface in org.apache.ignite">IgniteServices</a>&nbsp;withAsync()</pre>
<div class="block">Gets instance of this component with asynchronous mode enabled.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html#withAsync()">withAsync</a></code>&nbsp;in interface&nbsp;<code><a href="../../../org/apache/ignite/lang/IgniteAsyncSupport.html" title="interface in org.apache.ignite.lang">IgniteAsyncSupport</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>Instance of this component with asynchronous mode enabled.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/IgniteServices.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em>Ignite - In-Memory Data Fabric</em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../org/apache/ignite/IgniteSemaphore.html" title="interface in org.apache.ignite"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../org/apache/ignite/IgniteSet.html" title="interface in org.apache.ignite"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/apache/ignite/IgniteServices.html" target="_top">Frames</a></li>
<li><a href="IgniteServices.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small><table width="100%" border="0" cellspacing=0 cellpadding=0 style="padding: 5px"> <tr> <td> <table style="padding-left: 0; margin: 0"> <tbody style="padding: 0; margin: 0"> <tr style="padding: 0; margin: 0"> <td> <a target=_blank href="https://ignite.apache.org"><nobr>2015 Copyright &#169; Apache Software Foundation</nobr></a> </td> </tr> </tbody> </table> </td> <td width="100%" align="right" valign="center"> <a href="https://twitter.com/ApacheIgnite" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @ApacheIgnite</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> </td> </tr> <tr> <td colspan="2" valign="top" align="left"> <table style="padding-left: 0; margin: 0"> <tbody style="padding: 0; margin: 0"> <tr style="padding: 0; margin: 0"> <td> <b>Ignite Fabric</b> </td> <td>:&nbsp;&nbsp; ver. <strong>1.7.0</strong> </td> </tr> <tr style="padding: 0; margin: 0"> <td> <b>Release Date</b> </td> <td>:&nbsp;&nbsp; August 1 2016 </td> </tr> </tbody> </table> </td> </tr> </table></small></p>
</body>
</html>