thrift

Apache thrift: client timeout issues

喜夏-厌秋 提交于 2019-11-29 17:52:01
问题 I have some Apache Thrift (v.0.6.1) test application with perl-server and php-client. The behaviour I cannot explain: If we call server-method with invalid argument we see the error in server-output, but php-client stays waiting the response infinitely. Here are the sources of server: sub new { my $classname = shift; my $self = {}; return bless($self,$classname); } sub DateToTimestamp { my ($self, $date) = @_; my $result = CommonAPI::DateToTimestamp($date); return $result; } eval { my

Is there a Thrift or Cassandra client for Node.js/JavaScript

∥☆過路亽.° 提交于 2019-11-29 16:50:51
问题 I would like to start using Cassandra with a node.js deployment, but I can't find a Thrift or Cassandra client for Node.js and/or JavaScript. Is there one? Is there a simple means of generating Thrift connections? Update: The short answer to this question turns out to be no, there is no JS client for Thrift that is compatible with Cassandra. Further Update: The next release of Cassandra (0.8 at time of writing) is going to have support for an Avro API. There is already node.js module for Avro

thrift详解

让人想犯罪 __ 提交于 2019-11-29 14:28:20
背景 thrift最早由facebook开发,后来贡献给了apache。thrift主要解决跨语言调用的问题。 thrift和protobuf有啥区别? thrift和protobuf,都解决了一个问题就是夸语言数据结构的定义,json也解决了跨语言的数据结构定义,只不过json都是字符串的,传输的开销和解析的开销可能有些大。那么想传输二进制的话怎么办呢,可以自己定义数据结构,比如大家熟知的网络协议就是这么定出来的,前1个字节代表啥啥啥,第二个字节代表啥啥啥,然后客户端和服务端都遵守这个协议。在没有thrift或者profobuf之前好多cs程序就是这么干的。但是这么干很累啊,还得写文档,而且开发时候也不好记,不好交流。后来人们想出了个办法,就是用一个类似json格式的文件定义数据结构,然后自动生成代码去处理二进制的转换,这样人们既可以用好读的格式定义数据结构,又可以高效的使用,于是就诞生了protobuf和thrift这类东西。protobuf到此为止了,thrift又把服务端程序和客户端程序也顺手加进去可以自动生成了,这样程序员就只负责写业务逻辑,其他的传输啊神马的都自动生成了,这就是protobuf和thrift的区别。这样thrift就有了全套的RPC机制, 为什么要跨语言调用? 有人认为是团队需要,不同的人擅长不同的语言,我认为从架构的角度想,有2点好处

Thrift原理及过程

倾然丶 夕夏残阳落幕 提交于 2019-11-29 13:52:17
一:概念 Thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发。它结合了功能强大的软件堆栈和代码生成引擎,以构建在 C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml 等等编程语言间无缝结合的、高效的服务。 二:过程 (1) 通过IDL(接口描述语言)定义一个接口的thrift文件,然后通过thrift的多语言编译功能,将接口定义的thrift文件翻译成对应的语言版本的接口文件; (2) Thrift生成的特定语言的接口文件中包括客户端部分和服务器部分; (3) 客户端通过接口文件中的客户端部分生成一个Client对象,这个客户端对象中包含所有接口函数的存根实现,然后用户代码就可以通过这个Client对象来调用thrift文件中的那些接口函数了,但是,客户端调用接口函数时实际上调用的是接口函数的本地存根实现,如图3.2中的箭头1所示; (4) 接口函数的存根实现将调用请求发送给thrift服务器端,然后thrift服务器根据调用的函数名和函数参数,调用实际的实现函数来完成具体的操作,如图3.2中的箭头2所示; (5) Thrift服务器在完成处理之后,将函数的返回值发送给调用的Client对象;如图3

Thrift API load test

◇◆丶佛笑我妖孽 提交于 2019-11-29 13:06:25
I am new into Apache Jmeter. Basically I want to load test our couple of thrift APIs but have no clue where to start with. It is in java where api takes 2 parameter and then send java object as response. Any pointer would be very helpful. You can use JSR223 Sampler + Groovy (add groovy-all.jar in jmeter/lib) and look at this client example, see NonblockingClient code for an example: http://www.javacodegeeks.com/2012/03/apache-thrift-quickstart-tutorial.html Make your groovy code call a least the following at end: SampleResult.setSuccessful(true/false) SampleResult.setResponseCode("code")

Preloading java classes/libraries at jar startup?

五迷三道 提交于 2019-11-29 10:21:02
I've written a Thrift server in Java to take advantage of a specific Java package/library, but I'm not a java programmer. The problem is; I'm seeing a time-out for the first RPC call to the server. Subsequest requests are executed without any issues, and its only affecting clients written in certain (but essential) languages. My current thought is that the server times-out on the response because upon first call it has to load all the libraries required for the request. Some Thrift client implementations must be handling the time-out better than others, possibly keeping the request open a

js中应用protocol buffer

六月ゝ 毕业季﹏ 提交于 2019-11-29 05:44:17
前段时间公司项目需要用到protocol buffer数据传输协议,这是什么东西,根本没接触过,好好的json干嘛不用?怀着好奇心去了解学习,最后顺利运用。下面是一些是经验,希望能帮到一些人。 首先我们要知道什么是protocol buffer protocolbuffer (以下简称PB)是google 的一种数据交换的格式,它独立于语言,独立于平台。 类似于XML,JSON这样的数据表示语言, ProtocolBuffer是用于结构化数据串行化的灵活、高效、自动的方法,格式有点类似XML,可以自己定义数据格式,它是一种二进制格式允许你使用规范的语言定义一个模式。 基本语法 普通消息 message SearchRequest { required string query = 1; optional int32 page_number = 2; optional int32 result_per_page = 3; } 指定字段规则 所指定的消息字段修饰符必须是如下之一: ² required:一个格式良好的消息一定要含有1个这种字段。表示该值是必须要设置的; ² optional:消息格式中该字段可以有0个或1个值(不超过1个)。 ² repeated:在一个格式良好的消息中,这种字段可以重复任意多次(包括0次)。重复的值的顺序会被保留。表示该值可以重复

Thrift代理Hbase

早过忘川 提交于 2019-11-29 03:54:57
使用HBase的2种方式: 1.直接使用HBase客户端API,这样就限制了只能使用java语言 2.使用一些能够将请求转换成API的代理,这些代理将原始Java API包装成其他协议,这样客户端可以使用API提供的任意外部语言来编写程序。外部API实现了专门基于java的服务,而这种服务能够在内部使用由HTable客户端提供的API。 HBase本身对代理模式的支持也很广泛,比如支持的类型有:REST、Thrift、Avro等 关于代理的模式,可以看一张网上的架构图: 这里主要介绍一下Thrift作为HBase的代理对外提供服务,主要是Thrift在性能上的优势以及对各种主流语言的支持 1.安装HBase和Hadoop Hadoop版本:2.5.1 Hbase版本:1.2.2 参考之前的文章: Hadoop的版本选择和单机模式: http://codingo.xyz/index.php/2016/08/16/hadoop-stand-alone/ Hadoop的伪分布式模式: http://codingo.xyz/index.php/2016/08/16/hadoop_false_distribute/ Hbase版本选择和单机模式入门: http://codingo.xyz/index.php/2016/08/17/hbase_standalone/ Hbase的伪分布式模式:

Apache Thrift

丶灬走出姿态 提交于 2019-11-29 02:28:30
前言: 目前流行的服务调用方式有很多种,例如基于 SOAP 消息格式的 Web Service,基于 JSON 消息格式的 RESTful 服务等。其中所用到的数据传输方式包括 XML,JSON 等,然而 XML 相对体积太大,传输效率低,JSON 体积较小,新颖,但还不够完善。本文将介绍由 Facebook 开发的远程服务调用框架 Apache Thrift,它采用接口描述语言定义并创建服务,支持可扩展的跨语言服务开发,所包含的代码生成引擎可以在多种语言中,如 C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk 等创建高效的、无缝的服务,其传输数据采用二进制格式,相对 XML 和 JSON 体积更小,对于高并发、大数据量和多语言的环境更有优势。本文将详细介绍 Thrift 的使用,并且提供丰富的实例代码加以解释说明,帮助使用者快速构建服务。 一个简单的 Thrift 实例 本文首先介绍一个简单的 Thrift 实现实例,使读者能够快速直观地了解什么是 Thrift 以及如何使用 Thrift 构建服务。 创建一个简单的服务 Hello。首先根据 Thrift 的语法规范编写脚本文件 Hello.thrift,代码如下: 清单 1. Hello.thrift namespace java

maven can't add files in generated-sources for compilation phase

ぃ、小莉子 提交于 2019-11-29 01:27:08
I use Apache Thrift to generate code in target/generated-sources . The Thrift compiler produces a directory named gen-java which contains all the Java code. When I execute mvn compile , the code is generated correctly in target/generated-source/gen-java , but in compilation phase, it complains can't find the classes which defined in gen-java . In my understanding, Maven 2 automatically adds generated sources, is that right? And what if my testing code also depends on the generated-sources , do I have to manually specified the compiler includes? Pascal Thivent In my understanding, maven 2