use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class SimpleBolt method execute.
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
BatchId id = (BatchId) input.getValue(0);
Long value = input.getLong(1);
AtomicLong counter = counters.get(id);
if (counter == null) {
counter = new AtomicLong(0);
counters.put(id, counter);
}
counter.addAndGet(value);
}
use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class SimpleBatchTestSpout method execute.
@Override
public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
BatchId batchId = (BatchId) tuple.getValue(0);
if (batchId.getId() > 100) {
JStormUtils.sleepMs(1000);
return;
}
for (int i = 0; i < BATCH_SIZE; i++) {
long value = random.nextInt(100);
basicOutputCollector.emit(new Values(batchId, value));
}
}
Aggregations