Search in sources :

Example 6 with BatchId

use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.

the class TransformBolt method execute.

@Override
public void execute(Tuple input, BasicOutputCollector collector) {
    BatchId id = (BatchId) input.getValue(0);
    long value = rand.nextInt(100);
    collector.emit(new Values(id, value));
}
Also used : BatchId(com.alibaba.jstorm.batch.BatchId) Values(backtype.storm.tuple.Values)

Example 7 with BatchId

use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.

the class CoordinatedBolt method handlePostCommit.

public void handlePostCommit(Tuple tuple) {
    basicCollector.setContext(tuple);
    try {
        BatchId id = (BatchId) tuple.getValue(0);
        ((IPostCommit) delegate).postCommit(id, basicCollector);
    } catch (Exception e) {
        LOG.info("Failed to do postCommit,", e);
    }
    collector.ack(tuple);
}
Also used : IPostCommit(com.alibaba.jstorm.batch.IPostCommit) BatchId(com.alibaba.jstorm.batch.BatchId) FailedException(backtype.storm.topology.FailedException) ReportedFailedException(backtype.storm.topology.ReportedFailedException)

Example 8 with BatchId

use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.

the class CoordinatedBolt method handlePrepareCommit.

public void handlePrepareCommit(Tuple tuple) {
    basicCollector.setContext(tuple);
    try {
        BatchId id = (BatchId) tuple.getValue(0);
        ((IPrepareCommit) delegate).prepareCommit(id, basicCollector);
        collector.ack(tuple);
    } catch (FailedException e) {
        if (e instanceof ReportedFailedException) {
            collector.reportError(e);
        }
        collector.fail(tuple);
    }
}
Also used : IPrepareCommit(com.alibaba.jstorm.batch.IPrepareCommit) ReportedFailedException(backtype.storm.topology.ReportedFailedException) FailedException(backtype.storm.topology.FailedException) ReportedFailedException(backtype.storm.topology.ReportedFailedException) BatchId(com.alibaba.jstorm.batch.BatchId)

Example 9 with BatchId

use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.

the class BatchMetaSpout method execute.

@Override
public void execute(Tuple input, BasicOutputCollector collector) {
    String streamId = input.getSourceStreamId();
    if (streamId.equals(BatchMetaRebalance.REBALANCE_STREAM_ID)) {
        try {
            metaClient.rebalanceMqList();
        } catch (Exception e) {
            LOG.warn("Failed to do rebalance operation", e);
        }
    } else {
        BatchId batchId = (BatchId) input.getValue(0);
        emitBatch(batchId, collector);
    }
}
Also used : BatchId(com.alibaba.jstorm.batch.BatchId) FailedException(backtype.storm.topology.FailedException)

Example 10 with BatchId

use of com.alibaba.jstorm.batch.BatchId in project jstorm by alibaba.

the class SimpleBolt method revert.

@Override
public void revert(BatchId id, byte[] commitResult) {
    LOG.info("Receive BatchId " + id);
    BatchId failedId = (BatchId) Utils.javaDeserialize(commitResult);
    if (!failedId.equals(id)) {
        LOG.info("Deserialized error  " + id);
    }
}
Also used : BatchId(com.alibaba.jstorm.batch.BatchId)

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