forked from YahooArchive/samoa
-
Notifications
You must be signed in to change notification settings - Fork 1
Topology Starter
Albert Bifet edited this page Oct 17, 2013
·
1 revision
To start a topology, users must create a class which should implement TopologyStarter
interface. Following is the interface code.
package samoa.core;
/**
* Topology stater interface
*/
public interface TopologyStarter extends java.io.Serializable{
/**
* Start the topology.
*/
void start();
}
In void start()
method, users should call a function of there EntrancePI
which brings next message/tuple from the external source, in a loop. Following is an example of a class implementing TopologyStarter
interface.
package samoa.fpm;
import samoa.core.Processor;
import samoa.core.TopologyStarter;
import samoa.fpm.processors.StreamSourceP;
public class MyTopologyStarter implements TopologyStarter {
private StreamSourceProcessor streamSource;
public MyTopologyStarter(StreamSourceProcessor s)
{
this.streamSource = s;
}
@Override
public void start() {
while(true)
streamSource.nextTuple();
}
}
SAMOA calls the start()
method of the Topology Starter class once in the beginning to start the topology. In the above code snippet, nextTuple()
method of an EntranceProcessingItem
is called in a loop which continuously brings external tuples/messages to the topology for processing.