本文整理汇总了Java中org.apache.storm.generated.GlobalStreamId类的典型用法代码示例。如果您正苦于以下问题:Java GlobalStreamId类的具体用法?Java GlobalStreamId怎么用?Java GlobalStreamId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GlobalStreamId类属于org.apache.storm.generated包,在下文中一共展示了GlobalStreamId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void execute(Tuple tuple) {
List<Object> id = tuple.select(_idFields);
GlobalStreamId streamId = new GlobalStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId());
if (!_pending.containsKey(id)) {
_pending.put(id, new HashMap<GlobalStreamId, Tuple>());
}
Map<GlobalStreamId, Tuple> parts = _pending.get(id);
if (parts.containsKey(streamId))
throw new RuntimeException("Received same side of single join twice");
parts.put(streamId, tuple);
if (parts.size() == _numSources) {
_pending.remove(id);
List<Object> joinResult = new ArrayList<Object>();
for (String outField : _outFields) {
GlobalStreamId loc = _fieldLocations.get(outField);
joinResult.add(parts.get(loc).getValueByField(outField));
}
_collector.emit(new ArrayList<Tuple>(parts.values()), joinResult);
for (Tuple part : parts.values()) {
_collector.ack(part);
}
}
}
示例2: getTerminalUserBoltNames
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
public static Set<String> getTerminalUserBoltNames(StormTopology topology) {
Set<String> terminalBolts = new HashSet<>();
Set<String> inputs = new HashSet<>();
for (Map.Entry<String, Bolt> entry : topology.get_bolts().entrySet()) {
String name = entry.getKey();
Set<GlobalStreamId> inputsForBolt = entry.getValue().get_common().get_inputs().keySet();
if (!isSystemComponent(name)) {
for (GlobalStreamId streamId : inputsForBolt) {
inputs.add(streamId.get_componentId());
}
}
}
for (String boltName : topology.get_bolts().keySet()) {
if (!isSystemComponent(boltName) && !inputs.contains(boltName)) {
terminalBolts.add(boltName);
}
}
return terminalBolts;
}
示例3: getAdjacencyMap
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
public static Map<String, Set<String>> getAdjacencyMap(StormTopology topology,
boolean removeSystemComponent)
throws Exception {
Map<String, Set<String>> adjacencyMap = new HashMap<>();
for (Map.Entry<String, Bolt> entry : topology.get_bolts().entrySet()) {
String boltName = entry.getKey();
Map<GlobalStreamId, Grouping> inputs = entry.getValue().get_common().get_inputs();
for (Map.Entry<GlobalStreamId, Grouping> input : inputs.entrySet()) {
String inputComponentId = input.getKey().get_componentId();
Set<String> components = adjacencyMap.containsKey(inputComponentId)
? adjacencyMap.get(inputComponentId) : new HashSet<String>();
components.add(boltName);
components = removeSystemComponent ? removeSystemComponents(components)
: components;
if (!removeSystemComponent || !isSystemComponent(inputComponentId)) {
adjacencyMap.put(inputComponentId, components);
}
}
}
return adjacencyMap;
}
示例4: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param map
* @param tc
* @param oc
*/
@Override
public void prepare(@SuppressWarnings("rawtypes") Map map, TopologyContext tc, OutputCollector oc) {
this.collector = oc;
Configuration cepConfig = new Configuration();
if (this.eventTypes == null || (this.objectStatements == null && this.statements == null)) {
throw new FailedException("Event types cannot be null and at least one type of statement has to be not null");
}
for (Map.Entry<GlobalStreamId, Grouping> a : tc.getThisSources().entrySet()) {
Fields f = tc.getComponentOutputFields(a.getKey());
if (!this.eventTypes.keySet().containsAll(f.toList())) {
throw new FailedException("Event types and fields from source streams do not match: Event Types="
+ Arrays.toString(this.eventTypes.keySet().toArray())
+ " Stream Fields=" + Arrays.toString(f.toList().toArray()));
}
cepConfig.addEventType(a.getKey().get_componentId() + "_" + a.getKey().get_streamId(), this.eventTypes);
}
this.epService = EPServiceProviderManager.getDefaultProvider(cepConfig);
this.epService.initialize();
if (!processStatemens()) {
throw new FailedException("At least one type of statement has to be not empty");
}
}
示例5: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) {
choices = new ArrayList<>(targetTasks.size());
allTasks = new ArrayList<>(targetTasks.size());
for (Integer i : targetTasks) {
choices.add(Arrays.asList(i));
allTasks.add(i);
}
}
示例6: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
_fieldLocations = new HashMap<String, GlobalStreamId>();
_collector = collector;
int timeout = ((Number) conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)).intValue();
_pending = new TimeCacheMap<List<Object>, Map<GlobalStreamId, Tuple>>(timeout, new ExpireCallback());
_numSources = context.getThisSources().size();
Set<String> idFields = null;
for (GlobalStreamId source : context.getThisSources().keySet()) {
Fields fields = context.getComponentOutputFields(source.get_componentId(), source.get_streamId());
Set<String> setFields = new HashSet<String>(fields.toList());
if (idFields == null)
idFields = setFields;
else
idFields.retainAll(setFields);
for (String outfield : _outFields) {
for (String sourcefield : fields) {
if (outfield.equals(sourcefield)) {
_fieldLocations.put(outfield, source);
}
}
}
}
_idFields = new Fields(new ArrayList<String>(idFields));
if (_fieldLocations.size() != _outFields.size()) {
throw new RuntimeException("Cannot find all outfields among sources");
}
}
示例7: getBoltStatLongValueFromMap
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
public static Long getBoltStatLongValueFromMap(
Map<String, Map<GlobalStreamId, Long>> map, String statName) {
if (map != null) {
Long statValue = null;
Map<GlobalStreamId, Long> intermediateMap = map.get(statName);
Set<GlobalStreamId> key = intermediateMap.keySet();
if (key.size() > 0) {
Iterator<GlobalStreamId> itr = key.iterator();
statValue = intermediateMap.get(itr.next());
}
return statValue;
}
return 0L;
}
示例8: TwoFlinkStreamsMerger
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
public TwoFlinkStreamsMerger(GlobalStreamId streamId1, Fields schema1, GlobalStreamId streamId2,
Fields schema2) {
this.inputStreamId1 = streamId1.get_streamId();
this.inputComponentId1 = streamId1.get_componentId();
this.inputSchema1 = schema1;
this.inputStreamId2 = streamId2.get_streamId();
this.inputComponentId2 = streamId2.get_componentId();
this.inputSchema2 = schema2;
}
示例9: open
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void open() throws Exception {
super.open();
this.flinkCollector = new TimestampedCollector<>(this.output);
GlobalJobParameters config = getExecutionConfig().getGlobalJobParameters();
StormConfig stormConfig = new StormConfig();
if (config != null) {
if (config instanceof StormConfig) {
stormConfig = (StormConfig) config;
} else {
stormConfig.putAll(config.toMap());
}
}
this.topologyContext = WrapperSetupHelper.createTopologyContext(
getRuntimeContext(), this.bolt, this.name, this.stormTopology, stormConfig);
final OutputCollector stormCollector = new OutputCollector(new BoltCollector<OUT>(
this.numberOfAttributes, this.topologyContext.getThisTaskId(), this.flinkCollector));
if (this.stormTopology != null) {
Map<GlobalStreamId, Grouping> inputs = this.topologyContext.getThisSources();
for (GlobalStreamId inputStream : inputs.keySet()) {
for (Integer tid : this.topologyContext.getComponentTasks(inputStream
.get_componentId())) {
this.inputComponentIds.put(tid, inputStream.get_componentId());
this.inputStreamIds.put(tid, inputStream.get_streamId());
this.inputSchemas.put(tid,
this.topologyContext.getComponentOutputFields(inputStream));
}
}
}
this.bolt.prepare(stormConfig, this.topologyContext, stormCollector);
}
示例10: testGetSourceGlobalStreamid
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Test
public void testGetSourceGlobalStreamid() {
GlobalStreamId globalStreamid = new StormTuple<>(null, null, -1, "streamId", "componentID",
null).getSourceGlobalStreamid();
Assert.assertEquals("streamId", globalStreamid.get_streamId());
Assert.assertEquals("componentID", globalStreamid.get_componentId());
}
示例11: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void prepare(
WorkerTopologyContext context,
GlobalStreamId stream,
List<Integer> targetTasks) {
this.taskIds = targetTasks;
}
示例12: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void prepare(com.twitter.heron.api.topology.TopologyContext context,
String component, String streamId,
List<Integer> targetTasks) {
TopologyContext c = new TopologyContext(context);
GlobalStreamId g = new GlobalStreamId(component, streamId);
delegate.prepare(c, g, targetTasks);
}
示例13: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void prepare(WorkerTopologyContext context, GlobalStreamId stream,
List<Integer> targetTasks) {
numTasks = targetTasks.size();
partitioner = new URLPartitioner();
if (StringUtils.isNotBlank(partitionMode)) {
Map<String, String> conf = new HashMap<>();
conf.put(Constants.PARTITION_MODEParamName, partitionMode);
partitioner.configure(conf);
}
}
示例14: expire
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
@Override
public void expire(List<Object> id, Map<GlobalStreamId, Tuple> tuples) {
for (Tuple tuple : tuples.values()) {
_collector.fail(tuple);
}
}
示例15: prepare
import org.apache.storm.generated.GlobalStreamId; //导入依赖的package包/类
public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks)
{
tasks = targetTasks.size();
}