storm1.1.0 drpc 部署和调用测试
一、配置集群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 部署和调用测试的更多相关文章
- WebService的开发、部署、调用
本文参考其它文章和自己解决中间问题的经历记录,以C#开发WebService为例子,欢迎探讨: 一.C#开发WebService 在visual studio中新建ASP.NET Web服务应用程序, ...
- 使用vs2010创建、发布、部署、调用 WebService
原文地址:使用vs2010创建.发布.部署.调用 WebService作者:吴超 一 使用vs2010创建 WebService 1 打开VS2010,菜单 文件->新建->项目2 ...
- mosquitto在Linux环境下的部署/安装/使用/测试
mosquitto在Linux环境下的部署 看了有三四天的的源码,(当然没怎么好好看了),突然发现对mosquitto的源码有了一点点感觉,于是在第五天决定在Linux环境下部署mosquitto. ...
- 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 ...
- 【C#】 创建、部署和调用WebService的简单示例
C# 创建.部署和调用WebService的简单示例 <div class="postBody"> <div id="cnblogs_post_body ...
- C# 创建、部署和调用WebService的简单示例 (转)
C# 创建.部署和调用WebService的简单示例(转) 转自 https://www.cnblogs.com/Brambling/p/7266482.html webservice 可以用于分 ...
- C#中WebService的创建、部署和调用的简单实例
webservice 可以用于分布式应用程序之间的交互,和不同程序之间的交互. 概念性的东西就不说太多,下面开始创建一个简单的webservice的例子. 一:WebService的创建开发 先新建一 ...
- callback调用测试
<html> <head> <script> var context="全局"; var testObj={ context:"初始& ...
- 云优化的概念、Entity Framework 7.0、简单吞吐量压力测试
云优化的概念.Entity Framework 7.0.简单吞吐量压力测试 继续上一篇<开发 ASP.NET vNext 初步总结(使用Visual Studio 2014 CTP1)>之 ...
随机推荐
- vs2015 iis express启动不了及安装DotNetCore.1.0.0-VS2015Tools.Preview2失败的解决方法
直接用管理员账户打开cmd,进入exe所在的文件夹在运行命令DotNetCore.1.0.0-VS2015Tools.Preview2.exe SKIP_VSU_CHECK=1不要加引号. PS:如果 ...
- RN-入门基础
Props State 一切界面变化,都是state变化 state修改必须通过setState方法 this.state.like=true 这样复制无效 setState是一个merge合并的操作 ...
- 基础总结(03)-- css有趣的特性
1.currentColor:可用于background/border-color/渐变/box-shadow/svg填充色,颜色继承自color. 待补充…
- 入门Spring ioc
简单的来记录一下自己的SSM框架入门--------IOC篇段 ioc(控制反转 -将对象的创建的权利从类型本身来创建,来交给spring工厂来创建)的配置. <bean>:是可以指spr ...
- iOS下 UILabel 如何自动换行
背景: 相信很多朋友都遇到过,文本的内容长度不一,需要根据内容的多少来自动换行处理. 场景: 很多APP中评论,有的评论长,有的评论短,有的一行,有的多行. 下面以评论的实现为例来说说具体如何实现 ...
- sentry的安装和使用以及各种问题处理
官方的git地址:https://github.com/getsentry/onpremise 需要先安装docker 1.10版本以上 假设你已经安装完docker,那么接下来 安装docker-c ...
- Spring Cloud和Spring Boot的区别
Spring MVC: Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 MVC ...
- IDL实现矢量文件裁剪栅格数据
利用ENVI_SUBSET_VIA_ROI_DOIT函数实现矢量文件裁剪栅格数据. 测试数据:栅格文件是Mercator投影,矢量文件是Geographic坐标系 infile='F:\Temp_Da ...
- Jeecg-Boot 1.0版本发布,企业级快速开发平台
Jeecg-Boot 一款基于代码生成器的J2EE快速开发框架! 采用前后端分离技术: SpringBoot,Mybatis-plus,Shiro,JWT,Vue & Ant Design. ...
- web跨域问题(No 'Access-Control-Allow-Origin'..)
1. 问题 angular开发中连接java服务时出现跨域问题(No 'Access-Control-Allow-Origin'..). 如下图 解决方法 2,原因分析 这个与安全机制有关,默认情况下 ...