Package org.apache.storm.grouping
Class PartialKeyGrouping
java.lang.Object
org.apache.storm.grouping.PartialKeyGrouping
- All Implemented Interfaces:
Serializable,CustomStreamGrouping
A variation on FieldGrouping. This grouping operates on a partitioning of the incoming tuples (like a FieldGrouping),
but it can send Tuples from a given partition to multiple downstream tasks.
Given a total pool of target tasks, this grouping will always send Tuples with a given key to one member of a subset of those tasks. Each key is assigned a subset of tasks. Each tuple is then sent to one task from that subset.
Notes: - the default TaskSelector ensures each task gets as close to a balanced number of Tuples as possible - the default AssignmentCreator hashes the key and produces an assignment of two tasks
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis interface is responsible for choosing a subset of the target tasks to use for a given key.static classA basic implementation of target selection.static classThis implementation of AssignmentCreator chooses two arbitrary tasks.static interfaceThis interface chooses one element from a task assignment to send a specific Tuple to. -
Constructor Summary
ConstructorsConstructorDescriptionPartialKeyGrouping(Fields fields) PartialKeyGrouping(Fields fields, PartialKeyGrouping.AssignmentCreator assignmentCreator) PartialKeyGrouping(Fields fields, PartialKeyGrouping.AssignmentCreator assignmentCreator, PartialKeyGrouping.TargetSelector targetSelector) -
Method Summary
Modifier and TypeMethodDescriptionchooseTasks(int taskId, List<Object> values) This function implements a custom stream grouping.voidprepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) Tells the stream grouping at runtime the tasks in the target bolt.
-
Constructor Details
-
PartialKeyGrouping
public PartialKeyGrouping() -
PartialKeyGrouping
-
PartialKeyGrouping
-
PartialKeyGrouping
public PartialKeyGrouping(Fields fields, PartialKeyGrouping.AssignmentCreator assignmentCreator, PartialKeyGrouping.TargetSelector targetSelector)
-
-
Method Details
-
prepare
public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) Description copied from interface:CustomStreamGroupingTells the stream grouping at runtime the tasks in the target bolt. This information should be used in chooseTasks to determine the target tasks.It also tells the grouping the metadata on the stream this grouping will be used on.
- Specified by:
preparein interfaceCustomStreamGrouping
-
chooseTasks
Description copied from interface:CustomStreamGroupingThis function implements a custom stream grouping. It takes in as input the number of tasks in the target bolt in prepare and returns the tasks to send the tuples to.- Specified by:
chooseTasksin interfaceCustomStreamGroupingvalues- the values to group on
-