In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about how to write simple stress test code in Storm. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
The code is relatively simple, look at the picture and say:
Package storm.benchmark;import backtype.storm.Config;import backtype.storm.StormSubmitter;import backtype.storm.spout.SpoutOutputCollector;import backtype.storm.task.TopologyContext;import backtype.storm.topology.BasicOutputCollector;import backtype.storm.topology.OutputFieldsDeclarer;import backtype.storm.topology.TopologyBuilder;import backtype.storm.topology.base.BaseBasicBolt;import backtype.storm.topology.base.BaseRichSpout;import backtype.storm.tuple.Fields;import backtype.storm.tuple.Tuple;import backtype.storm.tuple.Values;import java.util.Map;import java.util.Random Public class ThroughputTest {public static class GenSpout extends BaseRichSpout {private static final Character [] CHARS = new Character [] {'await,' baked, 'cased,' dashed, 'eyed,' faded, 'grubbed,' h'}; SpoutOutputCollector _ collector; int _ size; Random _ rand; String _ id; String _ val Public GenSpout (int size) {_ size = size;} @ Override public void open (Map conf, TopologyContext context, SpoutOutputCollector collector) {_ collector = collector; _ rand = new Random (); _ id = randString (5); _ val = randString (_ size) } @ Override public void nextTuple () {_ collector.emit (new Values (_ id, _ val));} private String randString (int size) {StringBuffer buf = new StringBuffer (); for (int iTuno; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.