use of org.apache.heron.streamlet.IStreamletWindowOperator 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;
}
Aggregations