Generate python 3 code

Summary: Add an option in thrift compiler to generate python 3 code
@override-unit-failures

Test Plan:
Run
_build/dbg/thrift/compiler/thrift -o thrifttest/ -I . --gen py thrifttest/sum.thrift
to generate py2 code, then run
2to3 -f all -f idioms thrifttest/gen-py/
to find all incompatibilities, fix them, then run
_build/dbg/thrift/compiler/thrift -o thrifttest/ -I . --gen py:py3 thrifttest/sum.thrift
to generate py3 code and diff with py2 code to verify

Reviewed By: davejwatson@fb.com

FB internal diff: D1061976
run reindent.py on thrift compiler, try 2

@override-unit-failures

Test Plan: contbuild

Reviewed By: haijunz@fb.com

FB internal diff: D1153028

Blame Revision: D1149980
HeaderClientChannel: remove SaslCallback base class

Summary: ...and make it a member instead

@override-unit-failures

Test Plan: fbmake

Reviewed By: davejwatson@fb.com

FB internal diff: D1151952
Replace HeaderClientChaneel's HHWheelTimer base with a member

Summary: as title

@override-unit-failures

Test Plan: fbmake, perftest.py

Reviewed By: davejwatson@fb.com

FB internal diff: D1151984
reindent all python files

Summary: run reindent on lib, test, perf and tutorial and some code sanity change
@override-unit-failures

Test Plan: fbmake runtests. No more PEP8 lint errors!

Reviewed By: alandau@fb.com

FB internal diff: D1156040
HeaderServerChannel: convert inheritance to containment

Summary: as title

Test Plan: fbmake and perftest

Reviewed By: davejwatson@fb.com

FB internal diff: D1156566
Rename Client to TClient to avoid name collision

Summary: Users define struct named Client which caused name collision in generated code. Rename the Client class to TClient and add TClient and a reserved word.
@override-unit-failures

Test Plan: fbmake

Reviewed By: davejwatson@fb.com

FB internal diff: D1138555
fix unions in compatibility mode

Summary: Unions aren't typedef'd in compatibility mode, but inherited.  const_cast is too strict in this case: we need to both get the parent class and const_cast

Test Plan: repro in D1154211 passes

Reviewed By: alandau@fb.com

FB internal diff: D1160803
move out processInThread from compiler

Summary: Most of this doesn't use any substitution, so doesn't need to be in compiler.

Test Plan:
fbconfig thrift/lib/cpp2; fbmake dbg

ran loadtest.py, looks fine

Reviewed By: andrewcox@fb.com

FB internal diff: D1149989
fix processInThread bug

Summary: bug introduced in D1149989 - thought this could be a MoveWrapper, but by the time we catch it has already been moved in to the lambda.

Test Plan: fbconfig -r thrift/lib/cpp2; fbmake runtests

Reviewed By: haijunz@fb.com

FB internal diff: D1164075

Blame Revision: D1149989
Add kerberos utility functions to thrift

Summary:
This diff adds a few utility functions to thrift. It is mostly c++ convenience wrappers around krb5 objects.

This also adds a credentials cache manager designed to manage the kerberos credentials cache asynchronously.

Test Plan: Compiled stuff that depends on it, it seems to work. Ran tests.

Reviewed By: mhorowitz@fb.com

FB internal diff: D1162667
Add x-th percentile latency stats display

Summary:
This diff is a split from D1157286 for the thrift perftest part, and depends on D1158270
Add x-th percentile latency stats display to thrift perf-test;
It supports any percentile (0~100) latency stats display.

Test Plan:
$ fbconfig -r thrift/perf/cpp && fbmake
$ _bin/thrift/perf/cpp/ThriftServer &
then run loadgen
$ _bin/thrift/perf/cpp/loadgen -weight_sendrecv=1 --thriftLatencyMonPct=99.5

Reviewed By: simpkins@fb.com

FB internal diff: D1158298
Move process_ function to its own python function

Summary: This simply moves process_* function generation to its own python function, so the indentation isn't so crazy.  This was the worst offender for indentation, 14 indent! lol

Test Plan: fbconfig -r thrift/lib/cpp2; fbmake dbg

Reviewed By: andrewcox@fb.com

FB internal diff: D1150004
pull out service includes

Summary: Move service includes out of compiler.

Test Plan: fbconfig -r thrift/lib/cpp; fbmake dbg

Reviewed By: andrewcox@fb.com

FB internal diff: D1150006
Global 'out' scope in compiler

Summary: Instead of all the clowny 'with c('try') as cl:' and cl('..'), we can just use a global scope, since we always want to print to the last created scope.  I only converted a small part of the generator, comment if you like/dislike this and I can go farther

@override-unit-failures

Test Plan: fbconfig -r thrift/lib/cpp2; fbmake dbg

Reviewed By: andrewcox@fb.com

FB internal diff: D1150016
Addition hook to know when the server is ready

Summary:
TDirectServer currently does not have a hook to notify other
threads that it is ready to serve traffic. This diff implements this
extra hook so that other services that use TDirectServer can have a
means to be notified that it is ready to serve traffic.

Test Plan:
Played with the test servers and verified that it is working
normally.

Reviewed By: andrewcox@fb.com

FB internal diff: D1165692
thrift: use thrift-py.lpar over thrift-py.par

Summary:
We're seeing startup race-conditions on the build machines when
thrift-py.par is started up by several jobs simultaneously.  This
diff switches fbcode builds to favor the LPAR when it exists to
avoid this issue, which has the additional benefit of improving the
stratup time.

Test Plan:
Ran builds w/ and w/o the LPAR available.  Verified via strace that
the LPAR was used when it was available, and the PAR otherwise (which
is the case when thrift is run from its contbuild publish location
which only has access to the PAR).

Reviewed By: njormrod@fb.com

FB internal diff: D1169592
fix pendingCount context switches

Summary: Update pending count only if we receive new request on the thread - pendingCount probably doesn't matter for low qps services anyway.  Prevents extraneous wakeups

Test Plan:
fbconfig thrift/perf/cpp
fbmake dbg
_bin/thrift/perf/cpp/ThriftServer --enable_service_framework --max_requests=2 -num_threads=32
sudo perf record -ag -e cs
sudo perf report --stdio -g

context switches drop

Reviewed By: haijunz@fb.com

FB internal diff: D1169666
hack to unbreak thrift's FieldNames template

Summary:
Thrift's codegen module contains a FieldNames template that tries to
enumate all value fields inside a thrift structure.  Unfortunately,
thrift structures also contain a few methods that use FieldNames as part
of their definition.  This generates recursive alias errors when
FieldNames tries to examine these member methods.

For now this is a hack to just special case the names of these methods
so they can be skipped.

I presume there is probably a better way to fix this, but I'm not enough
of a D expert to know how to do it.

Test Plan: fbconfig -r tutorials/d && fbmake dbg

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1135306
remove unused vars in channeltest

Summary: Was showing a warning when building.

Test Plan:
fbconfig -r thrift/lib/cpp2
fbmake dbg

Reviewed By: alandau@fb.com

FB internal diff: D1162477