/*
* #!
* %
* Copyright (C) 2014 - 2016 Humboldt-Universität zu Berlin
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #_
*/
package de.hub.cs.dbis.aeolus.testUtils;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.IRichBolt;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Tuple;
/**
* {@link ResultBolt} accumulates all received tuples and emits no tuples. {@link ResultBolt} acknowledges all received
* tuples.
*
* @author mjsax
*/
public class ResultBolt implements IRichBolt {
private final static long serialVersionUID = 7985730498618052164L;
private final static Logger logger = LoggerFactory.getLogger(ResultBolt.class);
private OutputCollector collector;
public LinkedList<List<Object>> receivedTuples = new LinkedList<List<Object>>();
@Override
public void prepare(@SuppressWarnings("rawtypes") Map stormConf, TopologyContext context, OutputCollector collector) {
this.collector = collector;
}
@Override
public void execute(Tuple input) {
logger.trace("Buffering result tuple: {}", input);
this.receivedTuples.add(input.getValues());
this.collector.ack(input);
}
@Override
public void cleanup() {
// nothing to do
}
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
// nothing to do
}
@Override
public Map<String, Object> getComponentConfiguration() {
return null;
}
}