Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

아파치 쓰리프트 (Apache Thrift)

6,413 views

Published on

Scalable Cross-Language Services을 위한 아파치 쓰리프트 (Apache Thrift) 에 대한 이해와 사용방법

Published in: Technology
  • Dating for everyone is here: ❤❤❤ http://bit.ly/2F90ZZC ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Sex in your area is here: ♥♥♥ http://bit.ly/2F90ZZC ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes ,Download or read Ebooks here ... ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M }
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

아파치 쓰리프트 (Apache Thrift)

  1. 1. Apache Thrift Jinwook Jeong mrg721@gmail.com For Scalable Cross-Language Services
  2. 2. Thrift Thrift란? • The Apache Thrift software framework, for scalable cross- language services development
  3. 3. Thrift Thrift 역사 • 2007년까지 Facebook에서 개발, 이후에는 아파치 소프트웨어 재단
  4. 4. Thrift Thrift와 Protocol Buffer와 비교 Thrift Protocol Buffer 개발사 Facebook  Apache Google 채택사 Facebook, Hadoop (Eco System 관련) Google 사용자 많다 보통 지원 대부분 C++,java,python 지원기능 많다 적은편 자료형지원 Map, List, Set등 지원 지원안함
  5. 5. Thrift Thrift 설치 • 설치준비 필요환경 – https://thrift.apache.org/docs/install/ – Basic requirements • A relatively POSIX-compliant *NIX system • Cygwin or MinGW can be used on Windows (but there are better options, see below) • g++ 4.2 • boost 1.53.0 • Runtime libraries for lex and yacc might be needed for the compiler. – Requirements for building from source • GNU build tools: • autoconf 2.65 • automake 1.13 • libtool 1.5.24 • pkg-config autoconf macros (pkg.m4) • lex and yacc (developed primarily with flex and bison) • libssl-dev – Requirements for building the compiler from source on Windows • Visual Studio C++ • Flex and Bison (e.g. the WinFlexBison package) ...
  6. 6. Thrift Thrift 설치 • Thrift 설치환경준비 sudo yum -y update sudo yum -y groupinstall "Development Tools" sudo yum install -y wget 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 .. 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 .. https://thrift.apache.org/docs/install/centos
  7. 7. Thrift Thrift 설치 • Thrift 설치환경준비 wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz tar xvf bison-2.5.1.tar.gz cd bison-2.5.1 ./configure --prefix=/usr make sudo make install cd .. git clone https://git-wip-us.apache.org/repos/asf/thrift.git cd thrift ./bootstrap.sh ./configure --with-lua=no make sudo make install
  8. 8. Thrift Thrift 프로젝트 생성 • Ant 다운로드 및 설치 – yum -y install ant 이후, Thrift 압축해제 디렉터리에 가서 다음 명령어를 실행함 – ant -Dproxy.enabled=1 -Dproxy.host=myproxyhost -Dproxy.user=thriftuser - Dproxy.pass=topsecret https://thrift.apache.org/lib/java
  9. 9. Thrift Thrift 프로젝트 생성 • Thrift 코드 Import시 의존라이브러리 – 아래 의존라이브러리를 다운로드후 ‘add JAR’하여 프로젝트에 포함 – slf4j • http://www.slf4j.org/dist/ • slf4j-api-1.7.9.jar – Libthrift • http://repo1.maven.org/maven2/org/apache/thrift/libthrift/0.9.2/ • libthrift-0.9.2.jar
  10. 10. Thrift Thrift Interface Description Language • Thrift I.D.L 작성 – 공통으로 사용할 인터페이스를 정의합니다. namespace java tutorial.arithmetic.gen namespace js tutorial.arithmetic.gen //Namespace setting for each programming language typedef i64 long typedef i32 int service ArithmeticService { // defines simple arithmetic service long add(1:int num1, 2:int num2), long multiply(1:int num1, 2:int num2), } Thrift –gen java calc.thrift로 java코드 생성시 파일명과 서비스명이됨 < calc.thrift > https://thrift.apache.org/docs/idl
  11. 11. Thrift Thrift I.D.L에 기반한 인터페이스 코드 생성 • IDL기반 언어별 Thrift 인터페이스 생성 • Node.JS 예 – gen-node에 생성됨 • JAVA 예 $ thrift --gen java calc.thrift thrift --gen <language> <Thrift filename> thrift --gen js:node calc.thrift
  12. 12. Thrift Thrift 서버 • Java 인터페이스 코드생성 – # thrift --gen java calc.thrift – ‘namespace java tutorial.arithmetic.gen’에 따라 디렉터리 생성됨 – Tutorial 디렉터리를 자바 프로젝트 폴더로 옮김
  13. 13. Thrift Thrift 서버 public class Server { private void start() { try { TServerSocket serverTransport = new TServerSocket(7911); ArithmeticService.Processor processor = new ArithmeticService.Processor(new ArithmeticServiceImpl()); TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport). processor(processor)); System.out.println("Starting server on port 7911 ..."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } } public static void main(String[] args) { Server srv = new Server(); srv.start(); } }
  14. 14. Thrift Thrift 서버 public class ArithmeticServiceImpl implements ArithmeticService.Iface{ public long add(int num1, int num2) throws TException { return num1 + num2; } public long multiply(int num1, int num2) throws TException { return num1 * num2; } } https://github.com/Flipkart/phantom/tree/master/sample-thrift-proxy/src/main/java/thrift
  15. 15. Thrift Thrift 클라이언트 • Node.JS에서 thrift 스크립트로 부터 Node인터페이스 생성 – npm install thrift – thrift –gen js.node calc.thrift https://thrift.apache.org/tutorial/nodejs
  16. 16. Thrift Thrift 클라이언트 router.get('/test', function (req, res, next) { var thrift = require('thrift'); var Calculator = require('../gen-nodejs/ArithmeticService'); var ttypes = require('../gen-nodejs/calc_types'); var connection = thrift.createConnection("localhost", 7911); var client = thrift.createClient(Calculator, connection); connection.on('error', function (err) { console.error(err); }); client.multiply(100,200, function(err, response) { console.log("multiply : 100*100=" + response); }); client.add(100,200, function(err, response) { console.log("add : 100+200=" + response); }); res.send('hello world'); });
  17. 17. Thrift Thrift 테스트결과 • 서버실행 (Java) – 제공자 관점 • 클라이언트 실행 (Node.JS) – 요청자 관점

×