org.apache.ignite.internal.processors.hadoop

## Class HadoopTaskContext

- java.lang.Object
- - org.apache.ignite.internal.processors.hadoop.HadoopTaskContext

    public abstract class HadoopTaskContext
    extends Object

Task context.

### Field Summary

Fields
`protected HadoopJobEx` `job`

### Constructor Summary

Constructors
`protected` `HadoopTaskContext(HadoopTaskInfo taskInfo, HadoopJobEx job)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`abstract void` `cancel()` Cancel current task execution.
`abstract void` `cleanupTaskEnvironment()` Cleans up local environment of the task.
`abstract <T extends HadoopCounter> T` `counter(String grp, String name, Class<T> cls)` Gets counter for the given name.
`abstract HadoopCounters` `counters()` Gets all known counters.
`abstract Comparator<Object>` `groupComparator()` Gets comparator for grouping on combine or reduce operation.
`HadoopTaskInput` `input()` Gets task input.
`void` `input(HadoopTaskInput in)` Sets input of the task.
`HadoopJobEx` `job()`
`abstract HadoopSerialization` `keySerialization()` Gets serializer for values.
`void` `onMapperFinished()` Callback invoked from mapper thread when map is finished.
`HadoopTaskOutput` `output()` Gets task output.
`void` `output(HadoopTaskOutput out)` Sets output of the task.
`abstract PartiallyOffheapRawComparatorEx<Object>` `partialRawSortComparator()` Get semi-raw sorting comparator.
`abstract HadoopPartitioner` `partitioner()` Gets partitioner.
`abstract void` `prepareTaskEnvironment()` Prepare local environment for the task.
`abstract void` `run()` Execute current task.
`abstract <T> T` `runAsJobOwner(Callable<T> c)` Executes a callable on behalf of the job owner.
`abstract Comparator<Object>` `sortComparator()` Gets sorting comparator.
`HadoopTaskInfo` `taskInfo()` Gets task info.
`void` `taskInfo(HadoopTaskInfo info)` Set a new task info.
`abstract HadoopSerialization` `valueSerialization()` Gets serializer for values.

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

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

### Field Detail

#### job

    protected final HadoopJobEx job

### Constructor Detail

#### HadoopTaskContext

    protected HadoopTaskContext(HadoopTaskInfo taskInfo,
                                HadoopJobEx job)

Parameters:
  `taskInfo` - Task info.
  `job` - Job.

### Method Detail

#### taskInfo

    public HadoopTaskInfo taskInfo()

Gets task info.

Returns:
  Task info.

#### taskInfo

    public void taskInfo(HadoopTaskInfo info)

Set a new task info.

Parameters:
  `info` - Task info.

#### output

    public HadoopTaskOutput output()

Gets task output.

Returns:
  Task output.

#### input

    public HadoopTaskInput input()

Gets task input.

Returns:
  Task input.

#### job

    public HadoopJobEx job()

Returns:
  Job.

#### counter

    public abstract <T extends HadoopCounter> T counter(String grp,
                                                        String name,
                                                        Class<T> cls)

Gets counter for the given name.

Parameters:
  `grp` - Counter group's name.
  `name` - Counter name.
Returns:
  Counter.

#### counters

    public abstract HadoopCounters counters()

Gets all known counters.

Returns:
  Unmodifiable collection of counters.

#### input

    public void input(HadoopTaskInput in)

Sets input of the task.

Parameters:
  `in` - Input.

#### output

    public void output(HadoopTaskOutput out)

Sets output of the task.

Parameters:
  `out` - Output.

#### partitioner

    public abstract HadoopPartitioner partitioner()
                                           throws IgniteCheckedException

Gets partitioner.

Returns:
  Partitioner.
Throws:
  `IgniteCheckedException` - If failed.

#### keySerialization

    public abstract HadoopSerialization keySerialization()
                                                  throws IgniteCheckedException

Gets serializer for values.

Returns:
  Serializer for keys.
Throws:
  `IgniteCheckedException` - If failed.

#### valueSerialization

    public abstract HadoopSerialization valueSerialization()
                                                    throws IgniteCheckedException

Gets serializer for values.

Returns:
  Serializer for values.
Throws:
  `IgniteCheckedException` - If failed.

#### sortComparator

    public abstract Comparator<Object> sortComparator()

Gets sorting comparator.

Returns:
  Comparator for sorting.

#### partialRawSortComparator

    public abstract PartiallyOffheapRawComparatorEx<Object> partialRawSortComparator()

Get semi-raw sorting comparator.

Returns:
  Semi-raw sorting comparator.

#### groupComparator

    public abstract Comparator<Object> groupComparator()

Gets comparator for grouping on combine or reduce operation.

Returns:
  Comparator.

#### run

    public abstract void run()
                      throws IgniteCheckedException

Execute current task.

Throws:
  `IgniteCheckedException` - If failed.

#### cancel

    public abstract void cancel()

Cancel current task execution.

#### prepareTaskEnvironment

    public abstract void prepareTaskEnvironment()
                                         throws IgniteCheckedException

Prepare local environment for the task.

Throws:
  `IgniteCheckedException` - If failed.

#### cleanupTaskEnvironment

    public abstract void cleanupTaskEnvironment()
                                         throws IgniteCheckedException

Cleans up local environment of the task.

Throws:
  `IgniteCheckedException` - If failed.

#### runAsJobOwner

    public abstract <T> T runAsJobOwner(Callable<T> c)
                                 throws IgniteCheckedException

Executes a callable on behalf of the job owner. In case of embedded task execution the implementation of this method will use classes loaded by the ClassLoader this HadoopTaskContext loaded with.

Type Parameters:
  `T` - The return type of the Callable.
Parameters:
  `c` - The callable.
Returns:
  The result of the callable.
Throws:
  `IgniteCheckedException` - On any error in callable.

#### onMapperFinished

    public void onMapperFinished()
                          throws IgniteCheckedException

Callback invoked from mapper thread when map is finished.

Throws:
  `IgniteCheckedException` - If failed.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.1
Release Date | : May 21 2020