本文整理汇总了Java中storm.trident.planner.ProcessorContext类的典型用法代码示例。如果您正苦于以下问题:Java ProcessorContext类的具体用法?Java ProcessorContext怎么用?Java ProcessorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessorContext类属于storm.trident.planner包,在下文中一共展示了ProcessorContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
BatchState state = (BatchState) processorContext.state[_context.getStateIndex()];
if(!state.tuples.isEmpty()) {
List<Object> results = _function.batchRetrieve(_state, state.args);
if(results.size()!=state.tuples.size()) {
throw new RuntimeException("Results size is different than argument size: " + results.size() + " vs " + state.tuples.size());
}
for(int i=0; i<state.tuples.size(); i++) {
TridentTuple tuple = state.tuples.get(i);
Object result = results.get(i);
_collector.setContext(processorContext, tuple);
_function.execute(_projection.create(tuple), result, _collector);
}
}
}
示例2: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
_collector.setContext(processorContext);
Object batchId = processorContext.batchId;
// since this processor type is a committer, this occurs in the commit phase
List<TridentTuple> buffer = (List) processorContext.state[_context.getStateIndex()];
// don't update unless there are tuples
// this helps out with things like global partition persist, where multiple tasks may still
// exist for this processor. Only want the global one to do anything
// this is also a helpful optimization that state implementations don't need to manually do
if(buffer.size() > 0) {
Long txid = null;
// this is to support things like persisting off of drpc stream, which is inherently unreliable
// and won't have a tx attempt
if(batchId instanceof TransactionAttempt) {
txid = ((TransactionAttempt) batchId).getTransactionId();
}
_state.beginCommit(txid);
_updater.updateState(_state, buffer, _collector);
_state.commit(txid);
}
}
示例3: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
BatchState state = (BatchState) processorContext.state[_context.getStateIndex()];
if (!state.tuples.isEmpty()) {
List<Object> results = _function.batchRetrieve(_state, state.args);
if (results.size() != state.tuples.size()) {
throw new RuntimeException("Results size is different than argument size: " + results.size() + " vs " + state.tuples.size());
}
for (int i = 0; i < state.tuples.size(); i++) {
TridentTuple tuple = state.tuples.get(i);
Object result = results.get(i);
_collector.setContext(processorContext, tuple);
_function.execute(_projection.create(tuple), result, _collector);
}
}
}
示例4: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
_collector.setContext(processorContext);
Object batchId = processorContext.batchId;
// since this processor type is a committer, this occurs in the commit phase
List<TridentTuple> buffer = (List) processorContext.state[_context.getStateIndex()];
// don't update unless there are tuples
// this helps out with things like global partition persist, where multiple tasks may still
// exist for this processor. Only want the global one to do anything
// this is also a helpful optimization that state implementations don't need to manually do
if (buffer.size() > 0) {
Long txid = null;
// this is to support things like persisting off of drpc stream, which is inherently unreliable
// and won't have a tx attempt
if (batchId instanceof TransactionAttempt) {
txid = ((TransactionAttempt) batchId).getTransactionId();
}
_state.beginCommit(txid);
_updater.updateState(_state, buffer, _collector);
_state.commit(txid);
}
}
示例5: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
BatchState state = (BatchState) processorContext.state[_context.getStateIndex()];
if(!state.tuples.isEmpty()) {
List<Object> results = _function.batchRetrieve(_state, Collections.unmodifiableList(state.args));
if(results.size()!=state.tuples.size()) {
throw new RuntimeException("Results size is different than argument size: " + results.size() + " vs " + state.tuples.size());
}
for (int i = 0; i < state.tuples.size(); i++) {
TridentTuple tuple = state.tuples.get(i);
Object result = results.get(i);
_collector.setContext(processorContext, tuple);
_function.execute(state.args.get(i), result, _collector);
}
}
}
示例6: execute
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void execute(ProcessorContext processorContext, String streamId, TridentTuple tuple) {
TridentTuple toEmit = _factory.create(tuple);
for(TupleReceiver r: _context.getReceivers()) {
r.execute(processorContext, _context.getOutStreamId(), toEmit);
}
}
示例7: execute
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void execute(ProcessorContext processorContext, String streamId, TridentTuple tuple) {
TridentTuple toEmit = _factory.create(tuple);
for (TupleReceiver r : _context.getReceivers()) {
r.execute(processorContext, _context.getOutStreamId(), toEmit);
}
}
示例8: startBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void startBatch(ProcessorContext processorContext) {
}
示例9: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
}
示例10: startBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void startBatch(ProcessorContext processorContext) {
_collector.setContext(processorContext);
processorContext.state[_context.getStateIndex()] = _reducer.init(_collector);
}
示例11: execute
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void execute(ProcessorContext processorContext, String streamId, TridentTuple tuple) {
_collector.setContext(processorContext);
int i = _streamToIndex.get(streamId);
_reducer.execute(processorContext.state[_context.getStateIndex()], i, _projectionFactories[i].create(tuple), _collector);
}
示例12: finishBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void finishBatch(ProcessorContext processorContext) {
_collector.setContext(processorContext);
_reducer.complete(processorContext.state[_context.getStateIndex()], _collector);
}
示例13: setContext
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
public void setContext(ProcessorContext pc) {
this.context = pc;
}
示例14: startBatch
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void startBatch(ProcessorContext processorContext) {
_collector.setContext(processorContext);
processorContext.state[_context.getStateIndex()] = _agg.init(processorContext.batchId, _collector);
}
示例15: execute
import storm.trident.planner.ProcessorContext; //导入依赖的package包/类
@Override
public void execute(ProcessorContext processorContext, String streamId, TridentTuple tuple) {
_collector.setContext(processorContext);
_agg.aggregate(processorContext.state[_context.getStateIndex()], _projection.create(tuple), _collector);
}