一.创建server端

public class ManualDRPC {

    private static final Logger LOG = LoggerFactory.getLogger(ManualDRPC.class);

    public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException {

        TopologyBuilder builder = new TopologyBuilder();

        DRPCSpout spout = new DRPCSpout("add");
builder.setSpout("drpc", spout);
builder.setBolt("add", new AddBolt(),3).shuffleGrouping("drpc");
builder.setBolt("return", new ReturnResults(),3).shuffleGrouping("add"); Config conf = new Config();
StormSubmitter.submitTopology("ManualDRPC", conf, builder.createTopology());
LOG.warn("==================================================");
LOG.warn("the topology {} is submitted.","ManualDRPC");
LOG.warn("=================================================="); }
public static class AddBolt extends BaseBasicBolt{ @Override
public void execute(Tuple input, BasicOutputCollector collector) {
Object returnInfo = input.getValue(1);
String params = input.getString(0);
String[] numbers = params.split(",");
String conversValue = String.valueOf(Integer.parseInt(numbers[0]) + Integer.parseInt(numbers[1]));
collector.emit(new Values(conversValue,returnInfo));
} @Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("result","return-info"));
} }
}

二.client端

public class ManualClientDRPC {

    private static final Logger LOG = LoggerFactory.getLogger(ManualClientDRPC.class);

    public static void main(String[] args) {
Config conf = new Config();
conf.put("storm.thrift.transport", "org.apache.storm.security.auth.plain.PlainSaslTransportPlugin");
conf.put(Config.STORM_NIMBUS_RETRY_TIMES, 3);
conf.put(Config.STORM_NIMBUS_RETRY_INTERVAL, 10);
conf.put(Config.STORM_NIMBUS_RETRY_INTERVAL_CEILING, 20); try {
DRPCClient client = new DRPCClient(conf, "master", 3777);
String result = client.execute("add", "1,2");
LOG.info("============== result:{}",result);
} catch (Exception e) {
LOG.info("ERR");
}
}
}

storm manual drpc 的远程调用的更多相关文章

  1. dotNET使用DRPC远程调用运行在Storm上的Topology

    Distributed RPC(DRPC)是Storm构建在Thrift协议上的RPC的实现,DRPC使得你可以通过多种语言远程的使用Storm集群的计算能力.DRPC并非Storm的基础特性,但它确 ...

  2. Storm的DRPC

    RPC:Remote Procedure Call DRPC:Distributed RPC Hadoop提供了RPC的实现机制,实现方法见:<>,本文主要介绍Storm的DRPC.   ...

  3. C#远程调用技术WebService修炼手册

    一.课程介绍 一位伟大的讲师曾经说过一句话:事物存在即合理!意思就是说:任何存在的事物都有其存在的原因,存在的一切事物都可以找到其存在的理由,我们应当把焦点放在因果关联的本质上.所以在本次分享课开课之 ...

  4. Storm对DRPC权限控制Version1.0.1

    对Storm的DRPC进行权限控制, 并且设计相应的测试验证. 1.集群安装 请参考Storm集群安装Version1.0.1 2.使用DRPC功能 请参考Storm集群使用DRPC功能Version ...

  5. 架构设计:远程调用服务架构设计及zookeeper技术详解(下篇)

    一.下篇开头的废话 终于开写下篇了,这也是我写远程调用框架的第三篇文章,前两篇都被博客园作为[编辑推荐]的文章,很兴奋哦,嘿嘿~~~~,本人是个很臭美的人,一定得要截图为证: 今天是2014年的第一天 ...

  6. 架构设计:一种远程调用服务的设计构思(zookeeper的一种应用实践)

    在深入学习zookeeper我想先给大家介绍一个和zookeeper相关的应用实例,我把这个实例命名为远程调用服务.通过对这种应用实例的描述,我们会对zookeeper应用场景会有深入的了解. 远程调 ...

  7. 【Java EE 学习 78 中】【数据采集系统第十天】【Spring远程调用】

    一.远程调用概述 1.远程调用的定义 在一个程序中就像调用本地中的方法一样调用另外一个远程程序中的方法,但是整个过程对本地完全透明,这就是远程调用.spring已经能够非常成熟的完成该项功能了. 2. ...

  8. 深入浅出Alljoyn——实例分析之远程调用(Method)篇

    深入浅出就是很深入的学习了很久,还是只学了毛皮,呵呵! 服务端完整代码: #include <qcc/platform.h> #include <assert.h> #incl ...

  9. .Net组件程序设计之远程调用(二)

    .Net组件程序设计之远程调用(二) 激活模式 引用封送对象激活类型两种, 一种是客户端激活类型,一种是服务器端激活. 客户端激活对象 客户端激活方式:当客户端创建一个远程对象时,客户端得到的是一个新 ...

随机推荐

  1. 解决GitHub下载速度太慢的问题

    更改hosts文件: Windows 更改C:\Windows\System32\drivers\etc\hosts文件,在文件中追加219.76.4.4 github-cloud.s3.amazon ...

  2. Laravel API Errors and Exceptions: How to Return Responses

    Laravel API Errors and Exceptions: How to Return Responses February 13, 2019 API-based projects are ...

  3. leetcode解题报告(10):Merge Two Sorted Lists

    描述 Merge two sorted linked lists and return it as a new list. > The new list should be made by sp ...

  4. 【概率论】4-1:随机变量的期望(The Expectation of a Random Variable Part II)

    title: [概率论]4-1:随机变量的期望(The Expectation of a Random Variable Part II) categories: - Mathematic - Pro ...

  5. 【概率论】2-1:条件概率(Conditional Probability)

    title: [概率论]2-1:条件概率(Conditional Probability) categories: Mathematic Probability keywords: Condition ...

  6. 工作流调度系统Azkaban的简介和使用

    1 概述 1.1 为什么需要工作流调度系统 l 一个完整的数据分析系统通常都是由大量任务单元组成: shell脚本程序,java程序,mapreduce程序.hive脚本等 l 各任务单元之间存在时间 ...

  7. iptables 查看对应规则及端口号

    iptables -L -n --line-number

  8. 能不能支持在线查看word,excel这样的文件?还有拖拽上传功能?

    https://forum.enhancer.io/topic/5adea0cdce69735af635fcd8 方法1. 用一个自定义窗口, 自定义窗口里放一个iframe 假设你的 word 的地 ...

  9. DELPHI安卓定位权限申请

    DELPHI安卓定位权限申请 安卓8及以后版本的权限分为静态和动态申请2部分,而之前的安卓版本只需要静态申请权限. 1)静态申请定位权限: 2)动态申请定位权限: uses System.Permis ...

  10. nginx - nginx下配置thinkphp5

    首先tp5的访问目录指向到webroot/public文件夹中.thinkphp的url访问:http://serverName/index.php(或者其它应用入口文件)/模块/控制器/操作/[参数 ...