use of org.apache.heron.api.bolt.OutputCollector in project heron by twitter.
the class JoinOperatorTest method getJoinOperator.
@SuppressWarnings({ "rawtypes", "unchecked" })
private JoinOperator<String, KeyValue<String, String>, KeyValue<String, String>, String> getJoinOperator(JoinType type) {
SerializableFunction<KeyValue<String, String>, String> f = x -> x == null ? "null" : x.getKey();
JoinOperator<String, KeyValue<String, String>, KeyValue<String, String>, String> joinOperator = new JoinOperator(type, "leftComponent", "rightComponent", f, f, (SerializableBiFunction<KeyValue<String, String>, KeyValue<String, String>, String>) (o, o2) -> (o == null ? "null" : o.getValue()) + (o2 == null ? "null" : o2.getValue()));
joinOperator.prepare(new Config(), PowerMockito.mock(TopologyContext.class), new OutputCollector(new IOutputCollector() {
@Override
public void reportError(Throwable error) {
}
@Override
public List<Integer> emit(String streamId, Collection<Tuple> anchors, List<Object> tuple) {
emittedTuples.addAll(tuple);
return null;
}
@Override
public void emitDirect(int taskId, String streamId, Collection<Tuple> anchors, List<Object> tuple) {
}
@Override
public void ack(Tuple input) {
}
@Override
public void fail(Tuple input) {
}
}));
return joinOperator;
}
use of org.apache.heron.api.bolt.OutputCollector in project heron by twitter.
the class KeyByOperatorTest method getKeyByOperator.
@SuppressWarnings({ "rawtypes", "unchecked" })
private KeyByOperator<String, String, Integer> getKeyByOperator() {
KeyByOperator<String, String, Integer> keyByOperator = new KeyByOperator<String, String, Integer>(x -> (Integer.valueOf(x) % 2 == 0) ? "even" : "odd", x -> Integer.valueOf(x));
keyByOperator.prepare(new Config(), PowerMockito.mock(TopologyContext.class), new OutputCollector(new IOutputCollector() {
@Override
public void reportError(Throwable error) {
}
@Override
public List<Integer> emit(String streamId, Collection<Tuple> anchors, List<Object> tuple) {
emittedTuples.addAll(tuple);
return null;
}
@Override
public void emitDirect(int taskId, String streamId, Collection<Tuple> anchors, List<Object> tuple) {
}
@Override
public void ack(Tuple input) {
}
@Override
public void fail(Tuple input) {
}
}));
return keyByOperator;
}
use of org.apache.heron.api.bolt.OutputCollector in project incubator-heron by apache.
the class IntegrationTestBolt method prepare.
@Override
public void prepare(Map<String, Object> map, TopologyContext context, OutputCollector outputCollector) {
update(context);
this.collector = new OutputCollector(new IntegrationTestBoltCollector(outputCollector));
this.delegateBolt.prepare(map, new TestTopologyContext(context), collector);
}
use of org.apache.heron.api.bolt.OutputCollector in project incubator-heron by apache.
the class BoltInstance method init.
@SuppressWarnings("unchecked")
@Override
public void init(State<Serializable, Serializable> state) {
TopologyContextImpl topologyContext = helper.getTopologyContext();
// Initialize the GlobalMetrics
GlobalMetrics.init(topologyContext, systemConfig.getHeronMetricsExportInterval());
boltMetrics.registerMetrics(topologyContext);
// Initialize the instanceState if the topology is stateful and bolt is a stateful component
if (isTopologyStateful && bolt instanceof IStatefulComponent) {
this.instanceState = state;
((IStatefulComponent<Serializable, Serializable>) bolt).initState(instanceState);
if (spillState) {
if (FileUtils.isDirectoryExists(spillStateLocation)) {
FileUtils.cleanDir(spillStateLocation);
} else {
FileUtils.createDirectory(spillStateLocation);
}
}
}
// Delegate
bolt.prepare(topologyContext.getTopologyConfig(), topologyContext, new OutputCollector(collector));
// Invoke user-defined prepare task hook
topologyContext.invokeHookPrepare();
// Init the CustomStreamGrouping
helper.prepareForCustomStreamGrouping();
}
use of org.apache.heron.api.bolt.OutputCollector in project incubator-heron by apache.
the class JoinOperatorTest method getJoinOperator.
@SuppressWarnings({ "rawtypes", "unchecked" })
private JoinOperator<String, KeyValue<String, String>, KeyValue<String, String>, String> getJoinOperator(JoinType type) {
SerializableFunction<KeyValue<String, String>, String> f = x -> x == null ? "null" : x.getKey();
JoinOperator<String, KeyValue<String, String>, KeyValue<String, String>, String> joinOperator = new JoinOperator(type, "leftComponent", "rightComponent", f, f, (SerializableBiFunction<KeyValue<String, String>, KeyValue<String, String>, String>) (o, o2) -> (o == null ? "null" : o.getValue()) + (o2 == null ? "null" : o2.getValue()));
joinOperator.prepare(new Config(), PowerMockito.mock(TopologyContext.class), new OutputCollector(new IOutputCollector() {
@Override
public void reportError(Throwable error) {
}
@Override
public List<Integer> emit(String streamId, Collection<Tuple> anchors, List<Object> tuple) {
emittedTuples.addAll(tuple);
return null;
}
@Override
public void emitDirect(int taskId, String streamId, Collection<Tuple> anchors, List<Object> tuple) {
}
@Override
public void ack(Tuple input) {
}
@Override
public void fail(Tuple input) {
}
}));
return joinOperator;
}
Aggregations