一、配置集群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. 【Nginx】实现负载均衡

    负载均衡是什么? 当一台服务器的单位时间内的访问量越大时,服务器压力就越大,大到超过自身承受能力时,服务器就会崩溃.为了避免服务器崩溃,让用户有更好的体验,我们通过负载均衡的方式来分担服务器压力. 我 ...

  2. Could not create local repository at /home/yizhenn/.m、IDEA倒入maven项目无法导报问题

    问题描述: 用自己电脑新搭建环境,用idea倒入项目后发现无法倒入jar包,很少郁闷,折腾了很久,最终发现问题 settings文件中下面这个配置,需要是自己电脑的路径 <localReposi ...

  3. 逆向工程vgenerator(一)

    前言 想要自己实现一个mybatis-generator类似的轮子,目前只实现MySQL部分的方法.利用下班时间,写了一个小项目,实现了这个功能.我准备分成三篇博客来写这个东西. 基类 /** *基类 ...

  4. 编译pcre 报错 error: Invalid C++ compiler or C++ compiler flags

    安装c++ 编译器:yum -y install gcc-c++ ,再次编译通过.

  5. go 0000

    1,函数不能比较 函数默认都是值传递,  除了  map   值, slice (切片)  channel  (管道)   interface 默认以这4个默认 引用传递 两个 defer      ...

  6. idea使用

    一.IDEA 的下载及安装 打开IDEA的官网,如:http://www.jetbrains.com/ 然后到了主界面,点击下载如图:   图1 我们这里下载zip的,将它下载到你要保存的目录下,其次 ...

  7. git版本冲突解决

    1. 使用git log命令查看所有的历史版本,获取某个历史版本的id,假设查到历史版本的id是139dcfaa558e3276b30b6b2e5cbbb9c00bbdca96. git log 2. ...

  8. SQL SERVER 2019新功能

    1.错误代码行 BEGIN TRY    SELECT 1/0END TRYBEGIN CATCH    THROW END CATCH2.二级制截断列名值 chose语法

  9. Springboot中对Service层进行集成测试时注意点

    @SpringBootTest(classes = {DataSourceAutoConfiguration.class,MybatisAutoConfiguration.class,****Impl ...

  10. MySQL相关sql语句

    登陆mysql: mysql -hlocalhost -uroot -proot 创建数据库:create database dbname charset utf8 查看数据库:show databa ...