Always Learning

Advanced Search

Programmer's Guide to Apache Thrift

Programmer's Guide to Apache Thrift

Randy Abernethy

May 2019, Paperback
ISBN13: 9781617296161
ISBN10: 1617296163
Special online offer - Save 30%
Was 44.99, Now 31.49Save: 13.50
  • Print pagePrint page
  • Email this pageEmail page
  • Share

Programmer's Guide to Apache Thrift provides comprehensive coverage of the Apache Thrift framework along with a developer's-eye view of modern distributed application architecture. Packed with complete code examples and pragmatic discussion, this book lays the best practices for multi-language distributed application development. You'll take a guided tour through transports, protocols, IDL and servers as you explore complete example programs in C++, Java and Python. You'll also learn how to work with platforms ranging from enterprise servers to mobile clients.

About the technology

Any distributed application includes individual components, often written in different languages and hosted in multiple locations, which must communicate quickly and efficiently. Apache Thrift is a communication framework that enables cross-language remote procedure calls and serialization. Apache Thrift supports embedded, mobile, web, and server environments and a host of languages ranging from JavaScript to C++. It's perfect for back end services and embedded systems where size, scalability and performance are mission critical.

Key Features

  • Clear, concise coverage of all of the primary Apache Thrift features
  • Complete coverage of the Apache Thrift Interface Definition Language
  • Building and serializing complex user defined types
  • Working with plug in serialization protocols and data compression
  • Creating cross-language services
  • Tools and features to enable interface evolution

Randy Abernethy is an active Apache Thrift contributor and can be found on the dev and user email lists. A serial entrepreneur, Randy founded Hollywood's first all hard disk recording studio in the early 90s, a direct market access institutional brokerage in the 2000s, and has recently focused on the development of proprietary automated trading systems using Apache Thrift for interoperability.

PART 1 APACHE THRIFT OVERVIEWREAD IN LIVEBOOK1. INTRODUCTION TO APACHE THRIFT1.1. Polyglotism, the pleasure and the pain1.2. Application integration with Apache Thrift1.2.1. Type serialization1.2.2. Service implementation1.3. Building a simple service1.3.1. The Hello IDL1.3.2. The Hello server1.3.3. A Python client1.3.4. A C++ client1.3.5. A Java client1.4. The communications toolkit landscape1.4.1. SOAP1.4.2. REST1.4.3. Protocol Buffers1.4.4. Apache Avro1.4.5. Strengths of Apache Thrift1.4.6. Take away1.5. SummaryREAD IN LIVEBOOK2. APACHE THRIFT ARCHITECTURE2.1. Transports2.1.1. The Transport interface2.1.2. End point transports2.1.3. Layered transports2.1.4. Server transports2.2. Protocols2.3. Apache Thrift IDL2.3.1. User-defined types and serialization2.3.2. RPC services2.4. Servers2.5. Security2.6. SummaryREAD IN LIVEBOOK3. BUILDING, TESTING, AND DEBUGGING3.1. Installing the Apache Thrift IDL Compiler3.1.1. Platform installers3.1.2. VMs and containers3.1.3. Building from source3.2. The Apache Thrift source tree3.3. Apache Thrift tests3.4. Debugging RPC services3.4.1. Examining packets on the wire3.4.2. Unbuffered interfaces3.4.3. Interface misalignment3.4.4. I/O stack misalignment3.4.5. Instrumenting code3.4.6. Additional techniques3.5. SummaryPART 2 PROGRAMMING APACHE THRIFTREAD IN LIVEBOOK4. MOVING BYTES WITH TRANSPORTS4.1. End point transports ? part 1: memory & disk4.1.1. Programming with memory transports4.1.2. Programming with file transports4.2. The transport interface4.2.1. Basic transport operations4.3. End point transports ? Part 2: networks4.3.1. Network programming with TSocket4.4. Server transports4.4.1. Programming network servers with server transports4.4.2. The Server Transport interface4.5. Layered transports4.5.1. Message framing4.6. SummaryREAD IN LIVEBOOK5. SERIALIZING DATA WITH PROTOCOLS5.1. Basic serialization with the binary protocol5.1.1. Using the C++ TBinaryProtocol5.1.2. Using the Java TBinaryProtocol5.1.3. Using the Python TBinaryProtocol5.1.4. Takeaway5.2. The TProtocol interface5.2.1. Apache Thrift serialization5.2.2. C++ TProtocol5.2.3. Java TProtocol5.2.4. Python TProtocolBase5.3. Serializing objects5.3.1. Struct serialization5.3.2. Struct deserialization5.3.3. Struct evolution5.4. TCompactProtocol5.5. TJSONProtocol5.6. Selecting a protocol5.7. SummaryREAD IN LIVEBOOK6. APACHE THRIFT IDL6.1. Interfaces6.2. Apache Thrift IDL6.2.1. IDL file names6.2.2. Element names6.2.3. Keywords6.3. The IDL compiler6.3.1. Compilation phases and error messages6.3.2. Command line switches6.4. Comments and documentation6.5. Namespaces6.6. Built-in types6.6.1. Base types6.6.2. Container types6.6.3. Literals6.7. Constants6.7.1. C++ interface constant implementation6.7.2. Java interface constant implementation6.7.3. Python interface constant implementation6.8. Typedefs6.9. Enum6.10. Structures, unions, exceptions, and argument-lists6.10.1. Structs6.10.2. Fields6.10.3. Exceptions6.10.4. Unions6.11. Services6.12. Including external files6.13. Annotations6.13.1. SummaryREAD IN LIVEBOOK7. USER-DEFINED TYPES7.1. A simple user-defined type example7.2. Type design7.2.1. Namespaces7.2.2. Constants7.2.3. Structs7.2.4. Base types7.2.5. Typedefs7.2.6. Field Ids and retiring fields7.2.7. Enums7.2.8. Collections7.2.9. Unions7.2.10. Requiredness and optional fields7.3. Serializing objects to disk7.4. Under the type serialization hood7.4.1. Serializing with write()7.4.2. Deserializing with read()7.5. Type evolution7.5.1. Renaming fields7.5.2. Adding fields7.5.3. Deleting fields7.5.4. Changing a field?s type7.5.5. Changing a field?s requiredness7.5.6. Changing a field?s default value7.6. Using Zlib compression7.6.1. Using Zlib with C++7.6.2. Using Zlib with Python7.7. SummaryREAD IN LIVEBOOK8. IMPLEMENTING SERVICES8.1. Declaring IDL services8.1.1. Parameter identifiers8.1.2. Parameter Requiredness8.1.3. Default parameter values8.1.4. Function and parameter types8.2. Building a simple service8.2.1. Interfaces8.2.2. Coding service handlers and test harnesses8.2.3. Coding RPC servers8.2.4. Coding RPC clients8.3. Service interface evolution8.3.1. Adding features to a service8.4. RPC services in depth8.4.1. Under the hood8.4.2. Oneway functions8.4.3. Service inheritance8.4.4. Asynchronous clients8.5. SummaryREAD IN LIVEBOOK9. HANDLING EXCEPTIONS9.1. Apache Thrift exceptions9.2. TTransportException9.2.1. C++ Exception Processing9.2.2. Java exception processing9.2.3. Python exception processing9.2.4. Error processing without exceptions9.3. TProtocolException9.4. TApplicationException9.5. User-defined exceptions9.5.1. User-defined exception IDL example9.5.2. C++ user-defined exception client9.5.3. C++ user-defined exception server9.5.4. Java user-defined exception client9.5.5. Python user-defined exception client9.6. SummaryREAD IN LIVEBOOK10. SERVERS10.1. Building a Simple Server from Scratch10.2. Using Multithreaded Servers10.3. Server Concurrency Models10.3.1. Connection Based Processing10.3.2. Task Based Processing10.3.3. Multithreading vs. Multiprocessing10.3.4. Server Summary by Language10.4. Using Factories10.4.1. Building I/O Stacks with Factories10.4.2. Processor and Handler Factories10.4.3. In/Out Factories10.4.4. Building Servers with Custom Factories and Transports10.5. Server Interfaces and Event Processing10.5.1. TServer10.5.2. TServerEventHandler10.5.3. Building a C++ Thread Pool Server with Server Events10.6. Servers and Services10.6.1. Building Multiservice Servers10.6.2. Building a Multiplexed Java Threaded Selector Server10.7. SummaryPART 3 POLYGLOT APPLICATION DEVELOPMENTREAD IN LIVEBOOK11. BUILDING CLIENTS AND SERVERS WITH C++11.1. Setting up Apache Thrift for C++ Development11.1.1. Apache Thrift C++ Versions and Boost11.1.2. Building Apache Thrift C++ Libraries11.1.3. Building Apache Thrift C++ Libraries on Windows11.2. A Simple Client and Server11.2.1. The Hello IDL11.2.2. Building a Simple C++ Client11.2.3. Creating a Simple RPC Server11.3. C++ Transports, Protocols and Servers11.3.1. C++ Transports11.3.2. C++ Protocols11.3.3. Runtime versus Compile Time Polymorphism11.3.4. C++ Servers11.4. The C++ TNonBlockingServer11.5. SummaryREAD IN LIVEBOOK12. BUILDING CLIENTS AND SERVERS WITH JAVA12.1. Setting up Apache Thrift for Java Development12.1.1. Apache Thrift and SLF4J12.2. A Simple Client and Server12.2.1. The Hello IDL12.2.2. Building a Simple Java Client12.2.3. Creating a Simple RPC Server12.2.4. Building with Ant12.2.5. Building with Maven12.3. Using Apache Thrift in other JVM languages12.4. Java Transports, Protocols and Servers12.4.1. Java Transports12.4.2. Java Protocols12.4.3. Java Servers12.5. Asynchronous Java RPC12.6. SummaryREAD IN LIVEBOOK13. BUILDING C# CLIENTS AND SERVERS WITH .NET AND WINDOWS13.1. Setting up Apache Thrift on Windows13.2. A Simple Client and Server13.2.1. Creating a Visual Studio RPC Solution13.2.2. Creating the Interface Library13.2.3. Creating the RPC Server13.2.4. Creating the RPC Client13.2.5. Testing the RPC Application13.3. C# Transports, Protocols and Servers13.3.1. C# Transports13.3.2. C# Protocols13.3.3. C# Servers13.4. Long Polling with Named Pipes13.4.1. A Long Polling Interface13.4.2. Installing Apache Thrift Support through NuGet13.4.3. Creating a Named Pipe Server13.4.4. Building the Long Polling Server13.4.5. Building a Named Pipe Client13.5. SummaryREAD IN LIVEBOOK14. BUILDING NODE.JS CLIENTS AND SERVERS14.1. A Simple Client and Server14.1.1. Generating the Client/Server Stubs14.1.2. Creating a Node.js Server14.1.3. Creating a Node.js Client14.2. Q14.3. Node.js Servers14.4. Multiplexed Services14.5. Apache Thrift IDL and Node.js14.5.1. Creating full featured IDL handlers14.5.2. Creating a full featured Node.js Client14.6. SummaryREAD IN LIVEBOOK15. APACHE THRIFT AND JAVASCRIPT15.1. Apache Thrift JavaScript Quick Start15.2. A Simple Client and Server15.2.1. Installing Apache Thrift for JavaScript15.2.2. The Hello World IDL15.2.3. The Hello World Node.js Server15.2.4. The Hello World Web Client15.2.5. Running the Hello World Example15.2.6. Debugging15.2.7. Node.js HTTP Clients15.3. Asynchronous Browser Client Calls15.4. RPC Error Handling15.5. Browser RPC and jQuery15.6. Apache Thrift and Web Security15.6.1. Cross-Origin Resource Sharing (CORS)15.6.2. Content Security Policy (CSP)15.6.3. X-Frame-Options15.6.4. Transport Security15.7. Using the Web Socket Transport15.8. SummaryREAD IN LIVEBOOK16. SCRIPTING APACHE THRIFT16.1. Apache Thrift and Ruby16.1.1. A Ruby Server16.1.2. A Ruby Client16.1.3. Ruby Features16.2. Apache Thrift and PHP16.2.1. A PHP Program16.2.2. A PHP Apache Thrift Client16.2.3. PHP Features16.3. Apache Thrift and Perl16.4. Apache Thrift Perl Clients16.5. Apache Thrift Perl Servers16.5.1. Apache Thrift Perl Features16.6. Apache Thrift and Python16.7. SummaryREAD IN LIVEBOOK17. THRIFT IN THE ENTERPRISE17.1. Polyglot Development17.2. Apache Thrift in the Distributed Landscape17.2.1. Services17.2.2. Interface Definition<a href="https://livebook.manning.com/#!/book/programmers-guide-to-apache-thrift/chapter-17/section-17-2-3" target="_blank" title="Re </body> </html>

Randy Abernethy is an active Apache Thrift contributor and can be found on the dev and user email lists. A serial entrepreneur, Randy founded Hollywood's first all hard disk recording studio in the early 90s, a direct market access institutional brokerage in the 2000s, and has recently focused on the development of proprietary automated trading systems using Apache Thrift for interoperability.