Search in sources :

Example 1 with RotatingMap

use of backtype.storm.utils.RotatingMap 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)

Aggregations

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