Search in sources :

Example 1 with KvStatefulBoltExecutor

use of com.alibaba.jstorm.transactional.bolt.KvStatefulBoltExecutor in project jstorm by alibaba.

the class TransactionTopologyBuilder method setBolt.

@Override
public BoltDeclarer setBolt(String id, IRichBolt bolt, Number parallelismHint) throws IllegalArgumentException {
    upToDownstreamComponentsMap.put(id, new HashSet<String>());
    validateUnusedId(id);
    IRichBolt boltExecutor;
    boolean isStatefulBolt = false;
    if (bolt instanceof ITransactionStatefulBoltExecutor) {
        isStatefulBolt = true;
        boltExecutor = new TransactionStatefulBolt((ITransactionStatefulBoltExecutor) bolt);
    } else {
        boltExecutor = new TransactionBolt((ITransactionBoltExecutor) bolt);
    }
    initCommon(id, boltExecutor, parallelismHint);
    _bolts.put(id, boltExecutor);
    BoltDeclarer ret = new TransactionBoltDeclarer(id);
    ret.addConfiguration(TransactionCommon.TRANSACTION_STATEFUL_BOLT, isStatefulBolt);
    // If using KvState bolt, the corresponding init operater would be registered here.
    if (bolt instanceof KvStatefulBoltExecutor) {
        ConfigExtension.registerTransactionTaskStateInitOp(TopologyBuilder.getStormConf(), id, KeyRangeStateTaskInit.class);
    }
    return ret;
}
Also used : IRichBolt(backtype.storm.topology.IRichBolt) AckTransactionBolt(com.alibaba.jstorm.transactional.bolt.AckTransactionBolt) TransactionBolt(com.alibaba.jstorm.transactional.bolt.TransactionBolt) TransactionStatefulBolt(com.alibaba.jstorm.transactional.bolt.TransactionStatefulBolt) KvStatefulBoltExecutor(com.alibaba.jstorm.transactional.bolt.KvStatefulBoltExecutor) ITransactionBoltExecutor(com.alibaba.jstorm.transactional.bolt.ITransactionBoltExecutor) BoltDeclarer(backtype.storm.topology.BoltDeclarer) ITransactionStatefulBoltExecutor(com.alibaba.jstorm.transactional.bolt.ITransactionStatefulBoltExecutor)

Aggregations

BoltDeclarer (backtype.storm.topology.BoltDeclarer)1 IRichBolt (backtype.storm.topology.IRichBolt)1 AckTransactionBolt (com.alibaba.jstorm.transactional.bolt.AckTransactionBolt)1 ITransactionBoltExecutor (com.alibaba.jstorm.transactional.bolt.ITransactionBoltExecutor)1 ITransactionStatefulBoltExecutor (com.alibaba.jstorm.transactional.bolt.ITransactionStatefulBoltExecutor)1 KvStatefulBoltExecutor (com.alibaba.jstorm.transactional.bolt.KvStatefulBoltExecutor)1 TransactionBolt (com.alibaba.jstorm.transactional.bolt.TransactionBolt)1 TransactionStatefulBolt (com.alibaba.jstorm.transactional.bolt.TransactionStatefulBolt)1