thrift

Thrift学习笔记—IDL基本类型

自闭症网瘾萝莉.ら 提交于 2019-12-01 08:36:50
原文地址: http://zhwen.org/xlog/?p=658 thrift 采用 IDL ( Interface Definition Language )来定义通用的服务接口,并通过生成不同的语言代理实现来达到跨语言、平台的功能。在 thrift 的 IDL 中可以定义以下一些类型:基本数据类型,结构体,容器,异常、服务 1 基本类型 bool: 布尔值 (true or false), one byte byte: 有符号字节 i16: 16 位有符号整型 i32: 32 位有符号整型 i64: 64 位有符号整型 double: 64 位浮点型 string: Encoding agnostic text or binary string 基本类型中基本都是有符号数,因为有些语言没有无符号数,所以 Thrift 不支持无符号整型。 2 特殊类型 binary: Blob (byte array) a sequence of unencoded bytes 这是 string 类型的一种变形,主要是为 java 使用,目前我主要使用 C++ 的语言,所以 java 的这个类型没有用过 3 struct thrift 中 struct 是定义为一种对象,和面向对象语言的 class 差不多 ., 但是 struct 有以下一些约束: struct 不能继承,但是可以嵌套

Thrift RPC基础学习总结

家住魔仙堡 提交于 2019-12-01 08:36:36
一.什么是Thrift? Thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发。它结合了功能强大的软件堆栈和代码生成引擎,以构建在 C++、Java、Python、PHP、Ruby、Erlang、Perl、Haskell、C#、Cocoa、JavaScript、Node.js、Smalltalk、and OCaml 等等编程语言间无缝结合的、高效的服务。 Thrift最初由facebook开发,07年四月开放源码,08年5月进入Apache孵化器。Thrift允许你定义一个简单的定义文件中的数据类型和服务接口。以作为输入文件,编译器生成代码用来方便地生成RPC客户端和服务器通信的无缝跨编程语言。 官网地址: thrift.apache.org 二、Thrift的基础 基本类型: bool:布尔值,true 或 false,对应 Java 的 boolean byte:8 位有符号整数,对应 Java 的 byte i16:16 位有符号整数,对应 Java 的 short i32:32 位有符号整数,对应 Java 的 int i64:64 位有符号整数,对应 Java 的 long double:64 位浮点数,对应 Java 的 double string:utf-8编码的字符串,对应 Java 的 String 结构体类型: struct:定义公共的对象,类似于 C

Service Multiplexing using Apache Thrift

耗尽温柔 提交于 2019-12-01 07:36:06
Server code: TMultiplexedProcessor processor = new TMultiplexedProcessor(); processor.registerProcessor( "AddService", new AddService.Processor(new AddHandler())); processor.registerProcessor( "MultiplyService", new MultiplyService.Processor(new MultiplyHandler())); TServerTransport serverTransport = new TServerSocket(7911); TSimpleServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport). processor(processor)); System.out.println("Starting server on port 7911 ..."); server.serve(); Client Code: TFramedTransport transport; transport = new TFramedTransport(new TSocket("localhost

基于Docker + Consul + Nginx + Consul-Template的服务负载均衡实现(转)

大兔子大兔子 提交于 2019-12-01 07:25:00
前言 上一篇文章使用 Consul 和 Registrator 在 docker 的容器环境中搭建了服务注册和发现集群。在服务发现和注册的基础上,本文将引入 Nginx 反向代理服务器和 Consul-template 组件,实现动态的服务负载均衡。 正文 1. 工具介绍 1.1. Nginx 一个高性能的 HTTP 和反向代理服务器,用于前端访问流量到后台应用服务器负载均衡和请求转发。 1.2. Consul-template Consul-template 是 HashiCorp 基于 Consul 所提供的可扩展的工具,通过监听 Consul 中的数据变化,动态地修改一些配置文件中地模板。常用于在 Nginx 、 HAProxy 上动态配置健康状态下的客户端反向代理信息。 2. 实现原理 通过 Nginx 自身实现负载均衡和请求转发; 通过 Consul-template 的 config 功能实时监控 Consul 集群节点的服务和数据的变化; 实时的用 Consul 节点的信息替换 Nginx 配置文件的模板,并重新加载配置文件; Consul-template 和 nginx 必须安装在同一台机器上,因为 Consul-template 需要动态修改 nginx 的配置文件 nginx.conf ,然后执行 nginx -s reload 命令进行路由更新

centos 6.5(centos7)下安装thrift 0.9.1详细教程

有些话、适合烂在心里 提交于 2019-12-01 04:23:54
进行Thrift的最小化安装,在Centos 6.5 上下面的步骤必不可少. 我们给出从源代码编译Thrift的例子。这些介绍对Thrift0.9.2 的 releases版本同样有效。 更新系统 sudo yum -y update (系统会被升级为6.7) 安装平台开发工具 sudo yum -y groupinstall "Development Tools" (这一步不一定成功,但是不影响后面) 升级autoconf/automake/bison sudo yum install -y wget 升级 autoconf wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz tar xvf autoconf-2.69.tar.gz cd autoconf-2.69 ./configure --prefix=/usr make sudo make install cd .. 升级 automake wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz tar xvf automake-1.14.tar.gz cd automake-1.14 ./configure --prefix=/usr make sudo make install cd .. 升级

Thrift的使用-Python

本小妞迷上赌 提交于 2019-12-01 02:57:00
百科简介:Thrift是一种接口描述语言和二进制通讯协议,它被用来定义和创建跨语言的服务。它被当作一个 远程过程调用 (RPC)框架来使用,是由 Facebook 为“大规模跨语言服务开发”而开发的。它通过一个代码生成引擎联合了一个软件栈,来创建不同程度的、无缝的 跨平台 高效服务,可以使用 C# 、 C++ (基于 POSIX 兼容系统)、Cappuccino、 Cocoa 、 Delphi 、 Erlang 、 Go 、 Haskell 、 Java 、 Node.js 、 OCaml 、 Perl 、 PHP 、 Python 、 Ruby 和 Smalltalk 。虽然它以前是由Facebook开发的,但它现在是 Apache软件基金会 的 开源 项目了。该实现被描述在2007年4月的一篇由Facebook发表的技术论文中,该论文现由Apache掌管。 thrift主页:http://thrift.apache.org thrift下载: thrift-0.12.0.tar.gz 解压安装不多说^_^ (Mac用户直接使用$ brew install thrift 安装即可) 在python程序中使用thrift需要安装thrift模块,pip install thrift 即可 thrift 采用IDL(Interface Definition Language

Cassandra CQL method for paging through all rows

独自空忆成欢 提交于 2019-12-01 01:08:30
I want to programmatically examine all the rows in a large cassandra table, and was hoping to use CQL. I know I could do this with thrift, getting 10,000 (or so) rows at a time with multiget and handing the last retrieved key into to the next multiget call. But I have looked through all the documentation on CQL select, and there doesn't seem to be a way to do this. I have resorted to setting the select limit higher and higher, and setting the timeout higher and higher to match it. Is there an undocumented way to hand in a starting point to CQL select, or do I just need to break down and

HBase Thrift: how to connect to remote HBase master/cluster?

自古美人都是妖i 提交于 2019-11-30 22:41:30
Thanks to the Cloudera distribution, I have a HBase master/datanode + Thrift server running on a local machine, and can code and test HBase client programs and use it, no problem. However, I now need to use Thrift in production, and I'm not able to find documentation on how to get Thrift running with a production HBase cluster. From what I understand, I will need to run the hbase-thrift program on the client node since the Thrift program is just another intermediate client to HBase. So I'm guessing that I have to be able to somehow specify the master node hostname/IP to HBase-Thrift? How would

0039-如何使用Python Impyla客户端连接Hive和Impala

不羁的心 提交于 2019-11-30 22:21:34
温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。 1.文档编写目的 继上一章讲述 如何在CDH集群安装Anaconda&搭建Python私有源 后,本章节主要讲述如何使用Pyton Impyla客户端连接CDH集群的HiveServer2和Impala Daemon,并进行SQL操作。 内容概述 1.依赖包安装 2.代码编写 3.代码测试 测试环境 1.CM和CDH版本为5.11.2 2.RedHat7.2 前置条件 1.CDH集群环境正常运行 2.Anaconda已安装并配置环境变量 3.pip工具能够正常安装Python包 4.Python版本2.6+ or 3.3+ 5.非安全集群环境 2.Impyla依赖包安装 Impyla所依赖的Python包 six bit_array thrift (on Python 2.x) orthriftpy (on Python 3.x) thrift_sasl sasl 1.首先安装Impyla依赖的Python包 [root@ip-172-31-22-86 ~]# pip install bit_array [root@ip-172-31-22-86 ~]# pip install thrift==0.9.3 [root@ip-172-31-22-86 ~]# pip install six [root@ip-172-31

【Java】分布式RPC通信框架Apache Thrift 使用总结

↘锁芯ラ 提交于 2019-11-30 18:50:34
简介   Apache Thrift是Facebook开源的跨语言的RPC通信框架,目前已经捐献给Apache基金会管理,由于其跨语言特性和出色的性能,在很多互联网公司得到应用,有能力的公司甚至会基于thrift研发一套分布式服务框架,增加诸如服务注册、服务发现等功能。   RPC即Remote Procedure Call,翻译为远程过程调用。任何RPC协议的实现终极目标都是让使用者在调用远程方法的时候就像是调用本地方法一样简单,从而提高使用远程服务的效率。   现代互联网架构多数基于SOA思想而搭建,即面向服务化的架构。服务提供方称为Provider,服务的使用方称为Consumer,有时也把服务提供方称为Server端,使用方称为Client端,即典型的CS模型。这里的远程调用,主要指跨进程的调用,Provider和Consumer可能是同一机器的不同进程,也可能在不同的机器,通过网络相互通信,大部分情况下两者会部署在不同的物理机器上,这种情况下由于网络通信的开销就会对RPC框架的性能要求极高。 下面分别从服务端和客户端的视角来介绍Thrift在RPC中的应用。 服务端(Server) 服务端需要发布一个服务给别人使用,首先要约定好服务的接口,包括以下几个部分: 服务的名称 服务使用时的参数 返回结果 Thrift自己规定了一套接口定义语言(IDL)来描述服务,用后缀为