Search in sources :

Example 1 with ITransactionBoltExecutor

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

the class TransactionTopologyBuilder method setBolt.

public BoltDeclarer setBolt(String id, ITransactionBoltExecutor bolt, Number parallelism_hint) {
    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, parallelism_hint);
    _bolts.put(id, boltExecutor);
    BoltDeclarer ret = new TransactionBoltDeclarer(id);
    ret.addConfiguration(TransactionCommon.TRANSACTION_STATEFUL_BOLT, isStatefulBolt);
    return ret;
}
Also used : IRichBolt(backtype.storm.topology.IRichBolt) TransactionBolt(com.alibaba.jstorm.transactional.bolt.TransactionBolt) TransactionStatefulBolt(com.alibaba.jstorm.transactional.bolt.TransactionStatefulBolt) ITransactionBoltExecutor(com.alibaba.jstorm.transactional.bolt.ITransactionBoltExecutor) BoltDeclarer(backtype.storm.topology.BoltDeclarer) ITransactionStatefulBoltExecutor(com.alibaba.jstorm.transactional.bolt.ITransactionStatefulBoltExecutor)

Example 2 with ITransactionBoltExecutor

use of com.alibaba.jstorm.transactional.bolt.ITransactionBoltExecutor 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)2 IRichBolt (backtype.storm.topology.IRichBolt)2 ITransactionBoltExecutor (com.alibaba.jstorm.transactional.bolt.ITransactionBoltExecutor)2 ITransactionStatefulBoltExecutor (com.alibaba.jstorm.transactional.bolt.ITransactionStatefulBoltExecutor)2 TransactionBolt (com.alibaba.jstorm.transactional.bolt.TransactionBolt)2 TransactionStatefulBolt (com.alibaba.jstorm.transactional.bolt.TransactionStatefulBolt)2 AckTransactionBolt (com.alibaba.jstorm.transactional.bolt.AckTransactionBolt)1 KvStatefulBoltExecutor (com.alibaba.jstorm.transactional.bolt.KvStatefulBoltExecutor)1