blob: cead8b238e1c7ca7ad8316fe2e866463fb361ae8 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(72949126, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/72949126" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
<script type='text/javascript'>
window.__lo_site_id = 284467;
(function() {
var wa = document.createElement('script'); wa.type = 'text/javascript'; wa.async = true;
wa.src = 'https://d10lpsik1i8c69.cloudfront.net/w.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wa, s);
})();
</script>
<link rel="canonical" href="https://ignite.apache.org/releases/latest/dotnetdoc/api/Apache.Ignite.Core.Compute.html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Namespace Apache.Ignite.Core.Compute
| Apache Ignite.NET </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Namespace Apache.Ignite.Core.Compute
| Apache Ignite.NET ">
<meta name="generator" content="docfx 2.24.0.0">
<link rel="shortcut icon" href="../images/favicon.ico">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="toc.html">
<meta property="docfx:rel" content="../">
<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 data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../images/logo_ignite_32_32.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="Apache.Ignite.Core.Compute">
<h1 id="Apache_Ignite_Core_Compute" data-uid="Apache.Ignite.Core.Compute" class="text-break">Namespace Apache.Ignite.Core.Compute
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>
<div class="markdown level0 remarks"></div>
<h3 id="classes">Classes
</h3>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeExecutionRejectedException.html">ComputeExecutionRejectedException</a></h4>
<section><p>Indicates a situation when execution service provided by the user in configuration rejects execution.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobAdapter-1.html">ComputeJobAdapter&lt;T&gt;</a></h4>
<section><p>Convenience adapter for <a class="xref" href="Apache.Ignite.Core.Compute.IComputeJob-1.html">IComputeJob&lt;TRes&gt;</a> implementations. It provides the following functionality:
<ul>
<li>
Default implementation of <a class="xref" href="Apache.Ignite.Core.Compute.IComputeJob-1.html#Apache_Ignite_Core_Compute_IComputeJob_1_Cancel">Cancel()</a> method and ability
to check whether cancellation occurred with <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobAdapter-1.html#Apache_Ignite_Core_Compute_ComputeJobAdapter_1_IsCancelled">IsCancelled()</a> method.
</li>
<li>
Ability to set and get job arguments via <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobAdapter-1.html#Apache_Ignite_Core_Compute_ComputeJobAdapter_1_SetArguments_System_Object___">SetArguments(Object[])</a>
and <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobAdapter-1.html#Apache_Ignite_Core_Compute_ComputeJobAdapter_1_GetArgument__1_System_Int32_">GetArgument&lt;TArg&gt;(Int32)</a> methods.
</li>
</ul></p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobFailoverException.html">ComputeJobFailoverException</a></h4>
<section><p>This runtime exception can be thrown from <a class="xref" href="Apache.Ignite.Core.Compute.IComputeJob-1.html#Apache_Ignite_Core_Compute_IComputeJob_1_Execute">Execute()</a>
method to force job failover to another node within task topology.
<a class="xref" href="Apache.Ignite.Core.Compute.IComputeFunc-2.html">IComputeFunc&lt;TArg, TRes&gt;</a> or <a class="xref" href="Apache.Ignite.Core.Compute.IComputeFunc-1.html">IComputeFunc&lt;TRes&gt;</a>
passed into any of the <a class="xref" href="Apache.Ignite.Core.Compute.ICompute.html">ICompute</a> methods can also throw this exception
to force failover.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskAdapter-3.html">ComputeTaskAdapter&lt;TArg, TJobRes, TTaskRes&gt;</a></h4>
<section><p>Convenience adapter for <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html">IComputeTask&lt;TArg, TJobRes, TRes&gt;</a> interface</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskCancelledException.html">ComputeTaskCancelledException</a></h4>
<section><p>This exception indicates that Ignite task was cancelled.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskNoResultCacheAttribute.html">ComputeTaskNoResultCacheAttribute</a></h4>
<section><p>This attribute disables caching of task results when attached to <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html">IComputeTask&lt;TArg, TJobRes, TRes&gt;</a>
instance. Use it when number of jobs within task grows too big, or jobs themselves are too large
to keep in memory throughout task execution. By default all results are cached and passed into
<a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_OnResult_Apache_Ignite_Core_Compute_IComputeJobResult__1__System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">OnResult(IComputeJobResult&lt;TJobRes&gt;, IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a>
and <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_Reduce_System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">Reduce(IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a> methods. When this
attribute is attached to a task class, then this list of job results will always be empty.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskSplitAdapter-3.html">ComputeTaskSplitAdapter&lt;TArg, TJobRes, TTaskRes&gt;</a></h4>
<section><p>This class defines simplified adapter for <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html">IComputeTask&lt;TArg, TJobRes, TRes&gt;</a>. This adapter can be used
when jobs can be randomly assigned to available Ignite nodes. This adapter is sufficient
in most homogeneous environments where all nodes are equally suitable for executing grid
job, see <a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskSplitAdapter-3.html#Apache_Ignite_Core_Compute_ComputeTaskSplitAdapter_3_Split_System_Int32__0_">Split(Int32, TArg)</a> method for more details.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskTimeoutException.html">ComputeTaskTimeoutException</a></h4>
<section><p>Indicates that task execution timed out.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeUserUndeclaredException.html">ComputeUserUndeclaredException</a></h4>
<section><p>This exception is thrown when user&apos;s code throws undeclared runtime exception. By user core it is
assumed the code in Ignite task, Ignite job or SPI. In most cases it should be an indication of unrecoverable
error condition such as assertion, out of memory error, etc.</p>
</section>
<h3 id="interfaces">Interfaces
</h3>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ICompute.html">ICompute</a></h4>
<section><p>Defines Ignite functionality for executing tasks and closures over nodes
in the <a class="xref" href="Apache.Ignite.Core.Cluster.IClusterGroup.html">IClusterGroup</a>. Instance of <a class="xref" href="Apache.Ignite.Core.Compute.ICompute.html">ICompute</a>
is obtained from grid projection using <a class="xref" href="Apache.Ignite.Core.Cluster.IClusterGroup.html#Apache_Ignite_Core_Cluster_IClusterGroup_GetCompute">GetCompute()</a> method.
<p>
Note that if attempt is made to execute a computation over an empty projection (i.e. projection that does
not have any alive nodes), <code>ClusterGroupEmptyException</code> will be thrown out of result task.
<p>
Ignite must select a node for a computation to be executed. The node will be selected based on the
underlying <code>GridLoadBalancingSpi</code>, which by default sequentially picks next available node from
grid projection. Other load balancing policies, such as <code>random</code> or <code>adaptive</code>, can be
configured as well by selecting different load balancing SPI in Ignite configuration. If your logic requires
some custom load balancing behavior, consider implementing <code>ComputeTask</code> in Java directly.
<p>
Ignite guarantees that as long as there is at least one Ignite node standing, every job will be
executed. Jobs will automatically failover to another node if a remote node crashed or has rejected
execution due to lack of resources. By default, in case of failover, next load balanced node will be
picked for job execution. Also jobs will never be re-routed to the nodes they have failed on. This
behavior can be changed by configuring any of the existing or a custom <code>FailoverSpi</code> in Ignite
configuration.
<p>
All members are thread-safe and may be used concurrently from multiple threads.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeAction.html">IComputeAction</a></h4>
<section><p>Defines a void function having no arguments.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeFunc-1.html">IComputeFunc&lt;TRes&gt;</a></h4>
<section><p>Defines function having no arguments.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeFunc-2.html">IComputeFunc&lt;TArg, TRes&gt;</a></h4>
<section><p>Defines function having a single argument.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeJob-1.html">IComputeJob&lt;TRes&gt;</a></h4>
<section><p>Defines executable unit for <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html">IComputeTask&lt;TArg, TJobRes, TRes&gt;</a>. Ignite task gets split into jobs
when <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_Map_System_Collections_Generic_IList_Apache_Ignite_Core_Cluster_IClusterNode___0_">Map(IList&lt;IClusterNode&gt;, TArg)</a> method is called. This
method returns all jobs for the task mapped to their corresponding Ignite nodes for execution.
Grid will then serialize this jobs and send them to requested nodes for execution.
<p>
Once job execution is complete, the return value will be sent back to parent task and will
be passed into
<a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_OnResult_Apache_Ignite_Core_Compute_IComputeJobResult__1__System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">OnResult(IComputeJobResult&lt;TJobRes&gt;, IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a>
method via <a class="xref" href="Apache.Ignite.Core.Compute.IComputeJobResult-1.html">IComputeJobResult&lt;TRes&gt;</a> instance.
<p>
Ignite job implementation can be injected with <a class="xref" href="Apache.Ignite.Core.IIgnite.html">IIgnite</a> using
<a class="xref" href="Apache.Ignite.Core.Resource.InstanceResourceAttribute.html">InstanceResourceAttribute</a> attribute.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeJobResult-1.html">IComputeJobResult&lt;TRes&gt;</a></h4>
<section><p>Job execution result which gets passed to
<a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_OnResult_Apache_Ignite_Core_Compute_IComputeJobResult__1__System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">OnResult(IComputeJobResult&lt;TJobRes&gt;, IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a>
method.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeReducer-2.html">IComputeReducer&lt;TRes, TReduceRes&gt;</a></h4>
<section><p>Compute reducer which is capable of result collecting and reducing.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-2.html">IComputeTask&lt;TJobRes, TReduceRes&gt;</a></h4>
<section><p>IComputeTask without an argument.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html">IComputeTask&lt;TArg, TJobRes, TRes&gt;</a></h4>
<section><p>Ignite task interface defines a task that can be executed on the grid. Ignite task
is responsible for splitting business logic into multiple Ignite jobs, receiving
results from individual Ignite jobs executing on remote nodes, and reducing
(aggregating) received jobs&apos; results into final Ignite task result.
<p>
Upon request to execute a task, the system will do the following:
<ul><li>Inject annotated resources into task instance.</li><li>Apply <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_Map_System_Collections_Generic_IList_Apache_Ignite_Core_Cluster_IClusterNode___0_">Map(IList&lt;IClusterNode&gt;, TArg)</a>.
This method is responsible for splitting business logic into multiple jobs
(units of execution) and mapping them to Ignite nodes.</li><li>System will send mapped Ignite jobs to their respective nodes.</li><li>Once job execution results become available, <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_OnResult_Apache_Ignite_Core_Compute_IComputeJobResult__1__System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">OnResult(IComputeJobResult&lt;TJobRes&gt;, IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a> method
will be called for ech received job result. The policy returned by this method will
determine the way task reacts to every job result.
<p>
If <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobResultPolicy.html#Apache_Ignite_Core_Compute_ComputeJobResultPolicy_Wait">Wait</a> is returned, task will continue to wait
for other job results. If this result is the last job result, then reduce phase will be
started.
<p>
If <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobResultPolicy.html#Apache_Ignite_Core_Compute_ComputeJobResultPolicy_Reduce">Reduce</a> is returned, reduce phase will be started
right away without waiting for other jobs completion (all remaining jobs will receive cancel
request).
<p>
If <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobResultPolicy.html#Apache_Ignite_Core_Compute_ComputeJobResultPolicy_Failover">Failover</a> is returned, job will be failed over to
another node for execution. Note that if you use <a class="xref" href="Apache.Ignite.Core.Compute.ComputeTaskAdapter-3.html">ComputeTaskAdapter&lt;TArg, TJobRes, TTaskRes&gt;</a>, it will
automatically fail jobs to another node for 2 well-known failure cases: 1) job has failed to due
to node crash (in this case <a class="xref" href="Apache.Ignite.Core.Compute.IComputeJobResult-1.html#Apache_Ignite_Core_Compute_IComputeJobResult_1_Exception">Exception</a> will return
<a class="xref" href="Apache.Ignite.Core.Cluster.ClusterTopologyException.html">ClusterTopologyException</a>); 2) job execution was rejected, i.e. remote node
has cancelled job before it got a chance to execute, while it still was on the waiting list.
(in this case <a class="xref" href="Apache.Ignite.Core.Compute.IComputeJobResult-1.html#Apache_Ignite_Core_Compute_IComputeJobResult_1_Exception">Exception</a> will return
<a class="xref" href="Apache.Ignite.Core.Compute.ComputeExecutionRejectedException.html">ComputeExecutionRejectedException</a>).
</li><li>Once all results are received or <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_OnResult_Apache_Ignite_Core_Compute_IComputeJobResult__1__System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">OnResult(IComputeJobResult&lt;TJobRes&gt;, IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a>
method returned <a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobResultPolicy.html#Apache_Ignite_Core_Compute_ComputeJobResultPolicy_Reduce">Reduce</a> policy, method <a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_Reduce_System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">Reduce(IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a>
is called to aggregate received results into one final result. Once this method is finished the
execution of the Ignite task is complete. This result will be returned to the user through future.
</li></ul></p>
</section>
<h3 id="enums">Enums
</h3>
<h4><a class="xref" href="Apache.Ignite.Core.Compute.ComputeJobResultPolicy.html">ComputeJobResultPolicy</a></h4>
<section><p>This enumeration provides different types of actions following the last received job result. See
<a class="xref" href="Apache.Ignite.Core.Compute.IComputeTask-3.html#Apache_Ignite_Core_Compute_IComputeTask_3_OnResult_Apache_Ignite_Core_Compute_IComputeJobResult__1__System_Collections_Generic_IList_Apache_Ignite_Core_Compute_IComputeJobResult__1___">OnResult(IComputeJobResult&lt;TJobRes&gt;, IList&lt;IComputeJobResult&lt;TJobRes&gt;&gt;)</a>
for more details.</p>
</section>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
© 2015 - 2019 The Apache Software Foundation
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>
</body>
</html>