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 7411b1d STORM-3415: Fix checkstyle violations in storm-jms-example new 7a07b5e Merge pull request #3025 from krichter722/checkstyle-jms-examples 7411b1d is described below commit 7411b1d45d5f343bf2a1cd43e552a02319a3a711 Author: Karl-Philipp Richter <krich...@posteo.de> AuthorDate: Fri Jun 14 10:47:51 2019 +0200 STORM-3415: Fix checkstyle violations in storm-jms-example --- examples/storm-jms-examples/pom.xml | 2 +- .../storm/jms/example/ExampleJmsTopology.java | 20 +++++-- .../org/apache/storm/jms/example/GenericBolt.java | 15 ++--- .../storm/jms/example/JsonTupleProducer.java | 23 ++++---- .../storm/jms/example/SpringJmsProvider.java | 65 +++++++++++----------- 5 files changed, 66 insertions(+), 59 deletions(-) diff --git a/examples/storm-jms-examples/pom.xml b/examples/storm-jms-examples/pom.xml index 1e0511b..56596f7 100644 --- a/examples/storm-jms-examples/pom.xml +++ b/examples/storm-jms-examples/pom.xml @@ -105,7 +105,7 @@ <artifactId>maven-checkstyle-plugin</artifactId> <!--Note - the version would be inherited--> <configuration> - <maxAllowedViolations>78</maxAllowedViolations> + <maxAllowedViolations>0</maxAllowedViolations> </configuration> </plugin> <plugin> diff --git a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/ExampleJmsTopology.java b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/ExampleJmsTopology.java index 096a16e..dcf9d48 100644 --- a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/ExampleJmsTopology.java +++ b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/ExampleJmsTopology.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.jms.example; import javax.jms.JMSException; @@ -33,6 +34,9 @@ import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.ITuple; +/** + * An example JMS topology. + */ public class ExampleJmsTopology { public static final String JMS_QUEUE_SPOUT = "JMS_QUEUE_SPOUT"; public static final String INTERMEDIATE_BOLT = "INTERMEDIATE_BOLT"; @@ -41,6 +45,11 @@ public class ExampleJmsTopology { public static final String JMS_TOPIC_SPOUT = "JMS_TOPIC_SPOUT"; public static final String ANOTHER_BOLT = "ANOTHER_BOLT"; + /** + * The main method. + * @param args takes the topology name as first argument + * @throws Exception any expection occuring durch cluster setup or operation + */ @SuppressWarnings("serial") public static void main(String[] args) throws Exception { @@ -49,11 +58,6 @@ public class ExampleJmsTopology { "jms-activemq.xml", "jmsConnectionFactory", "notificationQueue"); - // JMS Topic provider - JmsProvider jmsTopicProvider = new SpringJmsProvider( - "jms-activemq.xml", "jmsConnectionFactory", - "notificationTopic"); - // JMS Producer JmsTupleProducer producer = new JsonTupleProducer(); @@ -67,7 +71,6 @@ public class ExampleJmsTopology { // spout with 5 parallel instances builder.setSpout(JMS_QUEUE_SPOUT, queueSpout, 5); - // intermediate bolt, subscribes to jms spout, anchors on tuples, and auto-acks builder.setBolt(INTERMEDIATE_BOLT, new GenericBolt("INTERMEDIATE_BOLT", true, true, new Fields("json")), 3).shuffleGrouping( @@ -78,6 +81,11 @@ public class ExampleJmsTopology { builder.setBolt(FINAL_BOLT, new GenericBolt("FINAL_BOLT", true, true), 3).shuffleGrouping( INTERMEDIATE_BOLT); + // JMS Topic provider + JmsProvider jmsTopicProvider = new SpringJmsProvider( + "jms-activemq.xml", "jmsConnectionFactory", + "notificationTopic"); + // bolt that subscribes to the intermediate bolt, and publishes to a JMS Topic JmsBolt jmsBolt = new JmsBolt(); jmsBolt.setJmsProvider(jmsTopicProvider); diff --git a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/GenericBolt.java b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/GenericBolt.java index 341a4dc..fe90440 100644 --- a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/GenericBolt.java +++ b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/GenericBolt.java @@ -15,27 +15,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.jms.example; import java.util.Map; -import org.apache.storm.topology.base.BaseRichBolt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import org.apache.storm.task.OutputCollector; import org.apache.storm.task.TopologyContext; import org.apache.storm.topology.OutputFieldsDeclarer; +import org.apache.storm.topology.base.BaseRichBolt; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Tuple; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * A generic <code>org.apache.storm.topology.IRichBolt</code> implementation * for testing/debugging the Storm JMS Spout and example topologies. - * <p> - * For debugging purposes, set the log level of the + * + * <p>For debugging purposes, set the log level of the * <code>org.apache.storm.contrib.jms</code> package to DEBUG for debugging - * output. + * output.</p> * * @author tgoetz */ diff --git a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/JsonTupleProducer.java b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/JsonTupleProducer.java index 9f88570..178032a 100644 --- a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/JsonTupleProducer.java +++ b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/JsonTupleProducer.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.jms.example; import javax.jms.JMSException; @@ -43,18 +44,18 @@ import org.apache.storm.tuple.Values; public class JsonTupleProducer implements JmsTupleProducer { @Override - public Values toTuple(Message msg) throws JMSException { - if(msg instanceof TextMessage){ - String json = ((TextMessage) msg).getText(); - return new Values(json); - } else { - return null; - } - } + public Values toTuple(Message msg) throws JMSException { + if (msg instanceof TextMessage) { + String json = ((TextMessage) msg).getText(); + return new Values(json); + } else { + return null; + } + } @Override - public void declareOutputFields(OutputFieldsDeclarer declarer) { - declarer.declare(new Fields("json")); - } + public void declareOutputFields(OutputFieldsDeclarer declarer) { + declarer.declare(new Fields("json")); + } } diff --git a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/SpringJmsProvider.java b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/SpringJmsProvider.java index 747b415..c6b4c21 100644 --- a/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/SpringJmsProvider.java +++ b/examples/storm-jms-examples/src/main/java/org/apache/storm/jms/example/SpringJmsProvider.java @@ -15,62 +15,59 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.jms.example; import javax.jms.ConnectionFactory; import javax.jms.Destination; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - import org.apache.storm.jms.JmsProvider; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; /** * A <code>JmsProvider</code> that uses the spring framework * to obtain a JMS <code>ConnectionFactory</code> and * <code>Desitnation</code> objects. - * <p/> - * The constructor takes three arguments: + * + * <p>The constructor takes three arguments: * <ol> * <li>A string pointing to the the spring application context file contining the JMS configuration * (must be on the classpath) * </li> * <li>The name of the connection factory bean</li> * <li>The name of the destination bean</li> - * </ol> - * - * - * + * </ol></p> */ @SuppressWarnings("serial") public class SpringJmsProvider implements JmsProvider { - private ConnectionFactory connectionFactory; - private Destination destination; - - /** - * Constructs a <code>SpringJmsProvider</code> object given the name of a - * classpath resource (the spring application context file), and the bean - * names of a JMS connection factory and destination. - * - * @param appContextClasspathResource - the spring configuration file (classpath resource) - * @param connectionFactoryBean - the JMS connection factory bean name - * @param destinationBean - the JMS destination bean name - */ - public SpringJmsProvider(String appContextClasspathResource, String connectionFactoryBean, String destinationBean){ - ApplicationContext context = new ClassPathXmlApplicationContext(appContextClasspathResource); - this.connectionFactory = (ConnectionFactory)context.getBean(connectionFactoryBean); - this.destination = (Destination)context.getBean(destinationBean); - } + private ConnectionFactory connectionFactory; + private Destination destination; + + /** + * Constructs a <code>SpringJmsProvider</code> object given the name of a + * classpath resource (the spring application context file), and the bean + * names of a JMS connection factory and destination. + * + * @param appContextClasspathResource - the spring configuration file (classpath resource) + * @param connectionFactoryBean - the JMS connection factory bean name + * @param destinationBean - the JMS destination bean name + */ + public SpringJmsProvider(String appContextClasspathResource, String connectionFactoryBean, String destinationBean) { + ApplicationContext context = new ClassPathXmlApplicationContext(appContextClasspathResource); + this.connectionFactory = (ConnectionFactory)context.getBean(connectionFactoryBean); + this.destination = (Destination)context.getBean(destinationBean); + } - @Override - public ConnectionFactory connectionFactory() throws Exception { - return this.connectionFactory; - } + @Override + public ConnectionFactory connectionFactory() throws Exception { + return this.connectionFactory; + } - @Override - public Destination destination() throws Exception { - return this.destination; - } + @Override + public Destination destination() throws Exception { + return this.destination; + } }