Apache Thrift Pdf

Posted on by
Apache Thrift Pdf 7,6/10 5685 reviews
Apache Thrift
Developer(s)Apache Software Foundation
Stable release
RepositoryThrift Repository
Written inActionScript, C, C#, C++, D, Dart, Delphi, Erlang, Go, Haskel, Haxe, Java, JavaScript, Node.js, OCaml, Perl, PHP, Python, Rust, SmallTalk
TypeRemote procedure call framework
LicenseApache License 2.0
Websitethrift.apache.org

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. Thrift-based distributed software systems are built out of communicating components that use different languages, protocols, and message types.

Introducing Apache Thrift. Distributed systems and their services. An introduction to Apache Thrift. Apache Thrift and others. When to choose Apache Thrift. 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? Thrift: The Missing Guide 3 Types used in containers many be any valid Thrift type (including structs and exceptions) excluding services. Structs and Exceptions A Thrift struct is conceptually similar to a C struct — a convenient way of grouping together (and encapsulating) related items. Structs translate to classes in object-oriented languages.

Thrift is an interface definition language and binary communication protocol[1]used for defining and creating services for numerous languages.[2] It forms a remote procedure call (RPC) framework and was developed at Facebook for 'scalable cross-language services development'. It combines a software stack with a code generation engine to build cross-platform services which can connect applications written in a variety of languages and frameworks, including ActionScript, C, C++,[3]C#, Cappuccino,[4]Cocoa, Delphi, Erlang, Go, Haskell, Java, Node.js, Objective-C, OCaml, Perl, PHP, Python, Ruby, Rust, Smalltalk and Swift.[5] Although developed at Facebook, it is now an open source project in the Apache Software Foundation. The implementation was described in an April 2007 technical paper released by Facebook, now hosted on Apache.[6][7]

Architecture[edit]

The Apache Thrift API client/server architecture

Thrift includes a complete stack for creating clients and servers.[8] The top part is generated code from the Thrift definition. From this file, the services generate client and processor code. In contrast to built-in types, created data structures are sent as result in generated code. The protocol and transport layer are part of the runtime library. With Thrift, it is possible to define a service and change the protocol and transport without recompiling the code. Besides the client part, Thrift includes server infrastructure to tie protocols and transports together, like blocking, non-blocking, and multi-threaded servers. The underlying I/O part of the stack is implemented differently for different languages.

Thrift supports a number of protocols:[8]

  • TBinaryProtocol – A straightforward binary format, simple, but not optimized for space efficiency. Faster to process than the text protocol but more difficult to debug.
  • TCompactProtocol – More compact binary format; typically more efficient to process as well
  • TJSONProtocol – Uses JSON for encoding of data.
  • TSimpleJSONProtocol – A write-only protocol that cannot be parsed by Thrift because it drops metadata using JSON. Suitable for parsing by scripting languages.[9]

The supported transports are:

  • TSimpleFileTransport – This transport writes to a file.
  • TFramedTransport – This transport is required when using a non-blocking server. It sends data in frames, where each frame is preceded by length information.
  • TMemoryTransport – Uses memory for I/O. The Java implementation uses a simple ByteArrayOutputStream internally.
  • TSocket – Uses blocking socket I/O for transport.
  • TZlibTransport – Performs compression using zlib. Used in conjunction with another transport.

Thrift also provides a number of servers, which are

  • TNonblockingServer – A multi-threaded server using non-blocking I/O (Java implementation uses NIO channels). TFramedTransport must be used with this server.
  • TSimpleServer – A single-threaded server using standard blocking I/O. Useful for testing.
  • TThreadedServer – A multi-threaded server using a thread per connection model and standard blocking I/O.
  • TThreadPoolServer – A multi-threaded server using a thread pool and standard blocking I/O.

Benefits[edit]

Apache Thrift Pdf

Some stated benefits of Thrift include:[citation needed]

  • Cross-language serialization with lower overhead than alternatives such as SOAP due to use of binary format
  • A lean and clean library. No framework to code. No XML configuration files.
  • The language bindings feel natural. For example, Java uses ArrayList<String>. C++ uses std::vector<std::string>.
  • The application-level wire format and the serialization-level wire format are cleanly separated. They can be modified independently.
  • The predefined serialization styles include: binary, HTTP-friendly and compact binary.
  • Doubles as cross-language file serialization.
  • Soft versioning[clarify] of the protocol. Thrift does not require a centralized and explicit mechanism like major-version/minor-version. Loosely coupled teams can freely evolve RPC calls.
  • No build dependencies or non-standard software. No mix of incompatible software licenses.

Creating a Thrift service[edit]

Thrift is written in C++, but can create code for a number of languages. To create a Thrift service, one has to write Thrift files that describe it, generate the code in the destination language, write some code to start the server, and call it from the client. Here is a code example of such a description file:

Thrift will generate the code out of this descriptive information. For instance, in Java, the PhoneType will be a simple enum inside the Phone class.

See also[edit]

  • Abstract Syntax Notation One (ASN.1)
  • External Data Representation (XDR)
  • Internet Communications Engine (Ice)

References[edit]

  1. ^'Installing and using Apache Cassandra With Java Part 4 (Thrift Client)'. http://www.sodeso.nl/: Sodeso – Software Development Solutions. Retrieved 2011-03-30. Thrift is a separate Apache project which is a binary communication protocol
  2. ^Andrew Prunicki. 'Apache Thrift: Introduction'. http://www.ociweb.com/: Object Computing Inc. – An Open Solutions Company. Retrieved 2011-04-11. Through a simple and straightforward Interface Definition Language (IDL), Thrift allows [users] to define and create services which are both consumable by and serviceable by numerous languages. Using code generation, Thrift creates a set of files which can then be used for creating clients and/or servers. In addition to interoperability, Thrift can be very efficient through a unique serialization mechanism that is efficient in both time and space.
  3. ^Thrift Requirements, see this issue for Windows support
  4. ^Fred Potter, Using Thrift with CappuccinoArchived 2011-08-12 at the Wayback Machine, parallel48's posterously luscious blog, 10 June 2010.
  5. ^Andrew Prunicki. 'Apache Thrift: Code Generation'. http://www.ociweb.com/: Object Computing Inc. – An Open Solutions Company. Retrieved 2011-04-12. Thrift supports many languages too varying degrees. The complete list is below. Be careful before assuming that just because your language has some support that it supports all of Thrift's features. Python for example, only supports TBinaryProtocol. Cocoa, C++, C#, Erlang, Haskell, Java, OCaml, Perl, PHP, Python, Ruby, and Smalltalk
  6. ^Mark Slee, Aditya Agarwal, Marc Kwiatkowski, Thrift: Scalable Cross-Language Services Implementation
  7. ^'LibraryFeatures - Thrift Wiki'. Retrieved 2016-04-21.
  8. ^ abAndrew Prunicki. 'Apache Thrift: Introduction'. http://www.ociweb.com/: Object Computing Inc. – An Open Solutions Company. Retrieved 2011-04-11. The top portion of the stack is generated code from your Thrift definition file. Thrift services result in generated client and processor code. These are represented by the brown boxes in the diagram. The data structures that are sent (other than built-in types) also result in generated code. These result in the red boxes. The protocol and transport are part of the Thrift runtime library. Therefore with Thrift, you can define a service, and are free to change the protocol and transport without re-generating your code. Thrift also includes a server infrastructure to tie the protocols and transports together. There are blocking, non-blocking, single and multi-threaded servers available. The 'Underlying I/O' portion of the stack differs based on the language in question. For Java and Python network I/O, the built-in libraries are leveraged by the Thrift library, while the C++ implementation uses its own custom implementation.
  9. ^Skelton, Steven. 'Developer Friendly Thrift Request Logging'. Retrieved 3 July 2014.

External links[edit]

Retrieved from 'https://en.wikipedia.org/w/index.php?title=Apache_Thrift&oldid=915345819'
Active2 months ago

Although Thrift format is relatively widely used (and project still alive), I haven't been able to find specification for the underlying data format. Or formats, given that there are apparently at least two formats; standard one, and compact format.

Given its wide usage I am hoping it is just my poor google-fu, and a specification or specifications exist (outside of source code). If so, please share!

EDIT: Java source code is not too bad for figuring out format; see TBinaryProtocol.java and TCompactBinaryProtocol.java; which contain primitives, called by generated classes (which extend TBase)

EDIT2: While it does not contain format spec, 'the missing guide' is good reading.

Apache Thrift Pdf Free

StaxMan
StaxManStaxMan
87.5k27 gold badges172 silver badges211 bronze badges

3 Answers

The format for a Thrift message depends on the serialization protocol chosen. You can serialize a Thrift object using one of many protocols, including the TBinaryProtocol, TCompactProtocol, TJSONProtocol, and other obscure options. The protocol is described abstractly in the original Thrift Whitepaper PDF in terms of the API, but is not currently defined anywhere in the Thrift apache project.

The TCompactProtocol protocol is slightly better defined on the thrift wiki but not in simple terms.

Until better documentation is available, you can also examine the Python library code alongside the Python struct module documentation as another option.

Gabriel Gonzalez
31.4k3 gold badges64 silver badges125 bronze badges
Will PierceWill Pierce

I had the same problem and therefore decided to write a specification of the Thrift binary and compact protocol.

You can find it here: https://erikvanoosten.github.io/thrift-missing-specification/

Erik van OostenErik van Oosten

There are two binary encodings, compact and and non-compact.

Apache Thrift Service

Usually you will find the compact protocol in the wild:

Delta wars game download free for computer Apr 28, 2013  Delta Force 1 Free Download Full Version PC Game Cracked in Direct Link and Torrent. Delta Force 1 is a action video game. Highly Compressed PC Game Full Version Free Download, Download PC game ISO, Direct links game PC, Torrent PC Games, Crack DLC game PC, Free download pc games full version, skidrowcrack – fitgirl repack – corepack. Online real time strategy game. Delta Wars is a real-time strategy game. It can be played directly in the browser, so no download is required.Desert Order.

While the non-compact protocol is probably a legacy protocol:

With this being a rough overview of the specification:

Rollo

Apache Thrift Server

Rollo

Apache Thrift Pdf Converter

2,0413 gold badges18 silver badges29 bronze badges

Apache Thrift Download

Not the answer you're looking for? Browse other questions tagged thriftspecificationsdataformat or ask your own question.