一、配置集群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. lvm再次学习

    目录 LVM构架 分区 pvcreat vgcreat lvcreat 格式化文件系统 挂载至目录 已经学过很多很多遍LVM了,每次都觉得自己学会了,每次都是得查询才能搞定,这次给LVM做个专题,在有 ...

  2. 使用JavaMail创建邮件和发送邮件

    参考https://www.cnblogs.com/xdp-gacl/p/4216311.html,写的真好,知识在于分享,备份留着看 一.RFC882文档简单说明 RFC882文档规定了如何编写一封 ...

  3. LDAP目录服务

    LDAP目录服务 1.ldap目录服务介绍: 目录是一类为了浏览和搜索数据而设计的特殊的数据库,目录服务是按树状形式存储信息的,目录包含基于属性的描述信息,并且支持高级的过滤功能,一般来说,目录不支持 ...

  4. C#导出 Excel 时, 生成 CheckBox 控件

    在使用 Microsoft.Office.Interop.Excel 组件导出Excel 表格时,要把导出前的  CheckBox 控件一同导出到 excel 表格中,对于这个功能 看似很简单,但 M ...

  5. (转)get和post的区别

    Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE.URL全称是资源描述符,我们可以这样认为:一个URL地址,它用于描述一个网络上的资源,而HTTP ...

  6. 14Linux_BIND-Linux就该这么学

    bind 域名解析 域名→ip地址:正向解析 ip地址→域名:反向解析 主服务器:做管理 从服务器:同步 缓存服务器:转发

  7. react源码第一天

    1.下载源码:github 16.7版本 2.找到笔记:https://react.jokcy.me/book/api/react.html#

  8. css样式的书写顺序及原理——很重要!

    记得刚开始学习前端的时候,每次写css样式都是用到什么就在样式表后添加什么,完全没有考虑到样式属性的书写顺序对网页加载代码的影响.后来逐渐才知道正确的样式顺序不仅易于查看,并且也属于css样式优化的一 ...

  9. python 使用多进程打开多个cmd窗口,并在子进程结束之后关闭cmd窗口

    额,我想表达的是使用os.system()打开另一个可执行文件,然后等待其结束,关闭cmd窗口 主要是我突发奇想想装逼; 如果只是用multiprocessing库的多进程,然后输出信息的话,根本没法 ...

  10. Unable to connect to MKS;Too many scoket connect attempts;giving up

    Unable to connect to MKS;Too many scoket connect attempts;giving up(无法连接到MKS;太多scoket连接尝试;放弃) 第一次学习虚 ...