Skip to content
Albert Bifet edited this page Oct 17, 2013 · 1 revision

Task is similar to a job in Hadoop. Task is an execution entity. A topology must be defined inside a task. SAMOA can only execute classes that implement Task interface.

import samoa.core.TopologyStarter;
import samoa.topology.ComponentFactory;
import samoa.topology.Topology;

/**
 * Task interface, the mother of all SAMOA tasks!
 */
public interface Task {

	/**
	 * Initialize this SAMOA task, 
	 * i.e. create and connect ProcesingItems and Streams
	 * and initialize the topology
	 */
	public void init();	
	
	/**
	 * Return the final topology object to be executed in the cluster
	 * @return topology object to be submitted to be executed in the cluster
	 */
	public Topology getTopology();
	
	/**
	 * Return the entrance processor to start SAMOA topology
	 * The logic to start the topology should be implemented here
	 * @return entrance processor to start the topology
	 */
	public TopologyStarter getTopologyStarter();
	
	/**
	 * Sets the factory.
	 * TODO: propose to hide factory from task, 
	 * i.e. Task will only see TopologyBuilder, 
	 * and factory creation will be handled by TopologyBuilder
	 *
	 * @param factory the new factory
	 */
	public void setFactory(ComponentFactory factory) ;
	
}