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;
}
Aggregations