advertisement

An introduction to Apache Thrift

43 %
57 %
advertisement
Information about An introduction to Apache Thrift
Technology

Published on December 28, 2013

Author: mikejf12

Source: slideshare.net

Description

A short introduction to Apache Thrift, what is it and how does it work ?
How can it help to define multi language client/server interfaces ?
advertisement

Apache Thrift ● What is it ? ● Languages ● Process ● Architecture ● Example www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – What is it ? ● A multi language software framework ● For client / services development ● It is scaleable ● Uses a compiler to generate source code ● Released with Apache 2 License ● Uses an IDL ( interface descripton language ) ● Originally developed at Facebook www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Languages Languages supported – C++ Cocoa – Java JavaScript – Python Node.js – PHP Smalltalk – Ruby OCaml – Erlang Delphi – Perl ..... and others – Haskell – C# www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Process So how do we start to create a Thrift based app ? – We define a Thrift file – Which includes our interface definition ● Defines our Thrift types ● Defines our services Our clients will be able to call our services – We now use the Thrift compiler – thrift --gen <language> <Thrift file> To generate our source code – Now we add our extra client / server functionality ● ● www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Service www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Where used ? So who is using Thrift ? – Cassandra – Scribe – Hadoop – Hbase – ThriftDB – Others ......... www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift Architecture www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Example (Java) Create Thrift interface file # time.thrift namespace java tserver.gen typedef i64 Timestamp service TimeServer { Timestamp time() } Compile to Java code thrift --gen java time.thrift www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Example Create interface in TimeServerImpl.java package server; import org.apache.thrift.TException; import tserver.gen.*; class TimeServerImpl implements TimeServer.Iface { @Override public long time() throws TException { long time = System.currentTimeMillis(); System.out.println("time() called: " + time); return time; } } www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Example – Java Server package server; import java.io.IOException; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TBinaryProtocol.Factory; import org.apache.thrift.server.TServer; import org.apache.thrift.server.TThreadPoolServer; import org.apache.thrift.transport.TServerSocket; import org.apache.thrift.transport.TTransportException; import tserver.gen.TimeServer; public class Server { private void start(){ try { TServerSocket serverTransport = new TServerSocket(7911); TimeServer.Processor processor = new TimeServer.Processor(new TimeServerImpl()); Factory protFactory = new TBinaryProtocol.Factory(true, true); TServer server = new TThreadPoolServer(processor, serverTransport, protFactory); System.out.println("Starting server on port 7911 ..."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String args[]){ Server srv = new Server(); srv.start(); } } www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Apache Thrift – Example – Java Client package client; import java.net.SocketException; import org.apache.thrift.TException; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; import tserver.gen.TimeServer.Client; public class TimeClient { private void start(){ TTransport transport; try { transport = new TSocket("localhost", 7911); TProtocol protocol = new TBinaryProtocol(transport);Client client = new Client(protocol); transport.open(); long time = client.time(); System.out.println("Time from server:" + time); transport.close(); } catch (SocketException e) { e.printStackTrace(); } catch (TTransportException e) { e.printStackTrace();} catch (TException e) { e.printStackTrace(); } } public static void main(String[] args) { TimeClient c = new TimeClient(); c.start(); } } www.semtech-solutions.co.nz info@semtech-solutions.co.nz

Contact Us ● Feel free to contact us at – www.semtech-solutions.co.nz – info@semtech-solutions.co.nz ● We offer IT project consultancy ● We are happy to hear about your problems ● You can just pay for those hours that you need ● To solve your problems

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Apache Thrift - Java

Introduction¶ All Apache Thrift tutorials require that you have: Built and installed the Apache Thrift Compiler and Libraries, ... Apache, Apache Thrift, ...
Read more

Introduction to Apache Thrift | Edureka - YouTube

... http://www.edureka.co/cassandra?utm_source=youtube&utm_medium=referral&utm_campaign=apache-thrift ... Introduction To Apache ...
Read more

Introduction to Apache Thrift - Edureka Blog

Introduction to Apache Thrift. Thrift is basically a driver level interface that provides API for client implementation. In other words you will know the ...
Read more

Apache Thrift - PHP

Introduction¶ All Apache Thrift tutorials require that you have: Built and installed the Apache Thrift Compiler and Libraries, ... Apache, Apache Thrift, ...
Read more

An introduction to Apache Thrift - YouTube

A short introduction to Apache Thrift, what is it and how does it work ? How can it help to define multi language client/server interfaces ?
Read more

An introduction to Apache Thrift - es.scribd.com

An introduction to Apache Thrift - Free download as PDF File (.pdf), Text File (.txt) or view presentation slides online.
Read more

Introduction to Thrift — Thrift Tutorial 1.0 documentation

Introduction to Thrift; ... Thrift was originally developed by Facebook and now it is open sourced as an Apache project. Apache Thrift is a set of code ...
Read more

SETT June 2009 - Apache Thrift

Apache Thrift. by Andrew Prunicki, Senior Software Engineer Object Computing, Inc. (OCI) Introduction. Thrift is a framework for creating interoperable and ...
Read more