org.apache.ignite.internal.util.lang

## Class GridComputeJobWrapper

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridComputeJobWrapper

All Implemented Interfaces:
  Serializable, Callable<Object>, ComputeJob, GridPeerDeployAware

    public class GridComputeJobWrapper
    extends Object
    implements ComputeJob, Callable<Object>, GridPeerDeployAware

Convenient wrapper for grid job. It allows to create a job clone in cases when the same job needs to be cloned to multiple grid nodes during mapping phase of task execution.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridComputeJobWrapper(ComputeJob job)` Creates a wrapper with given grid `job`.

### Method Summary

Methods
`Object` `call()`
`void` `cancel()` This method is called when system detects that completion of this job can no longer alter the overall outcome (for example, when parent task has already reduced the results).
`ClassLoader` `classLoader()` Gets class loader for the class.
`Class<?>` `deployClass()` Gets top level user class being deployed.
`Object` `execute()` Executes this job.
`String` `toString()`
`ComputeJob` `wrappedJob()` Gets wrapped job.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridComputeJobWrapper

    public GridComputeJobWrapper(ComputeJob job)

Creates a wrapper with given grid `job`.

Parameters:
  `job` - Job to wrap.

### Method Detail

#### wrappedJob

    public ComputeJob wrappedJob()

Gets wrapped job.

Returns:
  Wrapped job.

#### call

    @Nullable
    public final Object call()
                      throws Exception

Specified by:
  `call` in interface `Callable<Object>`
Throws:
  `Exception`

#### deployClass

    public Class<?> deployClass()

Gets top level user class being deployed.

Specified by:
  `deployClass` in interface `GridPeerDeployAware`
Returns:
  Top level user deployed class.

#### classLoader

    public ClassLoader classLoader()

Gets class loader for the class. This class loader must be able to load the class returned from `GridPeerDeployAware.deployClass()` as well as all of its dependencies.

Note that in most cases the class loader returned from this method and the class loader for the class returned from `GridPeerDeployAware.deployClass()` method will be the same. If they are not the same, it is required that the class loader returned from this method still has to be able to load the deploy class and all its dependencies.

Specified by:
  `classLoader` in interface `GridPeerDeployAware`
Returns:
  Class loader for the class.

#### cancel

    public void cancel()

This method is called when system detects that completion of this job can no longer alter the overall outcome (for example, when parent task has already reduced the results). Job is also cancelled when `IgniteFuture.cancel()` is called.

Note that job cancellation is only a hint, and just like with `Thread.interrupt()` method, it is really up to the actual job instance to gracefully finish execution and exit.

Specified by:
  `cancel` in interface `ComputeJob`

#### execute

    public Object execute()

Executes this job.

Specified by:
  `execute` in interface `ComputeJob`
Returns:
  Job execution result (possibly `null`). This result will be returned in `ComputeJobResult.getData()` method passed into `ComputeTask.result(ComputeJobResult, List)` task method on caller node.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015