org.apache.ignite.streamer.router

## Class StreamerAffinityEventRouter

- java.lang.Object
- - org.apache.ignite.streamer.StreamerEventRouterAdapter
  - - org.apache.ignite.streamer.router.StreamerAffinityEventRouter

All Implemented Interfaces:
  StreamerEventRouter

    public class StreamerAffinityEventRouter
    extends StreamerEventRouterAdapter

Router used to colocate identical streamer events or events with identical affinity key on the same node. Such collocation is often required to perform computations on multiple events together, for example, find number of occurrences of a word in some text. In this case you would collocate identical words together to make sure that you can update their counts.

# Affinity Key

Affinity key for collocation of event together on the same node is specified via `StreamerAffinityEventRouter.AffinityEvent.affinityKey()` method. If event does not implement `StreamerAffinityEventRouter.AffinityEvent` interface, then event itself will be used to determine affinity.

### Nested Class Summary

Nested Classes
`static interface` `StreamerAffinityEventRouter.AffinityEvent` All events that implement this interface will be routed based on key affinity.

### Field Summary

Fields
`static int` `REPLICA_CNT`

### Constructor Summary

Constructors
Constructor and Description
`StreamerAffinityEventRouter()`

### Method Summary

Methods
`<T> ClusterNode` `route(StreamerContext ctx, String stageName, T evt)` Selects a node for given event that should be processed by a stage with given name.

### Methods inherited from class org.apache.ignite.streamer.StreamerEventRouterAdapter

`route`

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

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

### Field Detail

#### REPLICA_CNT

    public static final int REPLICA_CNT

See Also:
  Constant Field Values

### Constructor Detail

#### StreamerAffinityEventRouter

    public StreamerAffinityEventRouter()

### Method Detail

#### route

    public <T> ClusterNode route(StreamerContext ctx,
                        String stageName,
                        T evt)

Selects a node for given event that should be processed by a stage with given name.

Parameters:
  `ctx` - Streamer context.
  `stageName` - Stage name.
  `evt` - Event to route.
Returns:
  Node to route to. If this method returns `null` then the whole pipeline execution will be terminated. All running and ongoing stages for pipeline execution will be cancelled.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

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