Java Code Examples for org.apache.storm.tuple.Tuple#getString()
The following examples show how to use
org.apache.storm.tuple.Tuple#getString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoinBolt.java From bullet-storm with Apache License 2.0 | 6 votes |
private void onData(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); Querier querier = getQuery(id); if (querier == null) { log.debug("Received data for query {} before query. Ignoring...", id); return; } byte[] data = (byte[]) tuple.getValue(TopologyConstants.DATA_POSITION); querier.combine(data); if (querier.isDone()) { emitOrBufferFinished(id, querier); } else if (querier.isExceedingRateLimit()) { emitRateLimitError(id, querier, querier.getRateLimitError()); } else if (querier.isClosed()) { emitWindow(id, querier); } }
Example 2
Source File: WordCounterBolt.java From ranger with Apache License 2.0 | 6 votes |
@Override public void execute(Tuple tuple) { String word = tuple.getString(0); int count = 0; if (countMap.containsKey(word)) { count = countMap.get(word); count++; } count++; countMap.put(word, count); outputCollector.emit(new Values(word, count)); outputCollector.ack(tuple); }
Example 3
Source File: WordCounter.java From java-study with Apache License 2.0 | 6 votes |
/** * 为每个单词计数 */ @Override public void execute(Tuple input) { System.out.println("WordCounter.execute()"); String str = input.getString(0); /** * 如果单词尚不存在于map,我们就创建一个,如果已在,我们就为它加1 */ if (!counters.containsKey(str)) { counters.put(str, 1); } else { Integer c = counters.get(str) + 1; counters.put(str, c); } // 对元组作为应答 collector.ack(input); }
Example 4
Source File: FilterBolt.java From bullet-storm with Apache License 2.0 | 6 votes |
private void onQuery(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); String query = tuple.getString(TopologyConstants.QUERY_POSITION); if (manager.hasQuery(id)) { log.error("Duplicate for request {} with query {}", id, query); return; } try { Querier querier = createQuerier(Querier.Mode.PARTITION, id, query, config); if (!querier.initialize().isPresent()) { manager.addQuery(id, querier); log.info("Initialized query {}", querier.toString()); return; } } catch (RuntimeException ignored) { } // No need to handle any errors in the Filter Bolt. log.error("Failed to initialize query for request {} with query {}", id, query); }
Example 5
Source File: RemoteDRPCTopology.java From 163-bigdate-note with GNU General Public License v3.0 | 5 votes |
@Override public void execute(Tuple input) { Object requestId = input.getValue(0); String name = input.getString(1); //业务逻辑 String result = "add user:" + name; this.outputCollector.emit(new Values(requestId, result)); }
Example 6
Source File: JoinBolt.java From bullet-storm with Apache License 2.0 | 5 votes |
private void onError(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); Querier querier = getQuery(id); if (querier == null) { log.debug("Received error for {} without the query existing", id); // TODO Might later create this query if it is received late but whose error was ignored here. This is a leak. return; } RateLimitError error = (RateLimitError) tuple.getValue(TopologyConstants.ERROR_POSITION); emitRateLimitError(id, querier, error); }
Example 7
Source File: JoinBolt.java From bullet-storm with Apache License 2.0 | 5 votes |
private void onQuery(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); String query = tuple.getString(TopologyConstants.QUERY_POSITION); Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.QUERY_METADATA_POSITION); // bufferedMetadata has an entry for each query that exists in the JoinBolt; therefore, we check bufferedMetadata // for existing queries (as opposed to individually checking the queries, preStartBuffer, and postFinishBuffer maps) if (bufferedMetadata.containsKey(id)) { updateCount(duplicatedQueriesCount, 1L); log.error("Duplicate for request {} with query {}", id, query); return; } Querier querier; try { querier = createQuerier(Querier.Mode.ALL, id, query, config); Optional<List<BulletError>> optionalErrors = querier.initialize(); if (!optionalErrors.isPresent()) { setupQuery(id, query, metadata, querier); return; } emitErrorsAsResult(id, metadata, optionalErrors.get()); } catch (RuntimeException re) { // Includes JSONParseException emitErrorsAsResult(id, metadata, ParsingError.makeError(re, query)); } log.error("Failed to initialize query for request {} with query {}", id, query); }
Example 8
Source File: LoopBolt.java From bullet-storm with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.METADATA_POSITION); log.info("Looping back metadata with signal {} for {}", metadata.getSignal(), id); publish(new PubSubMessage(id, (byte[]) null, metadata), tuple); }
Example 9
Source File: SentenceWordCountTopology.java From incubator-heron with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split("\\s+")) { collector.emit(new Values(word, 1)); } }
Example 10
Source File: ResourceAwareExampleTopology.java From storm-net-adapter with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple) { String orig = tuple.getString(0); String ret = getFromCache(orig); if (ret == null) { ret = orig + "!!!"; addToCache(orig, ret); } _collector.emit(tuple, new Values(ret)); _collector.ack(tuple); }
Example 11
Source File: WordCountCalculatorBolt.java From Building-Data-Streaming-Applications-with-Apache-Kafka with MIT License | 5 votes |
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); }
Example 12
Source File: WordCountTopology.java From twister2 with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple) { String key = tuple.getString(0); int count = 1; if (countMap.get(key) == null) { countMap.put(key, count); } else { count = countMap.get(key); countMap.put(key, ++count); } System.out.println(key + ":" + count); }
Example 13
Source File: SentenceWordCountTopology.java From twister2 with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String word = tuple.getString(0); Integer count = counts.get(word); if (count == null) { count = 0; } count++; counts.put(word, count); System.out.println(word + ":" + count); }
Example 14
Source File: SentenceWordCountTopology.java From twister2 with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String sentence = tuple.getString(0); System.out.println("Sentence received : " + sentence); for (String word : sentence.split("\\s+")) { collector.emit(new Values(word, 1)); } }
Example 15
Source File: AdvertisingTopologyHighKeyCard.java From yahoo-streaming-benchmark with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple) { JSONObject obj = new JSONObject(tuple.getString(0)); _collector.emit(tuple, new Values(obj.getString("user_id"), obj.getString("page_id"), obj.getString("campaign_id"), obj.getString("ad_type"), obj.getString("event_type"), obj.getString("event_time"), obj.getString("ip_address"))); _collector.ack(tuple); }
Example 16
Source File: AnchoredWordCount.java From storm-net-adapter with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split("\\s+")) { collector.emit(new Values(word, 1)); } }
Example 17
Source File: LocalDRPCTopology.java From 163-bigdate-note with GNU General Public License v3.0 | 5 votes |
@Override public void execute(Tuple input) { Object requestId = input.getValue(0); String name = input.getString(1); //业务逻辑 String result = "add user:" + name; this.outputCollector.emit(new Values(requestId, result)); }
Example 18
Source File: ReachTopology.java From storm-net-adapter with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { Object id = tuple.getValue(0); String url = tuple.getString(1); List<String> tweeters = TWEETERS_DB.get(url); if (tweeters != null) { for (String tweeter : tweeters) { collector.emit(new Values(id, tweeter)); } } }
Example 19
Source File: BasicDRPCTopology.java From storm-net-adapter with Apache License 2.0 | 4 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String input = tuple.getString(1); collector.emit(new Values(tuple.getValue(0), input + "!")); }
Example 20
Source File: ManualDRPC.java From storm-net-adapter with Apache License 2.0 | 4 votes |
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String arg = tuple.getString(0); Object retInfo = tuple.getValue(1); collector.emit(new Values(arg + "!!!", retInfo)); }