- Today we are going to see how to build Apache Thrift for C on Visual Studio 2015. Then for demonstration, we’ll also build and run the C tutorial. Disclaimer: this tutorial builds hugely on the one given by Adil Bukhari Configuring Apache Thrift for Visual Studio 2012.The reason I create a new one is that I followed his steps but stumbled upon a few problems preventing me from.
- Sometimes, those PCs are running Windows. With the recent 0.90 release, Apache Thrift support for Windows is leaps and bounds beyond what it used to be, but it's still 'only' 98%. Here are the missing steps: First of all the good news: Use on Windows no longer requires Cygwin or MinGW, despite what the outdated documentation states.
- Dec 30, 2015 Although primarily designed for Unix-compatible systems, Apache Thrift can also be used in the Windows environment. The installation is very easy; it is enough to download the Thrift compiler from the download page,.
- Alternatively, the Thrift compiler can also be built via Cygwin or MinGW build environments, however this method is not only less comfortable, but more time-consuming and requires much more manual effort. Prebuilt Thrift compiler¶ The windows Thrift compiler is available as a prebuilt exe available here.
- Thrift compiler for Windows is available on the official download site. Powered by a free Atlassian Confluence Open Source Project License granted to Apache.
Last Modified: 2014-03-16
Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements. See the NOTICE filedistributed with this work for additional informationregarding copyright ownership. The ASF licenses this fileto you under the Apache License, Version 2.0 (the'License'); you may not use this file except in compliancewith the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied. See the License for thespecific language governing permissions and limitationsunder the License.
Dec 01, 2012 Apache Thrift in Windows Apache Thrift, originally developed by Facebook, is an immensely useful general-purpose inter-process communication (IPC) code generation tool and library. Although it supports a variety of IPC mechanisms, sockets are its primary conduit, and as such, is naturally language agnostic and actually its tool can generate code for a dozen different languages. Prebuilt Thrift compiler¶ The windows Thrift compiler is available as a prebuilt exe available here. Note that there is no installation tool, rather this EXE file is already the Thrift compiler utility. Download the file and put it into some suitable location of your choice.
Thrift is a lightweight, language-independent software stack with anassociated code generation mechanism for RPC. Thrift provides cleanabstractions for data transport, data serialization, and applicationlevel processing. The code generation system takes a simple definitionlanguage as its input and generates code across programming languages thatuses the abstracted stack to build interoperable RPC clients and servers.
Thrift is specifically designed to support non-atomic version changesacross client and server code.
For more details on Thrift's design and implementation, take a gander atthe Thrift whitepaper included in this distribution or at the README.md filesin your particular subdirectory of interest.
thrift/
Here is a Windows 7 Games package which solves this issue.RECOMMENDED:To get Windows 7 Games for Windows 10 Creators Update, follow the instructions below. Pc games windows 7 compatible. Get the ZIP archive with Games from the following link:.
compiler/
lib/
test/
tutorial/
See http://thrift.apache.org/docs/install for an up-to-date list of build requirements.
More information about Thrift can be obtained on the Thrift webpage at:
Thrift was inspired by pillar, a lightweight RPC tool written by Adam D'Angelo,and also by Google's protocol buffers.
If you are building from the first time out of the source repository, you willneed to generate the configure scripts. (This is not necessary if youdownloaded a tarball.) From the top directory, do:
Once the configure scripts are generated, thrift can be configured.From the top directory, do:
Apache Thrift Performance
You may need to specify the location of the boost files explicitly.If you installed boost in /usr/local, you would run configure as follows:
Note that by default the thrift C++ library is typically built with debuggingsymbols included. If you want to customize these options you should use theCXXFLAGS option in configure, as such:
To enable gcov required options -fprofile-arcs -ftest-coverage enable them:
Run ./configure --help to see other configuration options
Please be aware that the Python library will ignore the --prefix optionand just install wherever Python's distutils puts it (usually alongthe lines of /usr/lib/pythonX.Y/site-packages/). If you need to controlwhere the Python modules are installed, set the PY_PREFIX variable.(DESTDIR is respected for Python and C++.)
Make thrift:
From the top directory, become superuser and do:
Note that some language packages must be installed manually using build toolsbetter suited to those languages (at the time of this writing, this appliesto Java, Ruby, PHP).
Look for the README.md file in the lib// folder for more details on theinstallation of each language library package.
There are a large number of client library tests that can all be runfrom the top-level directory.
This will make all of the libraries (as necessary), and run throughthe unit tests defined in each of the client libraries. If a singlelanguage fails, the make check will continue on and provide a synopsisat the end.
To run the cross-language test suite, please run:
This will run a set of tests that use different language clients andservers.
Developer(s) | Apache Software Foundation |
---|---|
Stable release | |
Repository | Thrift Repository |
Written in | ActionScript, C, C#, C++, D, Dart, Delphi, Erlang, Go, Haskel, Haxe, Java, JavaScript, Node.js, OCaml, Perl, PHP, Python, Rust, SmallTalk |
Type | Remote procedure call framework |
License | Apache License 2.0 |
Website | thrift.apache.org |
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]
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. Force feedback 2 software. 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]
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++ usesstd::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.
Thrift Apache
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)
Apache Thrift Windows
References[edit]
- ^'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
- ^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.
- ^Thrift Requirements, see this issue for Windows support
- ^Fred Potter, Using Thrift with CappuccinoArchived 2011-08-12 at the Wayback Machine, parallel48's posterously luscious blog, 10 June 2010.
- ^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
- ^Mark Slee, Aditya Agarwal, Marc Kwiatkowski, Thrift: Scalable Cross-Language Services Implementation
- ^'LibraryFeatures - Thrift Wiki'. Retrieved 2016-04-21.
- ^ 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.
- ^Skelton, Steven. 'Developer Friendly Thrift Request Logging'. Retrieved 3 July 2014.