• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GeneralTopologyContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TupleImpl

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public TupleImpl(GeneralTopologyContext context, List<Object> values,
		int taskId, String streamId, MessageId id) {
	this.values = values;
	this.taskId = taskId;
	this.streamId = streamId;
	this.id = id;
	this.context = context;

	String componentId = context.getComponentId(taskId);
	Fields schema = context.getComponentOutputFields(componentId, streamId);
	if (values.size() != schema.size()) {
		throw new IllegalArgumentException(
				"Tuple created with wrong number of fields. " + "Expected "
						+ schema.size() + " fields but got "
						+ values.size() + " fields");
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:18,代码来源:TupleImpl.java


示例2: testFlush

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
@Test
public void testFlush() {
	StreamMerger<Tuple> merger = new StreamMerger<Tuple>(Arrays.asList(new Integer(0), new Integer(1)), 0);
	
	GeneralTopologyContext contextMock = mock(GeneralTopologyContext.class);
	when(contextMock.getComponentOutputFields(anyString(), anyString())).thenReturn(new Fields("ts"));
	
	Tuple t = new TupleImpl(contextMock, new Values(new Long(0)), 0, "");
	merger.addTuple(new Integer(0), t);
	
	Assert.assertNull(merger.getNextTuple());
	
	Tuple t2 = new TupleImpl(contextMock, new Values(new Long(1)), 1, TimestampMerger.FLUSH_STREAM_ID);
	merger.addTuple(new Integer(1), t2);
	
	Assert.assertSame(t, merger.getNextTuple());
	Assert.assertNull(merger.getNextTuple());
}
 
开发者ID:mjsax,项目名称:aeolus,代码行数:19,代码来源:StreamMergerTest.java


示例3: TupleImpl

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public TupleImpl(GeneralTopologyContext context, List<Object> values, int taskId, String streamId, MessageId id) {
    this.values = values;
    this.taskId = taskId;
    this.streamId = streamId;
    this.id = id;
    this.context = context;
    
    String componentId = context.getComponentId(taskId);
    Fields schema = context.getComponentOutputFields(componentId, streamId);
    if(values.size()!=schema.size()) {
        throw new IllegalArgumentException(
                "Tuple created with wrong number of fields. " +
                "Expected " + schema.size() + " fields but got " +
                values.size() + " fields");
    }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:17,代码来源:TupleImpl.java


示例4: TupleImpl

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public TupleImpl(GeneralTopologyContext context, List<Object> values,
                 int taskId, String streamId, MessageId id) {
    this.values = values;
    this.taskId = taskId;
    this.streamId = streamId;
    this.id = id;
    this.context = context;

    String componentId = context.getComponentId(taskId);
    Fields schema = context.getComponentOutputFields(componentId, streamId);
    if (values.size() != schema.size()) {
        throw new IllegalArgumentException(
                "Tuple created with wrong number of fields. " + "Expected "
                        + schema.size() + " fields but got "
                        + values.size() + " fields");
    }
}
 
开发者ID:troyding,项目名称:storm-resa,代码行数:18,代码来源:TupleImpl.java


示例5: KryoTupleDeserializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public KryoTupleDeserializer(final Map conf,
		final GeneralTopologyContext context) {
	_kryo = new KryoValuesDeserializer(conf);
	_context = context;
	_ids = new SerializationFactory.IdDictionary(context.getRawTopology());
	_kryoInput = new Input(1);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:9,代码来源:KryoTupleDeserializer.java


示例6: KryoTupleSerializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public KryoTupleSerializer(final Map conf,
		final GeneralTopologyContext context) {
	_kryo = new KryoValuesSerializer(conf);
	_kryoOut = new Output(2000, 2000000000);
	_ids = new SerializationFactory.IdDictionary(context.getRawTopology());
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:8,代码来源:KryoTupleSerializer.java


示例7: KryoTupleDeserializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public KryoTupleDeserializer(final Map conf,
		final GeneralTopologyContext context) {
	_kryo = new KryoValuesDeserializer(conf);
	_context = context;
	_ids = new SerializationFactory.IdDictionary(context.getRawTopology());
	_kryoInput = new Input(1);
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:8,代码来源:KryoTupleDeserializer.java


示例8: TupleImpl

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public TupleImpl(GeneralTopologyContext context, List<Object> values, int taskId, String streamId, MessageId id) {
    this.values = values;
    this.taskId = taskId;
    this.streamId = streamId;
    this.id = id;
    this.context = context;

    String componentId = context.getComponentId(taskId);
    Fields schema = context.getComponentOutputFields(componentId, streamId);
    if (values.size() != schema.size()) {
        throw new IllegalArgumentException("Tuple created with wrong number of fields. " + "Expected " + schema.size() + " fields but got " + values.size()
                + " fields");
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:15,代码来源:TupleImpl.java


示例9: getGeneralTopologyContext

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public static GeneralTopologyContext getGeneralTopologyContext(String topoName, Map<String, Object> conf) {
    NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
    try {
        Nimbus.Client nimbus = nimbusClient.getClient();
        return getGeneralTopologyContext(nimbus, topoName);
    } finally {
        nimbusClient.close();
    }
}
 
开发者ID:ADSC-Resa,项目名称:resa,代码行数:10,代码来源:TopologyHelper.java


示例10: generateTestTuple

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
private Tuple generateTestTuple(Object key, Object message) {
    TopologyBuilder builder = new TopologyBuilder();
    GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
        @Override
        public Fields getComponentOutputFields(String componentId, String streamId) {
            return new Fields("key", "message");
        }
    };
    return new TupleImpl(topologyContext, new Values(key, message), 1, "");
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:11,代码来源:KafkaBoltTest.java


示例11: testSocketBolt

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
@Test
public void testSocketBolt() throws Exception {
_socketBolt = new SocketBolt("localhost", 1111);

HashMap<String, Object> stormConf = new HashMap<String, Object>(0);
MemoryOutputCollector collector = new MemoryOutputCollector();
OutputCollector outputCollector = new OutputCollector(collector);
	
_socketBolt.prepare(stormConf, null, outputCollector);

int taskId = 1;
Map<Integer, String> taskToComponent = new HashMap<Integer, String>(1);
taskToComponent.put(taskId, "ComponentId");

String streamId = Utils.DEFAULT_STREAM_ID;
HashMap<String, Fields> fields = new HashMap<String, Fields>(1);
fields.put(streamId, new Fields("output"));
Map<String, Map<String, Fields>> componentToStreamToFields = new HashMap<String, Map<String, Fields>>(1);
componentToStreamToFields.put("ComponentId", fields);
GeneralTopologyContext context = new GeneralTopologyContext(null, null, taskToComponent, null, componentToStreamToFields, "stormId");

List<Object> values = new Values("one");
TupleImpl tuple = new TupleImpl(context, values, taskId, streamId);

_socketBolt.execute(tuple);
_socketBolt.execute(tuple);
_socketBolt.execute(tuple);
Thread.sleep(1000);
_socketBolt.cleanup();

List<Object> processedValues = collector.getValues();
assertNotNull("", processedValues);
assertEquals("", 3, processedValues.size());
assertEquals("", values, processedValues.get(0));
assertEquals("", values, processedValues.get(1));
assertEquals("", values, processedValues.get(2));

}
 
开发者ID:danigiri,项目名称:storm-sockets,代码行数:39,代码来源:SocketBoltTest.java


示例12: KryoTupleDeserializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public KryoTupleDeserializer(final Map conf,
    final GeneralTopologyContext context) {
_kryo = new KryoValuesDeserializer(conf);
_context = context;
_ids = new SerializationFactory.IdDictionary(context.getRawTopology());
_kryoInput = new Input(1);
   }
 
开发者ID:troyding,项目名称:storm-resa,代码行数:8,代码来源:KryoTupleDeserializer.java


示例13: WorkerDeserializeRunnable

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public WorkerDeserializeRunnable(List<TaskShutdownDameon> shutdownTasks,
                                 Map stormConf,
                                 GeneralTopologyContext topologyContext,
                                 int startRunTaskIndex,
                                 int threadIndex) {
    this.shutdownTasks = shutdownTasks;
    this.threadIndex = threadIndex;
    this.startRunTaskIndex = startRunTaskIndex;
    this.deserializer = new KryoTupleDeserializer(stormConf, topologyContext, topologyContext.getRawTopology());
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:11,代码来源:WorkerDeserializeRunnable.java


示例14: WorkerSerializeRunnable

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public WorkerSerializeRunnable(List<TaskShutdownDameon> shutdownTasks, Map stormConf,
                               GeneralTopologyContext topologyContext, int startRunTaskIndex, int threadIndex) {
    this.shutdownTasks = shutdownTasks;
    this.threadIndex = threadIndex;
    this.startRunTaskIndex = startRunTaskIndex;
    this.serializer = new KryoTupleSerializer(stormConf, topologyContext.getRawTopology());
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:8,代码来源:WorkerSerializeRunnable.java


示例15: KryoTupleDeserializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public KryoTupleDeserializer(final Map conf, final GeneralTopologyContext context, final StormTopology topology) {
    _kryo = new KryoValuesDeserializer(conf);
    _context = context;
    _ids = new SerializationFactory.IdDictionary(topology);
    _kryoInput = new Input(1);
    _ackerNum = JStormUtils.parseInt(conf.get(Config.TOPOLOGY_ACKER_EXECUTORS), 0);
    _isTransactionTuple = JStormUtils.parseBoolean(conf.get(ConfigExtension.TRANSACTION_TOPOLOGY), false);
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:9,代码来源:KryoTupleDeserializer.java


示例16: TupleImpl

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public TupleImpl(GeneralTopologyContext context, List<Object> values, int taskId, String streamId, MessageId id) {
    this.values = values;
    this.taskId = taskId;
    this.streamId = streamId;
    this.id = id;
    this.context = context;

    /*
    String componentId = context.getComponentId(taskId);
    Fields schema = context.getComponentOutputFields(componentId, streamId);
    if (values.size() != schema.size()) {
        throw new IllegalArgumentException("Tuple created with wrong number of fields. " + "Expected " + schema.size() + " fields but got " + values.size()
                + " fields");
    }*/
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:16,代码来源:TupleImpl.java


示例17: TupleImplExt

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public TupleImplExt(GeneralTopologyContext context, List<Object> values,
		int taskId, String streamId) {
	super(context, values, taskId, streamId);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:5,代码来源:TupleImplExt.java


示例18: KryoTupleSerializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public KryoTupleSerializer(final Map conf,
		final GeneralTopologyContext context) {
	_kryo = new KryoValuesSerializer(conf);
	_kryoOut = new Output(2000, 2000000000);
	_ids = new SerializationFactory.IdDictionary(context.getRawTopology());
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:7,代码来源:KryoTupleSerializer.java


示例19: testExecute

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
@Test
public void testExecute() throws Exception {
	final LinkedList<String> expectedResult = new LinkedList<String>();
	final LinkedList<String> result = new LinkedList<String>();
	final LinkedList<Tuple> input = new LinkedList<Tuple>();
	
	
	Config conf = new Config();
	String dummyDir = "dummyDir";
	String dummyFile = "dummyFile";
	
	String usedDir = ".";
	String usedFile = "result.dat";
	switch(this.r.nextInt(4)) {
	case 0:
		conf.put(TestFileOutputBolt.OUTPUT_DIR_NAME, dummyDir);
		usedDir = dummyDir;
		break;
	case 1:
		conf.put(TestFileOutputBolt.OUTPUT_FILE_NAME, dummyFile);
		usedFile = dummyFile;
		break;
	case 2:
		conf.put(TestFileOutputBolt.OUTPUT_DIR_NAME, dummyDir);
		conf.put(TestFileOutputBolt.OUTPUT_FILE_NAME, dummyFile);
		usedDir = dummyDir;
		usedFile = dummyFile;
		break;
	default:
	}
	
	FileWriter fileWriterMock = PowerMockito.mock(FileWriter.class);
	PowerMockito.whenNew(FileWriter.class).withArguments(usedDir + File.separator + usedFile)
		.thenReturn(fileWriterMock);
	
	BufferedWriter dummyWriter = new BufferedWriter(fileWriterMock) {
		@Override
		public void write(String s) {
			result.add(s);
		}
	};
	PowerMockito.whenNew(BufferedWriter.class).withArguments(fileWriterMock).thenReturn(dummyWriter);
	
	
	TestFileOutputBolt bolt = new TestFileOutputBolt();
	TestOutputCollector collector = new TestOutputCollector();
	bolt.prepare(conf, null, new OutputCollector(collector));
	
	GeneralTopologyContext context = mock(GeneralTopologyContext.class);
	when(context.getComponentOutputFields(anyString(), anyString())).thenReturn(new Fields("dummy"));
	when(context.getComponentId(anyInt())).thenReturn("componentID");
	
	final int numberOfLines = 20;
	for(int i = 0; i < numberOfLines; ++i) {
		TupleImpl t = new TupleImpl(context, new Values(new Integer(this.r.nextInt())), 0, null);
		input.add(t);
		expectedResult.add(t.toString());
		bolt.execute(t);
	}
	
	Assert.assertEquals(expectedResult, result);
	Assert.assertEquals(input, collector.acked);
}
 
开发者ID:mjsax,项目名称:aeolus,代码行数:64,代码来源:FileOutputBoltTest.java


示例20: KryoTupleDeserializer

import backtype.storm.task.GeneralTopologyContext; //导入依赖的package包/类
public KryoTupleDeserializer(final Map conf, final GeneralTopologyContext context) {
    _kryo = new KryoValuesDeserializer(conf);
    _context = context;
    _ids = new SerializationFactory.IdDictionary(context.getRawTopology());
    _kryoInput = new Input(1);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:7,代码来源:KryoTupleDeserializer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QueryResult类代码示例发布时间:2022-05-22
下一篇:
Java EXTTextureFilterAnisotropic类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap