本文整理汇总了Java中backtype.storm.spout.ISpoutOutputCollector类的典型用法代码示例。如果您正苦于以下问题:Java ISpoutOutputCollector类的具体用法?Java ISpoutOutputCollector怎么用?Java ISpoutOutputCollector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ISpoutOutputCollector类属于backtype.storm.spout包,在下文中一共展示了ISpoutOutputCollector类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBatchEmit
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testBatchEmit() throws IllegalArgumentException, IllegalAccessException {
TopologyContext context = mock(TopologyContext.class);
ISpoutOutputCollector col = mock(ISpoutOutputCollector.class);
BatchSpoutOutputCollector collector = new BatchSpoutOutputCollector(context, col, 0);
SpoutBatchCollectorImpl collectorImpl = new SpoutBatchCollectorImpl(collector, context, 0);
String streamId = new String();
Batch batch = mock(Batch.class);
Object messageId = mock(Object.class);
collector.batchEmitted = false;
collectorImpl.doEmit(streamId, null, batch, messageId);
verify(col).emit(streamId, (List)batch, messageId);
Assert.assertTrue(collector.batchEmitted);
}
示例2: batchEmitDirect
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void batchEmitDirect() throws IllegalArgumentException, IllegalAccessException {
TopologyContext context = mock(TopologyContext.class);
ISpoutOutputCollector col = mock(ISpoutOutputCollector.class);
BatchSpoutOutputCollector collector = new BatchSpoutOutputCollector(context, col, 0);
SpoutBatchCollectorImpl collectorImpl = new SpoutBatchCollectorImpl(collector, context, 0);
int taskId = 0;
String streamId = new String();
Batch batch = mock(Batch.class);
Object messageId = mock(Object.class);
collector.batchEmitted = false;
collectorImpl.doEmitDirect(taskId, streamId, null, batch, messageId);
verify(col).emitDirect(taskId, streamId, (List)batch, messageId);
Assert.assertTrue(collector.batchEmitted);
}
示例3: getOutputCollector
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
public ISpoutOutputCollector getOutputCollector() {
return collector;
}
示例4: newInstance
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
public static SpoutOutputCollector newInstance(ISpoutOutputCollector obj) {
return new SpoutOutputCollector(new AutoIDCollector(obj));
}
示例5: AutoIDCollector
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
public AutoIDCollector (ISpoutOutputCollector obj) {
super();
proxied = obj;
_rand = new Random();
}
示例6: invoke
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// log.info(method.getName());
// if (args != null) {
// log.info(Arrays.asList(args));
// }
if (method.getName().equals("open")) {
// FIXME: Check on emit and determine if we need to intercept and
// provide a default id mechanism.
// Pull any override values.
Map conf = (Map) args[0];
if (conf.containsKey(CONF_OVERRIDE)) {
resource_count = Integer.parseInt((String) conf.get(CONF_OVERRIDE));
}
// Replace the collector
args[2] = AutoIDCollector.newInstance((ISpoutOutputCollector) args[2]);
log.info("Configuring " + resource_count + " oustanding resources for consumption.");
// Initialize our resource semaphore.
resources = new Semaphore(resource_count);
} else if (method.getName().equals("nextTuple")) {
// Attempt to acquire some resources.
if (!resources.tryAcquire()) {
// No free resources, bounce.
return null;
}
// log.info("ACQUIRED");
} else if (method.getName().equals("ack") || method.getName().equals("fail")) {
// log.info("RELEASE");
// Release a resource.
resources.release();
if (args[0] != null && args[0] instanceof AutoID) {
args[0] = null;
}
}
return method.invoke(proxied, args);
}
示例7: FakeSpoutOutputCollector
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
public FakeSpoutOutputCollector(ISpoutOutputCollector delegate) {
super(delegate);
}
示例8: BatchSpoutOutputCollector
import backtype.storm.spout.ISpoutOutputCollector; //导入依赖的package包/类
/**
* Instantiates a new {@link BatchSpoutOutputCollector} for the given batch size.
*
* @param context
* The current runtime environment.
* @param collector
* The original collector object.
* @param batchSizes
* The batch sizes for each output stream.
*/
public BatchSpoutOutputCollector(TopologyContext context, ISpoutOutputCollector collector,
Map<String, Integer> batchSizes) {
super(collector);
this.collector = collector;
this.batcher = new SpoutBatchCollectorImpl(this, context, batchSizes);
}