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