support using fbstring for binary fields in cpp1 code

Summary:
Update the cpp code to allow using fbstring for binary types, just like
we do for string types.  The cpp2 code already supports fbstring for both
binary and string types.

This code is pretty inefficient--it uses the underlying std::string
implementations and then copies to/from a folly::fbstring.  This is
exaclty what the code is already doing for readString()/writeString()
though.

Test Plan:
Verified that a cpp1 client was able to use a thrift file that contains
an fbstring binary type.

Reviewed By: davejwatson@fb.com

FB internal diff: D1247787
Change default client from host/fqdn to first entry in keytab.

Summary:
Client principal choice: first of explicitly specified,
principal in current ccache, or first principal in keytab.  It's
possible for none to be available at startup.  In that case, we just
keep trying until a ccache or keytab appears.  Once a client principal
is chosen, we keep using that one and it never changes.

Test Plan: run regression tests

Reviewed By: andrei.bajenov@fb.com

FB internal diff: D1229336
remove global using statements from cpp2 headers

Summary:
Using statements in headers files should generally be avoided,
especially at global scope.  There is no way to "undo" the effect of a
using statement, so these pollute the global scope for everyone that
includes these headers.

The thrift cpp2 headers unfortunately had quite a few using statements
at global scope.  This removes all of them.  There were also a handful
of global using statements in the cpp headers, which I also removed.

I'm all for collapsing the various sub-namespaces under apache::thrift,
and moving more things directly into this namespace, but we shouldn't be
polluting the top-level global scope.

Test Plan:
Built all of thrift, ran its unit tests, and also built all projects
using thrift, and fixed build errors caused by code relying on these
global scope names.

Reviewed By: alandau@fb.com

FB internal diff: D1249253
Fix fastbinary benchmark

Summary:
Fix to make it work. It does show 20X performance gain with fastbinary:
[haijunz@dev1848 ~/fbcode] _build/dbg/thrift/test/fastbinary_test.par
That shouldn't happen.
Starting Benchmarks
HolyMoley Standard = 7.293125
HolyMoley Acceler. = 0.337320
FastStruct Standard = 1.549421
FastStruct Acceler. = 0.096837

The fastbinary.c module uses a Python Capsule defined in cStringIO.h and functions in this Capsule are defined in the cStringIO module. I must find some other difference that makes the performance diff.

Test Plan: fbconfig&&fbmake

Reviewed By: alandau@fb.com

FB internal diff: D1248682
Disable fastbinary in Python 3

Summary: fastbinary uses a Python Capsule implemented in cStringIO, which is gone in Python 3. I thought it was "working" but actually the c module isn't loaded in Python 3 without D1232261.

Test Plan: Dependency on fastbinary is removed for Python 3 unit tests so they succeed.

Reviewed By: alandau@fb.com

FB internal diff: D1248719
fix the build of the D libraries

Summary:
The D thrifserver code was using the global THeader and
makeMoveWrapper() names exposed by the thrift cpp2 headers.

I fixed the thrift headers to no longer expose these global names in
D1249253.  This build failure was missed when I rebased my changes.

Test Plan: Built all of thrift.

Reviewed By: davejwatson@fb.com

FB internal diff: D1250877
http support in THeader cleanup

Summary:
There is a lot of http legacy in thrift and the first step
needed to support http client is to change THRIFT_HTTP_CLIENT_TYPE to
THRIFT_HTTP_SERVER_TYPE (as that was the intention) in THeader. There is
also another change from HTTP_MAGIC to HTTP_SERVER_MAGIC.

Test Plan: git grep THRIFT_HTTP_CLIENT_TYPE

Reviewed By: davejwatson@fb.com

FB internal diff: D1251741
Krb5CredentialsCacheManager.cpp should do VLOG(4) instead of LOG(INFO)

Summary:
LOG(INFO) causes extra messages being output while running TW CLI
tools. This change in output of the CLI tools is not desirable by folks who use
TW CLI commands from scripts and expect the output in a specific pattern.

Test Plan: fbconfig -r thrift/lib/cpp/util/kerberos/ && fbmake runtests

Reviewed By: andrei.bajenov@fb.com

FB internal diff: D1253550
Change parameter to now shadow class function

Summary:
The super conservative `-Wno-shadow` parameter in memcache-land dislikes
this so let's just rename it (the function's so small that I don't think it
matters much).

Test Plan: compilation

Reviewed By: davejwatson@fb.com

FB internal diff: D1253821
Check ssl_ member for null before invoking SSL_pending

Summary:
`checkForImmediateRead` is invoked when you set the read callback.
This can happen prior to setting `ssl_`, so let's just check that it's
non-null before handing it off.

Test Plan: Tested it within larger mcrouter diff

Reviewed By: alandau@fb.com

FB internal diff: D1253826
Generate TEnumTraits<>::{min,max} for cpp2

Summary:
This diff adds support for the min() and max() functions in TEnumTraits
for cpp2. This support was present in the cpp generator, but cpp2 had a
TODO in the code.

The unit tests are cloned from the tests for the cpp generator and modified
to work with the strongly typed enums generated by cpp2.

Test Plan: fbconfig thrift/test && fbmake runtests

Reviewed By: alandau@fb.com

FB internal diff: D1256488
Use a global thread manager for a service

Summary:
This is an alternative to D988363. Basically instead of eliminating the thread manager completely, it reuses the same one.

I see a perf improvement with this diff. 9931qps -> 11500qps. (vs 12100qps when not using threads).

Test Plan: Same test plan as in D988363.

Reviewed By: alandau@fb.com

FB internal diff: D1258471
fix opensouce build

Summary: Needed a couple fixes due to recent auth changes.  Trying to get jenkins build setup so we catch these in an automated way

Test Plan: Jenkins build: http://ci-builds.fb.com/job/fbthrift/

Reviewed By: alandau@fb.com

FB internal diff: D1259286
Handle the case where the SASL thread manager is busy

Summary:
Two issues fixed here:
1. maxQueueLength was too low, I increased it
2. Handled the case where the maxQueueLength is reached more gracefully

Test Plan: Artificially lowered teh queue length, and made sure the server doesn't crash.

// fix to bug, needs to go in now
@override-unit-failures

Reviewed By: alandau@fb.com

FB internal diff: D1260277
Make sure overrides still work

Summary:
When serve() is called, we basically ignored all the previously set values with the setters.

This fixes that.

Test Plan: Unit tests

// build fix needs to go in
@override-unit-failures

Reviewed By: alandau@fb.com

FB internal diff: D1260805
Fix build with GHC 7.8

Summary:
GHC now complains about out-of-range integer literals.

I should probably upstream this too, I suppose...

Test Plan: Build & tested Haxl

Reviewed By: jon.coens@fb.com

FB internal diff: D1258988
fix process_delay

Summary: Process_delay has always been broken for task queue mode - after the changes to make async_tm the default, it's been broken everywhere.  Fix it by setting the processBegin time correctly when a task queue worker thread starts to run it.

Test Plan:
fbconfig thrift/perf/cpp; fbmake dev
_bin/thrift/perf/cpp/ThriftServer --enable_service_framework
_bin/thrift/perf/cpp/loadgen -cpp2 -async -weight_burn=1 -async_ops=1 -async_clients=100

look at localhost:8080, process_delay appears to be correct

Reviewed By: marccelani@fb.com

FB internal diff: D1260451
Fix usage of unique_ptr

Summary:
A new version of clang warns on this (see the very end of
http://ci-fbcode.fb.com:8080/builders/project/builds/800152/steps/build/logs/stdio).

Test Plan:
fbconfig thrift/lib/cpp2/security && fbmake dev

Reviewed By: andrei.bajenov@fb.com

FB internal diff: D1262649
Enable fastbinary in Python 3

Summary:
Python 2 uses a capsule to access internal buffer of a StringIO object but BytesIO and StringIO are no longer c modules in Python 3. This copies the necessary read/write functions from Python 2's cStringIO.c and modifies a few places so that it works with Bytes and str in Python 3.
encode_binary allocates a new buffer (StringIO in Python 2 and Oobject in Python 3), writes to it, then creates and returns a Bytes object. decode_binary accepts a BytesIO and reads its internal buffer directly.
I've had a hard time debugging this but the code so far seems not leaking memory. Will continue looking into using GDB to debug C modules in Python.

@override-unit-failures

Test Plan:
Tested it with fastbinary perf, it seems the performance is 12X in Python 3.
[haijunz@dev1848 ~/fbcode] _build/dbg/thrift/test/fastbinary_test_py3.par
That shouldn't happen.
Starting Benchmarks
HolyMoley Standard = 6.255279
HolyMoley Acceler. = 0.507743
FastStruct Standard = 1.315701
FastStruct Acceler. = 0.141880

Reviewed By: alandau@fb.com

FB internal diff: D1253015
Java: Tell transport whether we're flushing a regular or a oneway request

Summary: as title
@override-unit-failures

Test Plan: fbmake funtests

Reviewed By: davejwatson@fb.com

FB internal diff: D1262899