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)>之 ...
随机推荐
- cesium3dtiles位置改变
cesium偏移3dtiles高度var heightOffset = 20.0; var boundingSphere = tileset.boundingSphere; var cartograp ...
- 爬虫——BeautifulSoup和Xpath
爬虫我们大概可以分为三部分:爬取——>解析——>存储 一 Beautiful Soup: Beautiful Soup提供一些简单的.python式的函数用来处理导航.搜索.修改分析树等功 ...
- RocketMQ源码分析:(二)消息发送的三种方式
1. 同步传输(可靠,适用于重要的通知消息.短信通知.短信营销系统等) package com.miaoying.rocketmq.client; import lombok.extern.slf4j ...
- Python 有道翻译 爬虫 有道翻译API 突破有道翻译反爬虫机制
py2.7 #coding: utf-8 import time import random import hashlib import requests while(1): url = 'http: ...
- 一文洞悉Python必备50种算法!资深大牛至少得掌握25种!
一.环境需求 二.怎样使用 三.本地化 3.1扩展卡尔曼滤波本地化 3.2无损卡尔曼滤波本地化 3.3粒子滤波本地化 3.4直方图滤波本地化 四.映射 4.1高斯网格映射 4.2光线投射网格映射 4. ...
- C++中字符串换行(如何拆分为多行)
在C/C++语言中,可能我们要书写的一个字符串太长了,放在一行上影响代码的可读性.这时我们就需要多行书写了. 字符串多行书写有两种规则: 1. 在字符串换行处加一个反斜杠’\’,下一行前不能有空 ...
- Excel组合图表快速制作小功能
1. 选中数据区域,插入推荐的图表 2. 然后可以选择快速布局小工具进行布局微调 选中图表 -> 设计(菜单) -> 快速布局(左边) 个人特别喜欢带表格的那个组合图布局,清晰好看
- frist Django app — 一、 创建工程
缘起 既然python都学了,学习python的时候感觉是相见恨晚,一种新的编程语言带给我一种新的思考问题的方式,为了巩固学过的东西并进一步学习python,就想学学Django,看看会不会带给我关于 ...
- springboot性能优化
一.扫描优化 原文链接:http://www.studyshare.cn/blog-front/blog/details/1135 SpringBoot项目中的启动类,会使用@SpringBootAp ...
- Python OS模块,和Open函数
https://www.cnblogs.com/ginvip/p/6439679.html