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


Java Tuple.getString方法代码示例

本文整理汇总了Java中org.apache.storm.tuple.Tuple.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.getString方法的具体用法?Java Tuple.getString怎么用?Java Tuple.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.storm.tuple.Tuple的用法示例。


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

示例1: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple input) {
    String request = input.getString(0);
    try {
        Message message = MAPPER.readValue(request, Message.class);
        if (message instanceof CommandMessage) {
            Values values = new Values(Utils.MAPPER.writeValueAsString(new InfoMessage(healthCheck,
                    System.currentTimeMillis(), message.getCorrelationId(), Destination.NORTHBOUND)));
            collector.emit(Topic.HEALTH_CHECK, input, values);
        }
    } catch (IOException exception) {
        logger.error("Could not deserialize message: ", request, exception);
    } finally {
        collector.ack(input);
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:17,代码来源:HealthCheckBolt.java

示例2: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
    final String data = tuple.getString(0);
    LOGGER.debug("Processing datapoint", data);
    try {
        Datapoint datapoint = MAPPER.readValue(data, Datapoint.class);
        if (isUpdateRequired(datapoint)) {
            addDatapoint(datapoint);

            List<Object> stream = Stream.of(datapoint.getMetric(), datapoint.getTime(), datapoint.getValue(),
                    datapoint.getTags())
                    .collect(Collectors.toList());

            LOGGER.debug("emit: " + stream);
            collector.emit(stream);
        }
    } catch (IOException e) {
        LOGGER.error("Failed read datapoint", e);
    } finally {
        collector.ack(tuple);
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:OpenTSDBFilterBolt.java

示例3: handleSwitchEvent

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
private void handleSwitchEvent(Tuple tuple, SwitchInfoData switchData) {
    String switchID = switchData.getSwitchId();
    String state = "" + switchData.getState();
    logger.info("DISCO: Switch Event: switch={} state={}", switchID, state);

    if (SwitchState.DEACTIVATED.getType().equals(state)) {
        // current logic: switch down means stop checking associated ports/links.
        // - possible extra steps of validation of switch down should occur elsewhere
        // - possible extra steps of generating link down messages aren't important since
        //      the TPE will drop the switch node from its graph.
        discovery.handleSwitchDown(switchID);
    } else if (SwitchState.ACTIVATED.getType().equals(state)) {
        discovery.handleSwitchUp(switchID);
    } else {
        // TODO: Should this be a warning? Evaluate whether any other state needs to be handled
        logger.warn("SWITCH Event: ignoring state: {}", state);
    }

    // Pass the original message along, to the Topology Engine topic.
    String json = tuple.getString(0);
    collector.emit(topoEngTopic, tuple, new Values(PAYLOAD, json));
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:OFELinkBolt.java

示例4: handlePortEvent

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
private void handlePortEvent(Tuple tuple, PortInfoData portData) {
    String switchID = portData.getSwitchId();
    String portID = "" + portData.getPortNo();
    String updown = "" + portData.getState();
    logger.info("DISCO: Port Event: switch={} port={} state={}", switchID, portID, updown);

    if (isPortUpOrCached(updown)) {
        discovery.handlePortUp(switchID, portID);
    } else if (updown.equals(OFEMessageUtils.PORT_DOWN)) {
        discovery.handlePortDown(switchID, portID);
    } else {
        // TODO: Should this be a warning? Evaluate whether any other state needs to be handled
        logger.warn("PORT Event: ignoring state: {}", updown);
    }

    // Pass the original message along, to the Topology Engine topic.
    String json = tuple.getString(0);
    collector.emit(topoEngTopic, tuple, new Values(PAYLOAD, json));
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:20,代码来源:OFELinkBolt.java

示例5: handleIslEvent

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
private void handleIslEvent(Tuple tuple, IslInfoData discoveredIsl) {
    PathNode node = discoveredIsl.getPath().get(0);
    String switchID = node.getSwitchId();
    String portID = "" + node.getPortNo();
    IslChangeType state = discoveredIsl.getState();
    logger.info("DISCO: ISL Event: switch={} port={} state={}", switchID, portID, state);

    if (IslChangeType.DISCOVERED.equals(state)) {
        discovery.handleDiscovered(switchID, portID);
    } else if (IslChangeType.FAILED.equals(state)) {
        discovery.handleFailed(switchID, portID);
    } else {
        // TODO: Should this be a warning? Evaluate whether any other state needs to be handled
        logger.warn("ISL Event: ignoring state: {}", state);
    }

    String json = tuple.getString(0);
    collector.emit(topoEngTopic, tuple, new Values(PAYLOAD, json));
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:20,代码来源:OFELinkBolt.java

示例6: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public void execute(Tuple input, BasicOutputCollector collector) {
	// Get the Apache log from the tuple
	String log = input.getString(0);

	if (StringUtils.isBlank(log)) {
		// ignore blank lines
		return;
	}
	// call the logSplitter(String apachelog) method of ApacheLogSplitter
	// class.
	Map<String, Object> logMap = apacheLogSplitter.logSplitter(log);
	List<Object> logdata = new ArrayList<Object>();
	for (String element : LOG_ELEMENTS) {
		logdata.add(logMap.get(element));
	}
	// emits set of fields (ip, referrer, user-agent, bytesSent, etc)
	collector.emit(logdata);

}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Storm,代码行数:20,代码来源:ApacheLogSplitterBolt.java

示例7: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
/**
 * 执行SQL 选择操作
 */
public void execute(Tuple input, BasicOutputCollector collector) {

    BinaryTreeAndOr bTreeAndOr = Selection.binaryTreeAndOr;
    if (bTreeAndOr != null) {
        postorderTraversal(bTreeAndOr.root, input);

        if (bTreeAndOr.root.val) {
            // 该条tuple符合选择需求
            String ansStr = "";
            for (int i = 0; i < input.size(); i++) {
                ansStr += input.getString(i) + ",";
            }
            results.add(ansStr);

            collector.emit(input.getValues());
        }

    } else {
        // 无SQL 选择操作需求,tuple直接流入下一个bolt
        int fc = input.getValues().size();
        collector.emit(input.getValues());
    }
}
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:27,代码来源:SelectBolt.java

示例8: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
	String valueByField = input.getString(0);
	System.out.println(valueByField);
	try {
		IndexResponse response = client.prepareIndex("pub-nub", "sensor-data")
				.setSource(convertStringtoMap(valueByField)).get();
		System.out.println(response.status());
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:PacktPublishing,项目名称:Practical-Real-time-Processing-and-Analytics,代码行数:13,代码来源:ElasticSearchBolt.java

示例9: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public void execute(Tuple input) {
	try {
		String tweet = input.getString(0);
		Map<String, Object> map = new ObjectMapper().readValue(tweet, Map.class);
		collector.emit("stream1",new Values(tweet));
		collector.emit("stream2",new Values(map.get("text")));
		this.collector.ack(input);
	} catch (Exception exception) {
		exception.printStackTrace();
		this.collector.fail(input);
	}
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Storm,代码行数:13,代码来源:JSONParsingBolt.java

示例10: getTopic

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public String getTopic(Tuple tuple) {
    if (fieldIndex < tuple.size()) {
        return tuple.getString(fieldIndex);
    } else {
        LOG.warn("Field index {} is out of bounds. Using default topic {}", fieldIndex, defaultTopicName);
        return defaultTopicName;
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:10,代码来源:FieldIndexTopicSelector.java

示例11: JsonMessage

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public JsonMessage(Tuple raw) throws MessageFormatException {
    super();

    String json = raw.getString(getFormat().fieldIndex(FIELD_ID_JSON));
    try {
        payload = unpackJson(json);
    } catch (IOException e) {
        throw new MessageFormatException(raw, e);
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:11,代码来源:JsonMessage.java

示例12: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void execute(Tuple tuple) {
    logger.debug("Ingoing tuple: {}", tuple);
    String request = tuple.getString(0);
    //String request = tuple.getStringByField("value");
    try {
        Message stats = Utils.MAPPER.readValue(request, Message.class);
        if (!Destination.WFM_STATS.equals(stats.getDestination()) || !(stats instanceof InfoMessage)) {
            return;
        }
        InfoMessage message = (InfoMessage) stats;
        final InfoData data = message.getData();
        if (data instanceof PortStatsData) {
            logger.debug("Port stats message: {}", new Values(request));
            outputCollector.emit(PORT_STATS_STREAM, tuple, new Values(message));
        } else if (data instanceof MeterConfigStatsData) {
            logger.debug("Meter config stats message: {}", new Values(request));
            outputCollector.emit(METER_CFG_STATS_STREAM, tuple, new Values(message));
        } else if (data instanceof FlowStatsData) {
            logger.debug("Flow stats message: {}", new Values(request));
            outputCollector.emit(FLOW_STATS_STREAM, tuple, new Values(message));
        }
    } catch (IOException exception) {
        logger.error("Could not deserialize message={}", request, exception);
    } finally {
        outputCollector.ack(tuple);
        logger.debug("Message ack: {}", request);
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:33,代码来源:SpeakerBolt.java

示例13: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public void execute(Tuple input) {
    String str = input.getString(0);
    str = str.toLowerCase().trim();
    if (!wordCountMap.containsKey(str)) {
        wordCountMap.put(str, 1);
    } else {
        Integer c = wordCountMap.get(str) + 1;
        wordCountMap.put(str, c);
    }

    collector.ack(input);
}
 
开发者ID:PacktPublishing,项目名称:Building-Data-Streaming-Applications-with-Apache-Kafka,代码行数:13,代码来源:WordCountCalculatorBolt.java

示例14: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public void execute(Tuple input) {
    String line = input.getString(0);
    String[] words = line.split(" ");

    for (String word : words) {
        if (!word.isEmpty()) {
            collector.emit(new Values(word));
        }

    }

    collector.ack(input);
}
 
开发者ID:PacktPublishing,项目名称:Building-Data-Streaming-Applications-with-Apache-Kafka,代码行数:14,代码来源:StringToWordsSpliterBolt.java

示例15: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
	String str = input.getString(0);
	/**
	 * If the word dosn't exist in the map we will create
	 * this, if not We will add 1 
	 */
	if(!counters.containsKey(str)){
		counters.put(str, 1);
	}else{
		Integer c = counters.get(str) + 1;
		counters.put(str, c);
	}
}
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:15,代码来源:WordCounter.java


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