org.apache.ignite.internal.processors.streamer

## Class GridStreamerContextImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.streamer.GridStreamerContextImpl

All Implemented Interfaces:
  StreamerContext

    public class GridStreamerContextImpl
    extends Object
    implements StreamerContext

Streamer context implementation.

### Constructor Summary

Constructors
Constructor and Description
`GridStreamerContextImpl(GridKernalContext ctx, StreamerConfiguration cfg, IgniteStreamerEx streamer)`

### Method Summary

Methods
`void` `broadcast(IgniteInClosure<StreamerContext> clo)` Queries all streamer nodes deployed within grid.
`void` `broadcast(IgniteInClosure<StreamerContext> clo, Collection<ClusterNode> nodes)` Queries streamer nodes deployed within grid.
`<K,V> ConcurrentMap<K,V>` `localSpace()` Gets streamer local space.
`String` `nextStageName()` For context passed to `StreamerStage.run(StreamerContext, Collection)` this method will return next stage name in execution pipeline.
`void` `nextStageName(String nextStageName)` Sets next stage name for main context.
`ClusterGroup` `projection()` Gets instance of dynamic grid projection including all nodes on which this streamer is running.
`<R> Collection<R>` `query(IgniteClosure<StreamerContext,R> clo)` Queries all streamer nodes deployed within grid.
`<R> Collection<R>` `query(IgniteClosure<StreamerContext,R> clo, Collection<ClusterNode> nodes)` Queries streamer nodes deployed within grid.
`<R1,R2> R2` `reduce(IgniteClosure<StreamerContext,R1> clo, IgniteReducer<R1,R2> rdc)` Queries all streamer nodes deployed within grid.
`<R1,R2> R2` `reduce(IgniteClosure<StreamerContext,R1> clo, IgniteReducer<R1,R2> rdc, Collection<ClusterNode> nodes)` Queries streamer nodes deployed within grid.
`<E> StreamerWindow<E>` `window()` Gets default event window, i.e. window that is on the first place in streamer configuration.
`<E> StreamerWindow<E>` `window(String winName)` Gets streamer event window by window name, if no window with such name was configured `IllegalArgumentException` will be thrown.

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

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

### Constructor Detail

#### GridStreamerContextImpl

    public GridStreamerContextImpl(GridKernalContext ctx,
                           StreamerConfiguration cfg,
                           IgniteStreamerEx streamer)

Parameters:
  `ctx` - Kernal context.
  `cfg` - Streamer configuration.
  `streamer` - Streamer impl.

### Method Detail

#### projection

    public ClusterGroup projection()

Gets instance of dynamic grid projection including all nodes on which this streamer is running.

Specified by:
  `projection` in interface `StreamerContext`
Returns:
  Projection with all nodes on which streamer is configured.

#### localSpace

    public <K,V> ConcurrentMap<K,V> localSpace()

Gets streamer local space. Note that all updates to this space will be local.

Specified by:
  `localSpace` in interface `StreamerContext`
Returns:
  Streamer local space.

#### window

    public <E> StreamerWindow<E> window()

Gets default event window, i.e. window that is on the first place in streamer configuration.

Specified by:
  `window` in interface `StreamerContext`
Returns:
  Default window.

#### window

    public <E> StreamerWindow<E> window(String winName)

Gets streamer event window by window name, if no window with such name was configured `IllegalArgumentException` will be thrown.

Specified by:
  `window` in interface `StreamerContext`
Parameters:
  `winName` - Window name.
Returns:
  Window instance.

#### nextStageName

    public String nextStageName()

For context passed to `StreamerStage.run(StreamerContext, Collection)` this method will return next stage name in execution pipeline. For context obtained from streamer object, this method will return first stage name.

Specified by:
  `nextStageName` in interface `StreamerContext`
Returns:
  Next stage name depending on invocation context.

#### nextStageName

    public void nextStageName(String nextStageName)

Sets next stage name for main context.

Parameters:
  `nextStageName` - Next stage name.

#### query

    public <R> Collection<R> query(IgniteClosure<StreamerContext,R> clo)

Queries all streamer nodes deployed within grid. Given closure will be executed on each node on which streamer is configured. Streamer context local for that node will be passed to closure during execution. All results returned by closure will be added to result collection.

Specified by:
  `query` in interface `StreamerContext`
Parameters:
  `clo` - Function to be executed on individual nodes.
Returns:
  Result received from all streamers.

#### query

    public <R> Collection<R> query(IgniteClosure<StreamerContext,R> clo,
                          Collection<ClusterNode> nodes)

Queries streamer nodes deployed within grid. Given closure will be executed on those of passed nodes on which streamer is configured. Streamer context local for that node will be passed to closure during execution. All results returned by closure will be added to result collection.

Specified by:
  `query` in interface `StreamerContext`
Parameters:
  `clo` - Function to be executed on individual nodes.
  `nodes` - Optional list of nodes to execute query on, if empty, then all nodes on which this streamer is running will be queried.
Returns:
  Result received from all streamers.

#### broadcast

    public void broadcast(IgniteInClosure<StreamerContext> clo)

Queries all streamer nodes deployed within grid. Given closure will be executed on each streamer node in the grid. No result is collected.

Specified by:
  `broadcast` in interface `StreamerContext`
Parameters:
  `clo` - Function to be executed on individual nodes.

#### broadcast

    public void broadcast(IgniteInClosure<StreamerContext> clo,
                 Collection<ClusterNode> nodes)

Queries streamer nodes deployed within grid. Given closure will be executed on those of passed nodes on which streamer is configured. No result is collected.

Specified by:
  `broadcast` in interface `StreamerContext`
Parameters:
  `clo` - Function to be executed on individual nodes.
  `nodes` - Optional list of nodes to execute query on, if empty, then all nodes on which this streamer is running will be queried.

#### reduce

    public <R1,R2> R2 reduce(IgniteClosure<StreamerContext,R1> clo,
                    IgniteReducer<R1,R2> rdc)

Queries all streamer nodes deployed within grid. Given closure will be executed on each streamer node in the grid. Streamer context local for that node will be passed to closure during execution. Results returned by closure will be passed to given reducer.

Specified by:
  `reduce` in interface `StreamerContext`
Parameters:
  `clo` - Function to be executed on individual nodes.
  `rdc` - Reducer to reduce results received from remote nodes.
Returns:
  Reducer result.

#### reduce

    public <R1,R2> R2 reduce(IgniteClosure<StreamerContext,R1> clo,
                    IgniteReducer<R1,R2> rdc,
                    Collection<ClusterNode> nodes)

Queries streamer nodes deployed within grid. Given closure will be executed on those of passed nodes on which streamer is configured. Streamer context local for that node will be passed to closure during execution. Results returned by closure will be passed to given reducer.

Specified by:
  `reduce` in interface `StreamerContext`
Parameters:
  `clo` - Function to be executed on individual nodes.
  `rdc` - Reducer to reduce results received from remote nodes.
  `nodes` - Optional list of nodes to execute query on, if empty, then all nodes on which this streamer is running will be queried.
Returns:
  Reducer result.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015