Skip to content
Albert Bifet edited this page Oct 18, 2013 · 2 revisions

Processing Item is a hidden physical unit of the topology and is just a wrapper of Processor. It is used internally, and it is not accessible from the API.

Advanced

It does not contain any logic but connects the Processor to the other processors in the topology. There are two types of Processing Items.

  1. Simple Processing Item (PI)
  2. Entrance Processing Item (EntrancePI)

1. Simple Processing Item (PI)

Once a Processor is wrapped in a PI, it becomes an executable component of the topology. All physical topology units are created with the help of a TopologyBuilder. Following code snippet shows the creation of a Processing Item.

builder.initTopology("Parma Topology");
Processor samplerProcessor = new Sampler();
ProcessingItem samplerPI = builder.createPI(samplerProcessor,3);

createPI() method of TopologyBuilder is used to create a PI. Its first argument is the instance of a Processor which needs to be wrapped-in. Its second argument is the parallelism hint. It tells the underlying platforms how many parallel instances of this PI should be created on different nodes.

2. Entrance Processing Item (EntrancePI)

Entrance Processing Item is different from a PI in only one way. It can generate its own stream. It is mostly used as the source of a topology. It connects to external sources, pulls data and provides it to the topology in the form of streams. All physical topology units are created with the help of a TopologyBuilder. Following code snippet shows the creation of an Entrance Processing Item.

builder.initTopology("Parma Topology");
Processor sourceProcessor = new Source();
TopologyStarter topologyStarter = new FpmTopologyStarter(sourceProcessor);
EntranceProcessingItem sourcePi = builder.createEntrancePi(sourceProcessor, topologyStarter);

The creation of an Entrance PI is also different from a simple PI. createEntrancePi method of Topologybuilder requires an instance of TopologyStarter. TopologyStarter has been explained in its respective section.

3. Note

The Processor which is wrapped in an EntrancePI should contain a user-defined method which should return a new event/message each time it is called. This method is called in TopologyStarter to get new message/tuples from external sources. This is also explained in the Topology Starter section.