【问题标题】:Running Word Count in Local cluster in Apache Storm在 Apache Storm 的本地集群中运行字数统计
【发布时间】:2015-02-16 20:14:42
【问题描述】:

我正在努力学习这本书

http://my.safaribooksonline.com/9781449324025?iid=2013-12-blog-storm-book-9781449324025-SBOBlog

运行 Storm 集群并创建第一个拓扑。这些是我遵循的步骤

1) 已安装的 Maven

2) 为 Eclipse 安装了 maven 插件

3) 在 Eclipse 中创建新的 Maven 项目,工件名称为stormArtifact

4) 它生成了一个文件夹结构和一个 pom.xml 文件

5) 我将 pom.xml 更新如下。

6) 我添加了此链接中指定的喷口和螺栓

https://github.com/storm-book/examples-ch02-getting_started/zipball/master

7) 现在我使用命令运行它

mvn exec:java -Dexec.mainClass="TopologyMain" -Dexec.args="src/main/resources/words.txt"

但它抛出如下错误

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3:java (def
ault-cli) on project stormArtifact: The parameters 'mainClass' for goal org.code
haus.mojo:exec-maven-plugin:1.3:java are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParamete
rException

我的 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>stormGroup</groupId>
<artifactId>stormArtifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <compilerVersion>1.7</compilerVersion>
    </configuration>
</plugin>
</plugins>
</build>
<repositories>
<!-- Repository where we can found the storm dependencies -->
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<!-- Storm Dependency -->
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.9.0</version>
</dependency>
</dependencies>
</project>

ToplogyMain 类

import spouts.WordReader;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
import bolts.WordCounter;
import bolts.WordNormalizer;


public class TopologyMain {
public static void main(String[] args) throws InterruptedException {

    //Topology definition
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("word-reader",new WordReader());
    builder.setBolt("word-normalizer", new WordNormalizer())
        .shuffleGrouping("word-reader");
    builder.setBolt("word-counter", new WordCounter(),1)
        .fieldsGrouping("word-normalizer", new Fields("word"));

    //Configuration
    Config conf = new Config();
    conf.put("wordsFile", args[0]);
    conf.setDebug(false);
    //Topology run
    conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("Getting-Started-Toplogie", conf, builder.createTopology());
    Thread.sleep(1000);
    cluster.shutdown();
}
}

【问题讨论】:

  • 您是否尝试使用配置文件在 pom 中显式显示 maven-exec-plugin?
  • 您在运行命令之前是否运行了mvn clean package

标签: maven apache-storm


【解决方案1】:

我遇到了同样的问题,但我首先在本地机器上安装了storm binary distribution,然后在我的主pom.xml 中运行mvn package 命令。

成功了!

如果您使用的是 Storm 的最新开发版本,例如经过 克隆了Storm git repository,那么您必须首先执行 Storm 本身的本地构建

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 2015-12-01
    • 2018-07-12
    • 2021-06-02
    • 2023-03-19
    相关资源
    最近更新 更多