本文整理汇总了Java中storm.trident.topology.state.RotatingTransactionalState.getStateOrCreate方法的典型用法代码示例。如果您正苦于以下问题:Java RotatingTransactionalState.getStateOrCreate方法的具体用法?Java RotatingTransactionalState.getStateOrCreate怎么用?Java RotatingTransactionalState.getStateOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storm.trident.topology.state.RotatingTransactionalState
的用法示例。
在下文中一共展示了RotatingTransactionalState.getStateOrCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例2: 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);
}
}
}
示例3: 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);
}
}
}