org.apache.ignite.internal.processors.streamer

## Class GridStreamerStageExecutionFuture

- java.lang.Object
- - java.util.concurrent.locks.AbstractOwnableSynchronizer
  - - java.util.concurrent.locks.AbstractQueuedSynchronizer
    - - org.apache.ignite.internal.util.future.GridFutureAdapter<Object>
      - - org.apache.ignite.internal.processors.streamer.GridStreamerStageExecutionFuture

All Implemented Interfaces:
  Serializable, IgniteInternalFuture<Object>

    public class GridStreamerStageExecutionFuture
    extends GridFutureAdapter<Object>

Streamer execution future.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

`AbstractQueuedSynchronizer.ConditionObject`

### Constructor Summary

Constructors
Constructor and Description
`GridStreamerStageExecutionFuture(IgniteStreamerEx streamer, IgniteUuid execId, int failoverAttemptCnt, long execStartTs, IgniteUuid parentFutId, Collection<UUID> prevExecNodes, String stageName, Collection<?> evts)`

### Method Summary

Methods
`boolean` `cancel()` Default no-op implementation that always returns `false`.
`Map<UUID,GridStreamerExecutionBatch>` `childExecutions()`
`Collection<Object>` `events()`
`Collection<UUID>` `executionNodeIds()`
`int` `failoverAttemptCount()`
`IgniteUuid` `id()`
`void` `map()` Sends execution requests to remote nodes or schedules local execution if events were mapped locally.
`void` `metrics(StreamerMetricsHolder metricsHolder)` Sets metrics holder to update counters when future completes.
`boolean` `onDone(Object res, Throwable err)` Callback to notify that future is finished.
`void` `onExecutionCompleted(UUID childNodeId, Throwable err)` Callback invoked when child node reports execution is completed (successfully or not).
`void` `onNodeLeft(UUID leftNodeId)` Callback invoked when node leaves the grid.
`IgniteUuid` `parentFutureId()` If not root future, will return parent future ID.
`boolean` `rootExecution()`
`UUID` `senderNodeId()` If not root future, will return parent node ID (may be local node ID).
`String` `stageName()`
`String` `toString()`

### Methods inherited from class org.apache.ignite.internal.util.future.GridFutureAdapter

`chain, duration, endTime, error, get, get, get, get0, isCancelled, isDone, isFailed, listen, onCancelled, onDone, onDone, onDone, result, startTime, tryAcquireShared, tryReleaseShared`

### Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

`acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease`

### Methods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer

`getExclusiveOwnerThread, setExclusiveOwnerThread`

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

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

### Constructor Detail

#### GridStreamerStageExecutionFuture

    public GridStreamerStageExecutionFuture(IgniteStreamerEx streamer,
                                    @Nullable
                                    IgniteUuid execId,
                                    int failoverAttemptCnt,
                                    long execStartTs,
                                    @Nullable
                                    IgniteUuid parentFutId,
                                    @Nullable
                                    Collection<UUID> prevExecNodes,
                                    String stageName,
                                    Collection<?> evts)

Parameters:
  `streamer` - Streamer extended context.
  `execId` - Execution ID. If parent future ID is `null` then this is a root future and execution ID must be `null`.
  `failoverAttemptCnt` - Number of attempts this set of events was tried to failover.
  `execStartTs` - Execution start timestamp.
  `parentFutId` - Parent future ID.
  `prevExecNodes` - Node IDs on which pipeline was already executed.
  `stageName` - Stage name to run.
  `evts` - Events to process.

### Method Detail

#### id

    public IgniteUuid id()

Returns:
  Future ID.

#### metrics

    public void metrics(StreamerMetricsHolder metricsHolder)

Sets metrics holder to update counters when future completes. Used to avoid unnecessary listener creation.

Parameters:
  `metricsHolder` - Metrics holder.

#### failoverAttemptCount

    public int failoverAttemptCount()

Returns:
  Failover attempt count.

#### stageName

    public String stageName()

Returns:
  Stage name.

#### events

    public Collection<Object> events()

Returns:
  Events collection.

#### map

    public void map()

Sends execution requests to remote nodes or schedules local execution if events were mapped locally.

#### rootExecution

    public boolean rootExecution()

Returns:
  `True` if this future is a root execution future (i.e. initiated by streamer's addEvent call).

#### senderNodeId

    @Nullable
    public UUID senderNodeId()

If not root future, will return parent node ID (may be local node ID).

Returns:
  Sender node ID.

#### parentFutureId

    public IgniteUuid parentFutureId()

If not root future, will return parent future ID.

Returns:
  Parent future ID.

#### childExecutions

    public Map<UUID,GridStreamerExecutionBatch> childExecutions()

Returns:
  Map of child executions.

#### executionNodeIds

    public Collection<UUID> executionNodeIds()

Returns:
  Execution node IDs.

#### onExecutionCompleted

    public void onExecutionCompleted(UUID childNodeId,
                            @Nullable
                            Throwable err)

Callback invoked when child node reports execution is completed (successfully or not).

Parameters:
  `childNodeId` - Child node ID.
  `err` - Exception if execution failed.

#### onNodeLeft

    public void onNodeLeft(UUID leftNodeId)

Callback invoked when node leaves the grid. If left node is known to participate in pipeline execution, cancel all locally running stages.

Parameters:
  `leftNodeId` - Node ID that has left the grid.

#### onDone

    public boolean onDone(@Nullable
                 Object res,
                 @Nullable
                 Throwable err)

Callback to notify that future is finished. Note that if non-`null` exception is passed in the result value will be ignored.

Overrides:
  `onDone` in class `GridFutureAdapter<Object>`
Parameters:
  `res` - Optional result.
  `err` - Optional error.
Returns:
  `True` if result was set by this call.

#### cancel

    public boolean cancel()
                   throws IgniteCheckedException

Default no-op implementation that always returns `false`. Futures that do support cancellation should override this method and call `GridFutureAdapter.onCancelled()` callback explicitly if cancellation indeed did happen.

Specified by:
  `cancel` in interface `IgniteInternalFuture<Object>`
Overrides:
  `cancel` in class `GridFutureAdapter<Object>`
Returns:
  `True` if future was canceled (i.e. was not finished prior to this call).
Throws:
  `IgniteCheckedException` - If cancellation failed.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridFutureAdapter<Object>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015