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


Java IRichSpout类代码示例

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


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

示例1: testRunExecuteFixedNumber

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testRunExecuteFixedNumber() throws Exception {
	final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
	declarer.declare(new Fields("dummy"));
	PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments()
			.thenReturn(declarer);

	final StreamingRuntimeContext taskContext = mock(StreamingRuntimeContext.class);
	when(taskContext.getExecutionConfig()).thenReturn(mock(ExecutionConfig.class));
	when(taskContext.getTaskName()).thenReturn("name");

	final IRichSpout spout = mock(IRichSpout.class);
	final int numberOfCalls = this.r.nextInt(50);
	final SpoutWrapper<?> spoutWrapper = new SpoutWrapper<Object>(spout,
			numberOfCalls);
	spoutWrapper.setRuntimeContext(taskContext);

	spoutWrapper.run(mock(SourceContext.class));
	verify(spout, times(numberOfCalls)).nextTuple();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:SpoutWrapperTest.java

示例2: testCancel

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@Test
public void testCancel() throws Exception {
	final int numberOfCalls = 5 + this.r.nextInt(5);

	final StreamingRuntimeContext taskContext = mock(StreamingRuntimeContext.class);
	when(taskContext.getExecutionConfig()).thenReturn(mock(ExecutionConfig.class));
	when(taskContext.getTaskName()).thenReturn("name");

	final IRichSpout spout = new FiniteTestSpout(numberOfCalls);

	final SpoutWrapper<Tuple1<Integer>> spoutWrapper = new SpoutWrapper<Tuple1<Integer>>(spout);
	spoutWrapper.setRuntimeContext(taskContext);

	spoutWrapper.cancel();
	final TestContext collector = new TestContext();
	spoutWrapper.run(collector);

	Assert.assertEquals(new LinkedList<Tuple1<Integer>>(), collector.result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:SpoutWrapperTest.java

示例3: testRawType

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testRawType() throws Exception {
	IComponent boltOrSpout;

	if (this.r.nextBoolean()) {
		boltOrSpout = mock(IRichSpout.class);
	} else {
		boltOrSpout = mock(IRichBolt.class);
	}

	final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
	declarer.declare(new Fields("dummy1", "dummy2"));
	PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);

	WrapperSetupHelper.getNumberOfAttributes(boltOrSpout,
			new HashSet<String>(singleton(Utils.DEFAULT_STREAM_ID)));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:WrapperSetupHelperTest.java

示例4: testToManyAttributes

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testToManyAttributes() throws Exception {
	IComponent boltOrSpout;

	if (this.r.nextBoolean()) {
		boltOrSpout = mock(IRichSpout.class);
	} else {
		boltOrSpout = mock(IRichBolt.class);
	}

	final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
	final String[] schema = new String[26];
	for (int i = 0; i < schema.length; ++i) {
		schema[i] = "a" + i;
	}
	declarer.declare(new Fields(schema));
	PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);

	WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, null);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:WrapperSetupHelperTest.java

示例5: testMethodCalls

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@Test
public void testMethodCalls() {
	Map<String, Object> compConfig = new HashMap<String, Object>();

	IRichSpout spoutMock = mock(IRichSpout.class);
	when(spoutMock.getComponentConfiguration()).thenReturn(compConfig);

	Map<?, ?> conf = mock(Map.class);
	TopologyContext context = mock(TopologyContext.class);
	Object msgId = mock(Object.class);
	OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);

	NullTerminatingSpout spout = new NullTerminatingSpout(spoutMock);

	spout.open(conf, context, null);
	spout.close();
	spout.activate();
	spout.deactivate();
	spout.ack(msgId);
	spout.fail(msgId);
	spout.declareOutputFields(declarer);
	Map<String, Object> c = spoutMock.getComponentConfiguration();

	verify(spoutMock).open(same(conf), same(context), any(SpoutOutputCollector.class));
	verify(spoutMock).close();
	verify(spoutMock).activate();
	verify(spoutMock).deactivate();
	verify(spoutMock).ack(same(msgId));
	verify(spoutMock).fail(same(msgId));
	verify(spoutMock).declareOutputFields(same(declarer));
	Assert.assertSame(compConfig, c);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:NullTerminatingSpoutTest.java

示例6: testClose

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@Test
public void testClose() throws Exception {
	final IRichSpout spout = mock(IRichSpout.class);
	final SpoutWrapper<Tuple1<Integer>> spoutWrapper = new SpoutWrapper<Tuple1<Integer>>(spout);

	spoutWrapper.close();

	verify(spout).close();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:SpoutWrapperTest.java

示例7: testEmptyDeclarerBolt

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
@Test
public void testEmptyDeclarerBolt() {
	IComponent boltOrSpout;

	if (this.r.nextBoolean()) {
		boltOrSpout = mock(IRichSpout.class);
	} else {
		boltOrSpout = mock(IRichBolt.class);
	}

	Assert.assertEquals(new HashMap<String, Integer>(),
			WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, null));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:WrapperSetupHelperTest.java

示例8: testTupleTypes

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
private void testTupleTypes(final int numberOfAttributes) throws Exception {
	String[] schema;
	if (numberOfAttributes == -1) {
		schema = new String[1];
	} else {
		schema = new String[numberOfAttributes];
	}
	for (int i = 0; i < schema.length; ++i) {
		schema[i] = "a" + i;
	}

	IComponent boltOrSpout;
	if (this.r.nextBoolean()) {
		boltOrSpout = mock(IRichSpout.class);
	} else {
		boltOrSpout = mock(IRichBolt.class);
	}

	final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
	declarer.declare(new Fields(schema));
	PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);

	HashMap<String, Integer> attributes = new HashMap<String, Integer>();
	attributes.put(Utils.DEFAULT_STREAM_ID, numberOfAttributes);

	Assert.assertEquals(attributes, WrapperSetupHelper.getNumberOfAttributes(
			boltOrSpout,
			numberOfAttributes == -1 ? new HashSet<String>(singleton(Utils.DEFAULT_STREAM_ID)) : null));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:30,代码来源:WrapperSetupHelperTest.java

示例9: createSpouts

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
private void createSpouts()
    throws StreamingException
{
    List<? extends IRichOperator> sources = getInputStreams();
    checkInputStreams(sources);
    for (IRichOperator input : sources)
    {
        IRichSpout spout = ComponentCreator.createSpout(input);
        builder.setSpout(input.getOperatorId(), spout, input.getParallelNumber());
    }
}
 
开发者ID:HuaweiBigData,项目名称:StreamCQL,代码行数:12,代码来源:StormApplication.java

示例10: create

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
/**
 * 创建storm Spout
 */
public static IRichSpout create(IRichOperator operator)
{
    StormSpout spout = new StormSpout();
    spout.setOperator(operator);
    return spout;
}
 
开发者ID:HuaweiBigData,项目名称:StreamCQL,代码行数:10,代码来源:CommonSpoutCreator.java

示例11: buildSpouts

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
protected void buildSpouts(EcoExecutionContext executionContext,
                           TopologyBuilder builder,
                           ObjectBuilder objectBuilder)
    throws ClassNotFoundException, InstantiationException, IllegalAccessException,
    NoSuchFieldException, InvocationTargetException {
  EcoTopologyDefinition topologyDefinition = executionContext.getTopologyDefinition();

  for (ObjectDefinition def: topologyDefinition.getSpouts()) {
    Object obj = objectBuilder.buildObject(def, executionContext);
    builder.setSpout(def.getId(), (IRichSpout) obj, def.getParallelism());
    executionContext.addSpout(def.getId(), obj);
  }
}
 
开发者ID:twitter,项目名称:heron,代码行数:14,代码来源:SpoutBuilder.java

示例12: TopologyModule

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
public TopologyModule(ThresholdingConfiguration threshConfig, Config stormConfig,
    IRichSpout metricSpout, IRichSpout eventSpout) {
  this(threshConfig);
  this.stormConfig = stormConfig;
  this.metricSpout = metricSpout;
  this.eventSpout = eventSpout;
}
 
开发者ID:openstack,项目名称:monasca-thresh,代码行数:8,代码来源:TopologyModule.java

示例13: createUrlGeneratorSpout

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
protected IRichSpout createUrlGeneratorSpout(ServiceProvider serviceProvider) {
    return new UrlGeneratorSpout(serviceProvider);
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:4,代码来源:CrawlerTopology.java

示例14: open

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
public static <T extends IRichSpout> T open(Map config, T spout, TopologyContext context, ISpoutOutputCollector emitter) {
    spout.open(config, context, new SpoutOutputCollector(emitter));
    return spout;
}
 
开发者ID:yahoo,项目名称:bullet-storm,代码行数:5,代码来源:ComponentUtils.java

示例15: NullTerminatingSpout

import org.apache.storm.topology.IRichSpout; //导入依赖的package包/类
public NullTerminatingSpout(IRichSpout spout) {
	this.spout = spout;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:4,代码来源:NullTerminatingSpout.java


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