Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to write simple stress test code in Storm

Shulou Source: shulou.com Published: 2022-05-31 23:02:41 09月22日 Update

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

Tags: Code stress testing more knowledge articles practical that is work meetings articles read knowledge points industry details information information channels follow parts channels learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Redmi Docker Microsoft