Search in sources :

Example 1 with IStreamletBasicOperator

use of org.apache.heron.streamlet.IStreamletBasicOperator in project heron by twitter.

the class CustomStreamlet method doBuild.

/**
 * Connect this streamlet to TopologyBuilder.
 * @param bldr The TopologyBuilder for the topology
 * @param stageNames The existing stage names
 * @return True if successful
 */
@Override
public boolean doBuild(TopologyBuilder bldr, Set<String> stageNames) {
    // Create and set bolt
    BoltDeclarer declarer;
    if (operator instanceof IStreamletBasicOperator) {
        setDefaultNameIfNone(StreamletNamePrefix.CUSTOM, stageNames);
        IStreamletBasicOperator<R, T> op = (IStreamletBasicOperator<R, T>) operator;
        bldr.setBolt(getName(), op, getNumPartitions()).grouping(parent.getName(), parent.getStreamId(), grouper);
    } else if (operator instanceof IStreamletRichOperator) {
        setDefaultNameIfNone(StreamletNamePrefix.CUSTOM_BASIC, stageNames);
        IStreamletRichOperator<R, T> op = (IStreamletRichOperator<R, T>) operator;
        bldr.setBolt(getName(), op, getNumPartitions()).grouping(parent.getName(), parent.getStreamId(), grouper);
    } else if (operator instanceof IStreamletWindowOperator) {
        setDefaultNameIfNone(StreamletNamePrefix.CUSTOM_WINDOW, stageNames);
        IStreamletWindowOperator<R, T> op = (IStreamletWindowOperator<R, T>) operator;
        bldr.setBolt(getName(), op, getNumPartitions()).grouping(parent.getName(), parent.getStreamId(), grouper);
    } else {
        throw new RuntimeException("Unhandled operator class is found!");
    }
    return true;
}
Also used : IStreamletRichOperator(org.apache.heron.streamlet.IStreamletRichOperator) BoltDeclarer(org.apache.heron.api.topology.BoltDeclarer) IStreamletBasicOperator(org.apache.heron.streamlet.IStreamletBasicOperator) IStreamletWindowOperator(org.apache.heron.streamlet.IStreamletWindowOperator)

Aggregations

BoltDeclarer (org.apache.heron.api.topology.BoltDeclarer)1 IStreamletBasicOperator (org.apache.heron.streamlet.IStreamletBasicOperator)1 IStreamletRichOperator (org.apache.heron.streamlet.IStreamletRichOperator)1 IStreamletWindowOperator (org.apache.heron.streamlet.IStreamletWindowOperator)1