Search in sources :

Example 1 with BatchOutputCollectorImpl

use of backtype.storm.coordination.BatchOutputCollectorImpl in project storm by nathanmarz.

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<Integer>();
            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 : BatchOutputCollector(backtype.storm.coordination.BatchOutputCollector) IOutputCollector(backtype.storm.task.IOutputCollector) OutputCollector(backtype.storm.task.OutputCollector) HashMap(java.util.HashMap) BatchOutputCollectorImpl(backtype.storm.coordination.BatchOutputCollectorImpl) RotatingMap(backtype.storm.utils.RotatingMap)

Example 2 with BatchOutputCollectorImpl

use of backtype.storm.coordination.BatchOutputCollectorImpl in project jstorm by alibaba.

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(backtype.storm.coordination.BatchOutputCollectorImpl)

Example 3 with BatchOutputCollectorImpl

use of backtype.storm.coordination.BatchOutputCollectorImpl in project jstorm by alibaba.

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(new OutputCollector(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(backtype.storm.task.OutputCollector) BatchOutputCollector(backtype.storm.coordination.BatchOutputCollector) IOutputCollector(backtype.storm.task.IOutputCollector) BatchOutputCollectorImpl(backtype.storm.coordination.BatchOutputCollectorImpl)

Example 4 with BatchOutputCollectorImpl

use of backtype.storm.coordination.BatchOutputCollectorImpl in project storm by nathanmarz.

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(backtype.storm.coordination.BatchOutputCollectorImpl)

Aggregations

BatchOutputCollectorImpl (backtype.storm.coordination.BatchOutputCollectorImpl)4 BatchOutputCollector (backtype.storm.coordination.BatchOutputCollector)2 IOutputCollector (backtype.storm.task.IOutputCollector)2 OutputCollector (backtype.storm.task.OutputCollector)2 RotatingMap (backtype.storm.utils.RotatingMap)1 HashMap (java.util.HashMap)1