当前位置: 首页>>代码示例>>Java>>正文


Java RotatingTransactionalState类代码示例

本文整理汇总了Java中storm.trident.topology.state.RotatingTransactionalState的典型用法代码示例。如果您正苦于以下问题:Java RotatingTransactionalState类的具体用法?Java RotatingTransactionalState怎么用?Java RotatingTransactionalState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RotatingTransactionalState类属于storm.trident.topology.state包,在下文中一共展示了RotatingTransactionalState类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: emitBatch

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void emitBatch(final TransactionAttempt tx, final Object coordinatorMeta,
        final TridentCollector collector) {
    if(_savedCoordinatorMeta == null || !_savedCoordinatorMeta.equals(coordinatorMeta)) {
        List<ISpoutPartition> partitions = _emitter.getOrderedPartitions(coordinatorMeta);
        _partitionStates.clear();
        List<ISpoutPartition> myPartitions = new ArrayList();
        for(int i=_index; i < partitions.size(); i+=_numTasks) {
            ISpoutPartition p = partitions.get(i);
            String id = p.getId();
            myPartitions.add(p);
            _partitionStates.put(id, new EmitterPartitionState(new RotatingTransactionalState(_state, id), p));
        }
        _emitter.refreshPartitions(myPartitions);
        _savedCoordinatorMeta = coordinatorMeta;
    }
    for(EmitterPartitionState s: _partitionStates.values()) {
        RotatingTransactionalState state = s.rotatingState;
        final ISpoutPartition partition = s.partition;
        Object meta = state.getStateOrCreate(tx.getTransactionId(),
                new RotatingTransactionalState.StateInitializer() {
            @Override
            public Object init(long txid, Object lastState) {
                return _emitter.emitPartitionBatchNew(tx, collector, partition, lastState);
            }
        });
        // it's null if one of:
        //   a) a later transaction batch was emitted before this, so we should skip this batch
        //   b) if didn't exist and was created (in which case the StateInitializer was invoked and 
        //      it was emitted
        if(meta!=null) {
            _emitter.emitPartitionBatch(tx, collector, partition, meta);
        }
    }            
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:36,代码来源:PartitionedTridentSpoutExecutor.java

示例2: commit

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void commit(TransactionAttempt attempt) {
    // this code here handles a case where a previous commit failed, and the partitions
    // changed since the last commit. This clears out any state for the removed partitions
    // for this txid.
    // we make sure only a single task ever does this. we're also guaranteed that
    // it's impossible for there to be another writer to the directory for that partition
    // because only a single commit can be happening at once. this is because in order for 
    // another attempt of the batch to commit, the batch phase must have succeeded in between.
    // hence, all tasks for the prior commit must have finished committing (whether successfully or not)
    if(_changedMeta && _index==0) {
        Set<String> validIds = new HashSet<String>();
        for(ISpoutPartition p: (List<ISpoutPartition>) _emitter.getOrderedPartitions(_savedCoordinatorMeta)) {
            validIds.add(p.getId());
        }
        for(String existingPartition: _state.list("")) {
            if(!validIds.contains(existingPartition)) {
                RotatingTransactionalState s = new RotatingTransactionalState(_state, existingPartition);
                s.removeState(attempt.getTransactionId());
            }
        }
        _changedMeta = false;
    }            
    
    Long txid = attempt.getTransactionId();
    Map<String, Object> metas = _cachedMetas.remove(txid);
    for(String partitionId: metas.keySet()) {
        Object meta = metas.get(partitionId);
        _partitionStates.get(partitionId).rotatingState.overrideState(txid, meta);
    }
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:32,代码来源:OpaquePartitionedTridentSpoutExecutor.java

示例3: emitBatch

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void emitBatch(final TransactionAttempt tx, final Object coordinatorMeta, final TridentCollector collector) {
    if (_savedCoordinatorMeta == null || !_savedCoordinatorMeta.equals(coordinatorMeta)) {
        List<ISpoutPartition> partitions = _emitter.getOrderedPartitions(coordinatorMeta);
        _partitionStates.clear();
        List<ISpoutPartition> myPartitions = new ArrayList();
        for (int i = _index; i < partitions.size(); i += _numTasks) {
            ISpoutPartition p = partitions.get(i);
            String id = p.getId();
            myPartitions.add(p);
            _partitionStates.put(id, new EmitterPartitionState(new RotatingTransactionalState(_state, id), p));
        }
        _emitter.refreshPartitions(myPartitions);
        _savedCoordinatorMeta = coordinatorMeta;
    }
    for (EmitterPartitionState s : _partitionStates.values()) {
        RotatingTransactionalState state = s.rotatingState;
        final ISpoutPartition partition = s.partition;
        Object meta = state.getStateOrCreate(tx.getTransactionId(), new RotatingTransactionalState.StateInitializer() {
            @Override
            public Object init(long txid, Object lastState) {
                return _emitter.emitPartitionBatchNew(tx, collector, partition, lastState);
            }
        });
        // it's null if one of:
        // a) a later transaction batch was emitted before this, so we should skip this batch
        // b) if didn't exist and was created (in which case the StateInitializer was invoked and
        // it was emitted
        if (meta != null) {
            _emitter.emitPartitionBatch(tx, collector, partition, meta);
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:34,代码来源:PartitionedTridentSpoutExecutor.java

示例4: commit

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void commit(TransactionAttempt attempt) {
    // this code here handles a case where a previous commit failed, and the partitions
    // changed since the last commit. This clears out any state for the removed partitions
    // for this txid.
    // we make sure only a single task ever does this. we're also guaranteed that
    // it's impossible for there to be another writer to the directory for that partition
    // because only a single commit can be happening at once. this is because in order for
    // another attempt of the batch to commit, the batch phase must have succeeded in between.
    // hence, all tasks for the prior commit must have finished committing (whether successfully or not)
    if (_changedMeta && _index == 0) {
        Set<String> validIds = new HashSet<String>();
        for (ISpoutPartition p : (List<ISpoutPartition>) _emitter.getOrderedPartitions(_savedCoordinatorMeta)) {
            validIds.add(p.getId());
        }
        for (String existingPartition : _state.list("")) {
            if (!validIds.contains(existingPartition)) {
                RotatingTransactionalState s = new RotatingTransactionalState(_state, existingPartition);
                s.removeState(attempt.getTransactionId());
            }
        }
        _changedMeta = false;
    }

    Long txid = attempt.getTransactionId();
    Map<String, Object> metas = _cachedMetas.remove(txid);
    for (String partitionId : metas.keySet()) {
        Object meta = metas.get(partitionId);
        _partitionStates.get(partitionId).rotatingState.overrideState(txid, meta);
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:32,代码来源:OpaquePartitionedTridentSpoutExecutor.java

示例5: emitBatch

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void emitBatch(final TransactionAttempt tx, final Integer coordinatorMeta,
        final TridentCollector collector) {
    if(_savedCoordinatorMeta == null || !_savedCoordinatorMeta.equals(coordinatorMeta)) {
        List<ISpoutPartition> partitions = _emitter.getOrderedPartitions(coordinatorMeta);
        _partitionStates.clear();
        List<ISpoutPartition> myPartitions = new ArrayList<>();
        for(int i=_index; i < partitions.size(); i+=_numTasks) {
            ISpoutPartition p = partitions.get(i);
            String id = p.getId();
            myPartitions.add(p);
            _partitionStates.put(id, new EmitterPartitionState(new RotatingTransactionalState(_state, id), p));
        }
        _emitter.refreshPartitions(myPartitions);
        _savedCoordinatorMeta = coordinatorMeta;
    }
    for(EmitterPartitionState s: _partitionStates.values()) {
        RotatingTransactionalState state = s.rotatingState;
        final ISpoutPartition partition = s.partition;
        Object meta = state.getStateOrCreate(tx.getTransactionId(),
                new RotatingTransactionalState.StateInitializer() {
            @Override
            public Object init(long txid, Object lastState) {
                return _emitter.emitPartitionBatchNew(tx, collector, partition, lastState);
            }
        });
        // it's null if one of:
        // a) a later transaction batch was emitted before this, so we should skip this batch
        // b) if didn't exist and was created (in which case the StateInitializer was invoked and
        // it was emitted
        if (meta != null) {
            _emitter.emitPartitionBatch(tx, collector, partition, meta);
        }
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:36,代码来源:PartitionedTridentSpoutExecutor.java

示例6: commit

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void commit(TransactionAttempt attempt) {
    // this code here handles a case where a previous commit failed, and the partitions
    // changed since the last commit. This clears out any state for the removed partitions
    // for this txid.
    // we make sure only a single task ever does this. we're also guaranteed that
    // it's impossible for there to be another writer to the directory for that partition
    // because only a single commit can be happening at once. this is because in order for 
    // another attempt of the batch to commit, the batch phase must have succeeded in between.
    // hence, all tasks for the prior commit must have finished committing (whether successfully or not)
    if(_changedMeta && _index==0) {
        Set<String> validIds = new HashSet<>();
        for(ISpoutPartition p: _emitter.getOrderedPartitions(_savedCoordinatorMeta)) {
            validIds.add(p.getId());
        }
        for(String existingPartition: _state.list("")) {
            if(!validIds.contains(existingPartition)) {
                RotatingTransactionalState s = new RotatingTransactionalState(_state, existingPartition);
                s.removeState(attempt.getTransactionId());
            }
        }
        _changedMeta = false;
    }            
    
    Long txid = attempt.getTransactionId();
    Map<String, Object> metas = _cachedMetas.remove(txid);
    for(Entry<String, Object> entry: metas.entrySet()) {
        _partitionStates.get(entry.getKey()).rotatingState.overrideState(txid, entry.getValue());
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:31,代码来源:OpaquePartitionedTridentSpoutExecutor.java

示例7: EmitterPartitionState

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
public EmitterPartitionState(RotatingTransactionalState s, ISpoutPartition p) {
    rotatingState = s;
    partition = p;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:5,代码来源:PartitionedTridentSpoutExecutor.java

示例8: prepare

import storm.trident.topology.state.RotatingTransactionalState; //导入依赖的package包/类
@Override
public void prepare(Map conf, TopologyContext context) {
    _coord = _spout.getCoordinator(_id, conf, context);
    _underlyingState = TransactionalState.newCoordinatorState(conf, _id);
    _state = new RotatingTransactionalState(_underlyingState, META_DIR);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:7,代码来源:TridentSpoutCoordinator.java


注:本文中的storm.trident.topology.state.RotatingTransactionalState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。