一、配置集群storm.yaml文件,配置drpc.server

二、部署到linux上,开启nimbus,drpc,supervisor 等服务

/opt/module/storm-1.1.0/bin/storm nimbus &

/opt/module/storm-1.1.0/bin/storm drpc &

/opt/module/storm-1.1.0/bin/storm supervisor &

/opt/module/storm-1.1.0/bin/storm ui &

三、编写DrpcTopology程序。如下:

/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eyecool.framework.olive.compute; import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.LocalDRPC;
import org.apache.storm.StormSubmitter;
import org.apache.storm.drpc.LinearDRPCTopologyBuilder;
import org.apache.storm.utils.Utils; import com.eyecool.framework.olive.compute.bolt.ExclamationBolt; public class XFaceTopologyTest { public static void main(String[] args) throws Exception {
run(args);
} public static String spout_name = "raw-spout"; protected static int run(String[] args) throws Exception {
LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("lookup");
builder.addBolt(new ExclamationBolt(),3);
Config conf = new Config();
conf.setDebug(false);
conf.setNumWorkers(1);
if (args != null && args.length > 0) {
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createRemoteTopology());
} else {
LocalDRPC drpc = new LocalDRPC();
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("drpc-XFace", conf, builder.createLocalTopology(drpc));
System.out.println("Results for 'hello':" + drpc.execute("lookup", "hello"));
System.out.println("Results for 'hello':" + drpc.execute("lookup", "hello12")); Utils.sleep(1000000000);
cluster.killTopology("drpc-XFace");
cluster.shutdown();
}
return 0;
}
}
package com.eyecool.framework.olive.compute.bolt;

import org.apache.storm.topology.BasicOutputCollector;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseBasicBolt;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values; public class ExclamationBolt extends BaseBasicBolt { @Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("id", "return-info"));
} @Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
Object arg = tuple.getValue(0);
String retInfo = tuple.getString(1);
System.out.println("v0: "+arg +" v1: "+retInfo);
collector.emit(new Values(arg, retInfo + "!!!"));
} }

四、提交执行任务

/opt/module/storm-1.1.0/bin/storm jar olive-computeservice-storm-drpc-1.0.0-jar-with-dependencies.jar com.eyecool.framework.olive.compute.XFaceTopologyTest olive

五、页面可以看到系统成功运行

六、客户端代码调用测试,常遇到以下错误:

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.storm.security.auth.ThriftClient.reconnect(ThriftClient.java:108)
at org.apache.storm.security.auth.ThriftClient.<init>(ThriftClient.java:69)
at org.apache.storm.utils.DRPCClient.<init>(DRPCClient.java:44)
at org.apache.storm.utils.DRPCClient.<init>(DRPCClient.java:39)
at ClientTest.main(ClientTest.java:16)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.storm.security.auth.AuthUtils.GetTransportPlugin(AuthUtils.java:267)
at org.apache.storm.security.auth.ThriftClient.reconnect(ThriftClient.java:89)
... 4 more
Caused by: java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.storm.security.auth.AuthUtils.GetTransportPlugin(AuthUtils.java:263)
... 5 more

import java.util.Map;

import org.apache.storm.Config;
import org.apache.storm.utils.DRPCClient;
import org.apache.storm.utils.Utils; public class ClientTest { public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Config conf = new Config();
conf.setDebug(false);
Map config = Utils.readDefaultConfig();
@SuppressWarnings("resource")
DRPCClient client = new DRPCClient(conf, "192.168.0.188", 3772);// drpc
String result = client.execute("lookup", "hello world ");// 调用drpcTest函数,传递参数为hello System.out.println(result);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

正确的读取storm yaml 默认配置文件

Map config = Utils.readDefaultConfig();

就这么简单,完成!!!

storm1.1.0 drpc 部署和调用测试的更多相关文章

  1. WebService的开发、部署、调用

    本文参考其它文章和自己解决中间问题的经历记录,以C#开发WebService为例子,欢迎探讨: 一.C#开发WebService 在visual studio中新建ASP.NET Web服务应用程序, ...

  2. 使用vs2010创建、发布、部署、调用 WebService

    原文地址:使用vs2010创建.发布.部署.调用 WebService作者:吴超 一 使用vs2010创建 WebService 1 打开VS2010,菜单    文件->新建->项目2 ...

  3. mosquitto在Linux环境下的部署/安装/使用/测试

    mosquitto在Linux环境下的部署 看了有三四天的的源码,(当然没怎么好好看了),突然发现对mosquitto的源码有了一点点感觉,于是在第五天决定在Linux环境下部署mosquitto. ...

  4. C# -- HttpWebRequest 和 HttpWebResponse 的使用 C#编写扫雷游戏 使用IIS调试ASP.NET网站程序 WCF入门教程 ASP.Net Core开发(踩坑)指南 ASP.Net Core Razor+AdminLTE 小试牛刀 webservice创建、部署和调用 .net接收post请求并把数据转为字典格式

    C# -- HttpWebRequest 和 HttpWebResponse 的使用 C# -- HttpWebRequest 和 HttpWebResponse 的使用 结合使用HttpWebReq ...

  5. 【C#】 创建、部署和调用WebService的简单示例

    C# 创建.部署和调用WebService的简单示例 <div class="postBody"> <div id="cnblogs_post_body ...

  6. C# 创建、部署和调用WebService的简单示例 (转)

    C# 创建.部署和调用WebService的简单示例(转)  转自 https://www.cnblogs.com/Brambling/p/7266482.html  webservice 可以用于分 ...

  7. C#中WebService的创建、部署和调用的简单实例

    webservice 可以用于分布式应用程序之间的交互,和不同程序之间的交互. 概念性的东西就不说太多,下面开始创建一个简单的webservice的例子. 一:WebService的创建开发 先新建一 ...

  8. callback调用测试

    <html> <head> <script> var context="全局"; var testObj={ context:"初始& ...

  9. 云优化的概念、Entity Framework 7.0、简单吞吐量压力测试

    云优化的概念.Entity Framework 7.0.简单吞吐量压力测试 继续上一篇<开发 ASP.NET vNext 初步总结(使用Visual Studio 2014 CTP1)>之 ...

随机推荐

  1. 问题-python3.6找不到tkinter

    问题:import tkinter失败 然后直接pip安装也不ok python3.6安装过程中会提示是否选择安装tkinter,如此只有打开原来的安装程序 勾选箭头所示

  2. DocKer 创建容器 镜像端口映射失败

    问题一: 我想使用同一个镜像创建多个容器,并映射端口出现以下错误,该怎么解决? docker: Error response from daemon: driver failed programmin ...

  3. Problem A: Apple(高斯消元)

    可以发现具有非常多的方程, 然后高斯消元就能85分 然而我们发现这些方程组成了一些环, 我们仅仅设出一部分变量即可获得N个方程, 就可以A了 trick 合并方程 #include <cstdi ...

  4. 使用jieba库与wordcloud库第三方库进行词频统计

    一.jieba库与wordcloud库的使用 1.jieba库与wordcloud库的介绍 jieba 库的分词原理是利用一个中文词库,将待分词的内容与分词词库进行比对,通过图结构和动态规划方法找到最 ...

  5. 利用checkbox自带属性indeterminate构建含部分选中状态的树状结构

    本来上个月就像发的,但是一直忙啊忙的也没时间整理,所以拖到了现在. 好吧上面这句就是废话,我就是感概下.下面是正文. 前段时间在弄一个轻量级的web项目,要构建一个树状结构目录,同时希望能把部分选中的 ...

  6. VS编写一个项目的路径规划

    原文路径:http://blog.csdn.net/puttytree/article/details/7838419 https://www.cnblogs.com/zhehan54/p/45678 ...

  7. pyqt-QGrapicsView类

    QGrapicsView类 QGraphicsView提供一个显示QGraphicsScene内容的窗口,该窗口可以滚动,可以在构造时候把场景对象作为参数,或者之后使用setScene()来设置vie ...

  8. hbase概述和安装

    前言 前几天刚学了Hadoop的安装,几乎把Hadoop的雷都踩了一个遍,虽然Hadoop的相关的配置文件以及原理还没有完全完成,但是现在先总结分享一下笔者因为需要所整理的一些关于Hbase的东西. ...

  9. Never Wait for Weights(带权并查集+路径压缩)

    题目链接:http://acm.sdibt.edu.cn/vjudge/contest/view.action?cid=2209#problem/F !a b w 表示b比a大w ?  a b  输出 ...

  10. docker使用flannel网络

    基础环境我们使用了两台centos 7系统 基础配置为: 两台机器IP为 172.17.3.10 172.17.3.62 hosts文件配置为 172.17.3.10 node1 172.17.3.6 ...