Search in sources :

Example 1 with BatchOutputCollectorImpl

use of org.apache.storm.coordination.BatchOutputCollectorImpl in project storm by apache.

the class TransactionalSpoutBatchExecutor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
    _collector = new BatchOutputCollectorImpl(collector);
    _emitter = _spout.getEmitter(conf, context);
}
Also used : BatchOutputCollectorImpl(org.apache.storm.coordination.BatchOutputCollectorImpl)

Example 2 with BatchOutputCollectorImpl

use of org.apache.storm.coordination.BatchOutputCollectorImpl in project storm by apache.

the class TridentBoltExecutor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
    _messageTimeoutMs = context.maxTopologyMessageTimeout() * 1000L;
    _lastRotate = System.currentTimeMillis();
    _batches = new RotatingMap<>(2);
    _context = context;
    _collector = collector;
    _coordCollector = new CoordinatedOutputCollector(collector);
    _coordOutputCollector = new BatchOutputCollectorImpl(new OutputCollector(_coordCollector));
    _coordConditions = (Map) context.getExecutorData("__coordConditions");
    if (_coordConditions == null) {
        _coordConditions = new HashMap<>();
        for (String batchGroup : _coordSpecs.keySet()) {
            CoordSpec spec = _coordSpecs.get(batchGroup);
            CoordCondition cond = new CoordCondition();
            cond.commitStream = spec.commitStream;
            cond.expectedTaskReports = 0;
            for (String comp : spec.coords.keySet()) {
                CoordType ct = spec.coords.get(comp);
                if (ct.equals(CoordType.single())) {
                    cond.expectedTaskReports += 1;
                } else {
                    cond.expectedTaskReports += context.getComponentTasks(comp).size();
                }
            }
            cond.targetTasks = new HashSet<>();
            for (String component : Utils.get(context.getThisTargets(), COORD_STREAM(batchGroup), new HashMap<String, Grouping>()).keySet()) {
                cond.targetTasks.addAll(context.getComponentTasks(component));
            }
            _coordConditions.put(batchGroup, cond);
        }
        context.setExecutorData("_coordConditions", _coordConditions);
    }
    _bolt.prepare(conf, context, _coordOutputCollector);
}
Also used : OutputCollector(org.apache.storm.task.OutputCollector) IOutputCollector(org.apache.storm.task.IOutputCollector) BatchOutputCollector(org.apache.storm.coordination.BatchOutputCollector) HashMap(java.util.HashMap) BatchOutputCollectorImpl(org.apache.storm.coordination.BatchOutputCollectorImpl)

Aggregations

BatchOutputCollectorImpl (org.apache.storm.coordination.BatchOutputCollectorImpl)2 HashMap (java.util.HashMap)1 BatchOutputCollector (org.apache.storm.coordination.BatchOutputCollector)1 IOutputCollector (org.apache.storm.task.IOutputCollector)1 OutputCollector (org.apache.storm.task.OutputCollector)1