This is an automated email from the ASF dual-hosted git repository. srdo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/storm.git
The following commit(s) were added to refs/heads/master by this push: new de44647 STORM-3427: integration-test: fix all checkstyle warnings new 9b23e8a Merge pull request #3041 from krichter722/checkstyle-integration-test de44647 is described below commit de44647c76e3133ce4343b81eeda43db6fd2f7e9 Author: Karl-Philipp Richter <krich...@posteo.de> AuthorDate: Tue Jun 25 22:06:51 2019 +0200 STORM-3427: integration-test: fix all checkstyle warnings --- integration-test/pom.xml | 2 +- .../java/org/apache/storm/ExclamationTopology.java | 150 ++++++++++----------- .../java/org/apache/storm/debug/DebugHelper.java | 6 +- .../apache/storm/st/topology/TestableTopology.java | 7 +- .../st/topology/window/IncrementingSpout.java | 4 +- .../st/topology/window/SlidingTimeCorrectness.java | 10 +- .../topology/window/SlidingWindowCorrectness.java | 12 +- .../topology/window/TimeDataIncrementingSpout.java | 52 +++---- .../topology/window/TumblingTimeCorrectness.java | 12 +- .../topology/window/TumblingWindowCorrectness.java | 12 +- .../storm/st/topology/window/data/TimeData.java | 24 ++-- .../org/apache/storm/st/utils/StringDecorator.java | 6 +- .../java/org/apache/storm/st/utils/TimeUtil.java | 5 +- 13 files changed, 163 insertions(+), 139 deletions(-) diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 65f0453..e92fc97 100755 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -175,7 +175,7 @@ <artifactId>maven-checkstyle-plugin</artifactId> <!--Note - the version would be inherited--> <configuration> - <maxAllowedViolations>129</maxAllowedViolations> + <maxAllowedViolations>0</maxAllowedViolations> </configuration> </plugin> <plugin> diff --git a/integration-test/src/main/java/org/apache/storm/ExclamationTopology.java b/integration-test/src/main/java/org/apache/storm/ExclamationTopology.java index fa44a98..d674e8c 100644 --- a/integration-test/src/main/java/org/apache/storm/ExclamationTopology.java +++ b/integration-test/src/main/java/org/apache/storm/ExclamationTopology.java @@ -17,110 +17,110 @@ package org.apache.storm; -import com.google.common.collect.Lists; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import org.apache.storm.generated.StormTopology; +import org.apache.storm.spout.SpoutOutputCollector; +import org.apache.storm.st.topology.TestableTopology; +import org.apache.storm.st.utils.TimeUtil; import org.apache.storm.task.OutputCollector; import org.apache.storm.task.TopologyContext; import org.apache.storm.topology.OutputFieldsDeclarer; import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.topology.base.BaseRichBolt; +import org.apache.storm.topology.base.BaseRichSpout; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Tuple; import org.apache.storm.tuple.Values; -import java.util.Map; -import org.apache.storm.spout.SpoutOutputCollector; -import org.apache.storm.st.topology.TestableTopology; -import org.apache.storm.st.utils.TimeUtil; -import org.apache.storm.topology.base.BaseRichSpout; - /** * This is a basic example of a Storm topology. */ public class ExclamationTopology { - public static final String WORD = "word"; - public static final String EXCLAIM_1 = "exclaim1"; - public static final String EXCLAIM_2 = "exclaim2"; - public static final int SPOUT_EXECUTORS = 10; - public static final int EXCLAIM_2_EXECUTORS = 2; + public static final String WORD = "word"; + public static final String EXCLAIM_1 = "exclaim1"; + public static final String EXCLAIM_2 = "exclaim2"; + public static final int SPOUT_EXECUTORS = 10; + public static final int EXCLAIM_2_EXECUTORS = 2; - public static class ExclamationBolt extends BaseRichBolt { + public static class ExclamationBolt extends BaseRichBolt { - OutputCollector _collector; + OutputCollector collector; - @Override - public void prepare(Map<String, Object> conf, TopologyContext context, OutputCollector collector) { - _collector = collector; - } + @Override + public void prepare(Map<String, Object> conf, TopologyContext context, OutputCollector collector) { + this.collector = collector; + } - @Override - public void execute(Tuple tuple) { - _collector.emit(tuple, new Values(tuple.getString(0) + "!!!")); - _collector.ack(tuple); - } + @Override + public void execute(Tuple tuple) { + collector.emit(tuple, new Values(tuple.getString(0) + "!!!")); + collector.ack(tuple); + } - @Override - public void declareOutputFields(OutputFieldsDeclarer declarer) { - declarer.declare(new Fields("word")); + @Override + public void declareOutputFields(OutputFieldsDeclarer declarer) { + declarer.declare(new Fields("word")); + } } - } - - public static class FixedOrderWordSpout extends BaseRichSpout { - - public static final List<String> WORDS = Collections.unmodifiableList(Arrays.asList("nathan", "mike", "jackson", "golda", "bertels")); - private SpoutOutputCollector collector; - private int currentIndex = 0; - private int numEmitted = 0; + public static class FixedOrderWordSpout extends BaseRichSpout { + + public static final List<String> WORDS = Collections.unmodifiableList(Arrays.asList("nathan", + "mike", + "jackson", + "golda", + "bertels")); + + private SpoutOutputCollector collector; + private int currentIndex = 0; + private int numEmitted = 0; + + @Override + public void declareOutputFields(OutputFieldsDeclarer declarer) { + declarer.declare(new Fields("word")); + } + + @Override + public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { + this.collector = collector; + } + + @Override + public void nextTuple() { + if (numEmitted >= TestableTopology.MAX_SPOUT_EMITS) { + //Stop emitting at a certain point, because log rolling breaks the tests. + return; + } + //Sleep a bit to avoid hogging the CPU. + TimeUtil.sleepMilliSec(1); + collector.emit(new Values(WORDS.get((currentIndex++) % WORDS.size()))); + ++numEmitted; + } - @Override - public void declareOutputFields(OutputFieldsDeclarer declarer) { - declarer.declare(new Fields("word")); } - @Override - public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { - this.collector = collector; + public static void main(String[] args) throws Exception { + Config conf = new Config(); + conf.setDebug(true); + String topoName = "test"; + if (args.length > 0) { + topoName = args[0]; + } + + conf.setNumWorkers(3); + StormTopology topology = getStormTopology(); + StormSubmitter.submitTopologyWithProgressBar(topoName, conf, topology); } - @Override - public void nextTuple() { - if (numEmitted >= TestableTopology.MAX_SPOUT_EMITS) { - //Stop emitting at a certain point, because log rolling breaks the tests. - return; - } - //Sleep a bit to avoid hogging the CPU. - TimeUtil.sleepMilliSec(1); - collector.emit(new Values(WORDS.get((currentIndex++) % WORDS.size()))); - ++numEmitted; + public static StormTopology getStormTopology() { + TopologyBuilder builder = new TopologyBuilder(); + builder.setSpout(WORD, new FixedOrderWordSpout(), SPOUT_EXECUTORS); + builder.setBolt(EXCLAIM_1, new ExclamationTopology.ExclamationBolt(), 3).shuffleGrouping(WORD); + builder.setBolt(EXCLAIM_2, new ExclamationTopology.ExclamationBolt(), EXCLAIM_2_EXECUTORS).shuffleGrouping(EXCLAIM_1); + return builder.createTopology(); } - - } - - public static void main(String[] args) throws Exception { - StormTopology topology = getStormTopology(); - - Config conf = new Config(); - conf.setDebug(true); - String topoName = "test"; - if (args.length > 0) { - topoName = args[0]; - } - - conf.setNumWorkers(3); - StormSubmitter.submitTopologyWithProgressBar(topoName, conf, topology); - } - - public static StormTopology getStormTopology() { - TopologyBuilder builder = new TopologyBuilder(); - builder.setSpout(WORD, new FixedOrderWordSpout(), SPOUT_EXECUTORS); - builder.setBolt(EXCLAIM_1, new ExclamationTopology.ExclamationBolt(), 3).shuffleGrouping(WORD); - builder.setBolt(EXCLAIM_2, new ExclamationTopology.ExclamationBolt(), EXCLAIM_2_EXECUTORS).shuffleGrouping(EXCLAIM_1); - return builder.createTopology(); - } } diff --git a/integration-test/src/main/java/org/apache/storm/debug/DebugHelper.java b/integration-test/src/main/java/org/apache/storm/debug/DebugHelper.java index 97c0554..2af94e7 100644 --- a/integration-test/src/main/java/org/apache/storm/debug/DebugHelper.java +++ b/integration-test/src/main/java/org/apache/storm/debug/DebugHelper.java @@ -17,13 +17,13 @@ package org.apache.storm.debug; +import java.net.URL; +import java.net.URLClassLoader; + import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.URL; -import java.net.URLClassLoader; - public class DebugHelper { private static final Logger LOG = LoggerFactory.getLogger(DebugHelper.class); diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/TestableTopology.java b/integration-test/src/main/java/org/apache/storm/st/topology/TestableTopology.java index 558452c..cf10f23 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/TestableTopology.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/TestableTopology.java @@ -25,10 +25,15 @@ public interface TestableTopology { int TIMEDATA_SLEEP_BETWEEN_EMITS_MS = 20; //Some tests rely on reading the worker log. If there are too many emits and too much is logged, the log might roll, breaking the test. //Ensure the time based windowing tests can emit for 5 minutes - long MAX_SPOUT_EMITS = TimeUnit.MINUTES.toMillis(5)/TIMEDATA_SLEEP_BETWEEN_EMITS_MS; + long MAX_SPOUT_EMITS = TimeUnit.MINUTES.toMillis(5) / TIMEDATA_SLEEP_BETWEEN_EMITS_MS; + StormTopology newTopology(); + String getBoltName(); + int getBoltExecutors(); + String getSpoutName(); + int getSpoutExecutors(); } diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/IncrementingSpout.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/IncrementingSpout.java index 8b921b9..f42f660 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/IncrementingSpout.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/IncrementingSpout.java @@ -52,8 +52,8 @@ public class IncrementingSpout extends BaseRichSpout { @Override public void nextTuple() { if (currentNum >= TestableTopology.MAX_SPOUT_EMITS) { - //Stop emitting at a certain point, because log rolling breaks the tests. - return; + //Stop emitting at a certain point, because log rolling breaks the tests. + return; } //Sleep a bit to avoid hogging the CPU. TimeUtil.sleepMilliSec(1); diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingTimeCorrectness.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingTimeCorrectness.java index 604945f..88fcdf4 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingTimeCorrectness.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingTimeCorrectness.java @@ -18,20 +18,22 @@ package org.apache.storm.st.topology.window; import com.google.common.collect.Lists; + +import java.util.List; +import java.util.concurrent.TimeUnit; + import org.apache.storm.generated.StormTopology; import org.apache.storm.st.topology.TestableTopology; import org.apache.storm.st.topology.window.data.TimeData; import org.apache.storm.st.utils.StringDecorator; import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.topology.base.BaseWindowedBolt; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; -import java.util.concurrent.TimeUnit; - /** - * Computes sliding window sum + * Computes sliding window sum. */ public class SlidingTimeCorrectness implements TestableTopology { private static final Logger LOG = LoggerFactory.getLogger(SlidingTimeCorrectness.class); diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingWindowCorrectness.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingWindowCorrectness.java index cf725d3..5e11abe 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingWindowCorrectness.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/SlidingWindowCorrectness.java @@ -18,18 +18,20 @@ package org.apache.storm.st.topology.window; import com.google.common.collect.Lists; + +import java.util.List; + import org.apache.storm.generated.StormTopology; +import org.apache.storm.st.topology.TestableTopology; +import org.apache.storm.st.utils.StringDecorator; import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.topology.base.BaseWindowedBolt; -import org.apache.storm.st.topology.TestableTopology; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.storm.st.utils.StringDecorator; - -import java.util.List; /** - * Computes sliding window sum + * Computes sliding window sum. */ public class SlidingWindowCorrectness implements TestableTopology { private static final Logger LOG = LoggerFactory.getLogger(SlidingWindowCorrectness.class); diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/TimeDataIncrementingSpout.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/TimeDataIncrementingSpout.java index 444a8a6..2c2d4df 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/TimeDataIncrementingSpout.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/TimeDataIncrementingSpout.java @@ -32,34 +32,34 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TimeDataIncrementingSpout extends BaseRichSpout { - private static final Logger LOG = LoggerFactory.getLogger(TimeDataIncrementingSpout.class); - private SpoutOutputCollector collector; - private int currentNum; - private String componentId; + private static final Logger LOG = LoggerFactory.getLogger(TimeDataIncrementingSpout.class); + private SpoutOutputCollector collector; + private int currentNum; + private String componentId; - @Override - public void declareOutputFields(OutputFieldsDeclarer declarer) { - declarer.declare(TimeData.getFields()); - } + @Override + public void declareOutputFields(OutputFieldsDeclarer declarer) { + declarer.declare(TimeData.getFields()); + } - @Override - public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { - componentId = context.getThisComponentId(); - this.collector = collector; - } + @Override + public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { + componentId = context.getThisComponentId(); + this.collector = collector; + } - @Override - public void nextTuple() { - if (currentNum >= TestableTopology.MAX_SPOUT_EMITS) { - //Stop emitting at a certain point, because log rolling breaks the tests. - return; - } - //Sleep a bit between emits to ensure that we don't reach the cap too quickly, since this spout is used to test time based windows - TimeUtil.sleepMilliSec(TestableTopology.TIMEDATA_SLEEP_BETWEEN_EMITS_MS); - currentNum++; - TimeData data = TimeData.newData(currentNum); - final Values tuple = data.getValues(); - collector.emit(tuple); - LOG.info(StringDecorator.decorate(componentId, data.toString())); + @Override + public void nextTuple() { + if (currentNum >= TestableTopology.MAX_SPOUT_EMITS) { + //Stop emitting at a certain point, because log rolling breaks the tests. + return; } + //Sleep a bit between emits to ensure that we don't reach the cap too quickly, since this spout is used to test time based windows + TimeUtil.sleepMilliSec(TestableTopology.TIMEDATA_SLEEP_BETWEEN_EMITS_MS); + currentNum++; + TimeData data = TimeData.newData(currentNum); + final Values tuple = data.getValues(); + collector.emit(tuple); + LOG.info(StringDecorator.decorate(componentId, data.toString())); } +} diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingTimeCorrectness.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingTimeCorrectness.java index 56de3ad..934940f 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingTimeCorrectness.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingTimeCorrectness.java @@ -18,20 +18,22 @@ package org.apache.storm.st.topology.window; import com.google.common.collect.Lists; + +import java.util.List; +import java.util.concurrent.TimeUnit; + import org.apache.storm.generated.StormTopology; import org.apache.storm.st.topology.TestableTopology; import org.apache.storm.st.topology.window.data.TimeData; +import org.apache.storm.st.utils.StringDecorator; import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.topology.base.BaseWindowedBolt; -import org.apache.storm.st.utils.StringDecorator; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; -import java.util.concurrent.TimeUnit; - /** - * Computes sliding window sum + * Computes sliding window sum. */ public class TumblingTimeCorrectness implements TestableTopology { private static final Logger LOG = LoggerFactory.getLogger(TumblingTimeCorrectness.class); diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingWindowCorrectness.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingWindowCorrectness.java index 344ecfa..81d46b9 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingWindowCorrectness.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/TumblingWindowCorrectness.java @@ -18,18 +18,20 @@ package org.apache.storm.st.topology.window; import com.google.common.collect.Lists; + +import java.util.List; + import org.apache.storm.generated.StormTopology; +import org.apache.storm.st.topology.TestableTopology; +import org.apache.storm.st.utils.StringDecorator; import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.topology.base.BaseWindowedBolt; -import org.apache.storm.st.topology.TestableTopology; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.storm.st.utils.StringDecorator; - -import java.util.List; /** - * Computes sliding window sum + * Computes sliding window sum. */ public class TumblingWindowCorrectness implements TestableTopology { private static final Logger LOG = LoggerFactory.getLogger(TumblingWindowCorrectness.class); diff --git a/integration-test/src/main/java/org/apache/storm/st/topology/window/data/TimeData.java b/integration-test/src/main/java/org/apache/storm/st/topology/window/data/TimeData.java index 1c90de2..4a1fc96 100644 --- a/integration-test/src/main/java/org/apache/storm/st/topology/window/data/TimeData.java +++ b/integration-test/src/main/java/org/apache/storm/st/topology/window/data/TimeData.java @@ -19,13 +19,14 @@ package org.apache.storm.st.topology.window.data; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.apache.storm.tuple.Fields; -import org.apache.storm.tuple.Tuple; -import org.apache.storm.tuple.Values; import java.util.Collection; import java.util.Date; +import org.apache.storm.tuple.Fields; +import org.apache.storm.tuple.Tuple; +import org.apache.storm.tuple.Values; + public class TimeData implements Comparable<TimeData> { public static final TimeData CLS = new TimeData(-1); private static final String NUMBER_FIELD_NAME = "number"; @@ -85,15 +86,22 @@ public class TimeData implements Comparable<TimeData> { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } TimeData data = (TimeData) o; - if (num != data.num) return false; - if (timestamp != data.timestamp) return false; + if (num != data.num) { + return false; + } + if (timestamp != data.timestamp) { + return false; + } return now.equals(data.now); - } @Override diff --git a/integration-test/src/main/java/org/apache/storm/st/utils/StringDecorator.java b/integration-test/src/main/java/org/apache/storm/st/utils/StringDecorator.java index 51ad8df..e760c7a 100644 --- a/integration-test/src/main/java/org/apache/storm/st/utils/StringDecorator.java +++ b/integration-test/src/main/java/org/apache/storm/st/utils/StringDecorator.java @@ -21,8 +21,10 @@ import org.apache.commons.lang.StringUtils; /** * This class provides a method to pass data from the test bolts and spouts to the test method, via the worker log. - * Test components can use {@link #decorate(java.lang.String, java.lang.String) } to create a string containing a unique prefix. - * Such prefixed log lines can be retrieved from the worker logs, and recognized via {@link #isDecorated(java.lang.String, java.lang.String) }. + * Test components can use {@link #decorate(java.lang.String, java.lang.String) } to create a string containing a + * unique prefix. + * Such prefixed log lines can be retrieved from the worker logs, and recognized via + * {@link #isDecorated(java.lang.String, java.lang.String) }. */ public class StringDecorator { diff --git a/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java b/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java index 36bdfdd..e43fb05 100644 --- a/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java +++ b/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java @@ -17,13 +17,13 @@ package org.apache.storm.st.utils; +import java.util.concurrent.TimeUnit; + import org.apache.commons.lang.exception.ExceptionUtils; import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; - public class TimeUtil { private static Logger log = LoggerFactory.getLogger(TimeUtil.class); @@ -34,6 +34,7 @@ public class TimeUtil { log.warn("Caught exception: " + ExceptionUtils.getFullStackTrace(e)); } } + public static void sleepMilliSec(int milliSec) { try { TimeUnit.MILLISECONDS.sleep(milliSec);