use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class SimpleSpout method execute.
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
BatchId batchId = (BatchId) input.getValue(0);
for (int i = 0; i < batchSize; i++) {
long value = rand.nextInt(10);
collector.emit(new Values(batchId, value));
}
}
use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class BatchSpoutMsgId method mkInstance.
public static BatchSpoutMsgId mkInstance() {
BatchId batchId = BatchId.mkInstance();
BatchStatus batchStatus = BatchStatus.COMPUTING;
return new BatchSpoutMsgId(batchId, batchStatus);
}
use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class SimpleBatchTestBolt method execute.
@Override
public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
BatchId id = (BatchId) tuple.getValue(0);
Long value = tuple.getLong(1);
System.out.println("SimpleBatchTestBolt #execute id = " + id + " value = " + value);
}
use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class CountBolt method execute.
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
BatchId id = (BatchId) input.getValue(0);
AtomicLong counter = counters.get(id);
if (counter == null) {
counter = new AtomicLong(0);
counters.put(id, counter);
}
counter.incrementAndGet();
}
use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.
the class DBBolt method execute.
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
BatchId batchId = (BatchId) input.getValue(0);
if (input.getSourceComponent().equals(CountBolt.COUNT_BOLT_NAME)) {
AtomicLong counter = counters.get(batchId);
if (counter == null) {
counter = new AtomicLong(0);
counters.put(batchId, counter);
}
long value = input.getLong(1);
counter.addAndGet(value);
} else if (input.getSourceComponent().equals(CountBolt.SUM_BOLT_NAME)) {
AtomicLong sum = sums.get(batchId);
if (sum == null) {
sum = new AtomicLong(0);
sums.put(batchId, sum);
}
long value = input.getLong(1);
sum.addAndGet(value);
} else {
LOG.warn("Unknow source type");
}
}
Aggregations