Search in sources :

Example 11 with BatchId

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);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BatchId(com.alibaba.jstorm.batch.BatchId) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 12 with BatchId

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));
    }
}
Also used : BatchId(com.alibaba.jstorm.batch.BatchId) Values(backtype.storm.tuple.Values)

Aggregations

BatchId (com.alibaba.jstorm.batch.BatchId)12 FailedException (backtype.storm.topology.FailedException)3 Values (backtype.storm.tuple.Values)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 ReportedFailedException (backtype.storm.topology.ReportedFailedException)2 IPostCommit (com.alibaba.jstorm.batch.IPostCommit)1 IPrepareCommit (com.alibaba.jstorm.batch.IPrepareCommit)1 BatchStatus (com.alibaba.jstorm.batch.util.BatchStatus)1