[split] util and finagle: fix compiler warnings

Fixes to some of the more trivial compiler warnings in finagle and
util.

RB_ID=473425
[split] [finagle-core] fix Trace.state_= when clearing state

RB_ID=482807
[split] finagle-core: Enable SNI by default for finagle clients over ssl

Problem

finagle's implementation of SSL does not use Server Name Indication
(SNI).

Solution

finagle must use SSLEngine, not SSLSockets, because SSLSockets have
mostly blocking operations.  In order to use SNI with SSLEngine,
we must supply a peerHost and peerPort to SSLContext.  This means
threading a host and port through to SSL connection establishment
time.  The only reference that we have to the downstream is the
SocketAddress, so we use that by default--however, if the client
specifies a hostname to verify against, we override the host with
that one.

Result

SNI is automatically turned on for all clients that enable TLS.
When host verification is also turned on, we use the same host for
host verification and SNI.

RB_ID=481449
[split] Updated with CrimsonHexagon info

Signed-off-by: Travis Brown <tbrown@twitter.com>

RB_ID=483177
[split]  finagle-kestrelx: fix java style failures

 Problem

 finagle-kestrelx's java src is failing checkstyle

 Solution

 fix the style issues

RB_ID=484231
[split] use org.apache.thrift libthrift 0.5.0-1 universally

tl;dr: 0.5.0 has a bug, 0.5.0-1 doesn't.  See THRIFT-223 for the explanation of the problem.

Exceptions:
scrooge-generator (0.8, only used by eventbus-thrift and some leaves)
scrooge-benchmark (0.8)
ostrichagg (0.8, I don't know why, but I believe it's a leaf)

Note this *downgrades* scrooge-core from 0.8 to 0.5.

libthrift 0.5.0 and 0.5.0-1 were published by twitter, not Apache.
They're publicly available on maven.twttr.com.

Note the 0.5.0 pom.xmls (thrift and org.apache.thrift) are empty.  The
0.5.0-1 pom.xml has dependencies on slf4j-api and commons-lang.

RB_ID=474051
[split] Port tracing fix from finagle-http

We need to backport changes from finagle-http to finagle-httpx. This
change comes from 81e920d.

From RB=431323:

> Problem
>
> How and where Finagle initializes a its Tracing infrastructure is
> unlcear and difficult to reason about. Each Codec is charged with
> decoding trace info, pushing the Tracer, tracing send/recv events, and
> service name annotations. This caused issues where traces were
> recorded before a tracer was pushed to the stack or before the proper
> TraceId was decoded out of the protocol, thus creating broken traces.
>
> Solution
>
> Charge the codecs with simply initializing the trace id by decoding it
> from the protocol. Let finagle handle tracing service name and send/recv
> events.
>
> Result
>
> Traces work the right way by default

RB_ID=484289
[split] scribelibe_2.10 0.0.10 + a bunch to birdcage

RB_ID=482663
[split] Add missing tracing configuration to Macaw

* Adds missing DefaultServer override for newTraceInitializer.
* In the future, we should switch to Stack (see RB).

RB_ID=484875
[split] Read-only ByteBuffer's may be used as param values for Thrift's binary args.

RB_ID=483311
[split]  finagle-core: whitelist twcache from duplicate scheme check and parameterize resolver discovery

 Problem

 Finagle-memcached and finagle-memcachedx each define a resolver,
 'TwitterCacheResolver', for the twcache scheme. This leads to an
 unrecoverable runtime failure for packages that pick up both libraries
 due to the conflicting resolvers registering for the same scheme.

 Solution

 Special-case the 'twcache' scheme to whitelist it for finagle-core's
 Resolver duplicate checking.

 The reason for this hack is that no other solution is deployable
 in the multi-mono-repo world without one-shotting Science in a
 branch (as confirmed in extensive discussion with jw and moses).
 The plan for an incremental rollout for finagle-memcachedx precludes
 a 2.10 style upgrade so that leads us to the proposed bandaid. The
 good news is that this bandaid has clearly defined lifespan, the
 duration of the netty4 migration.

 Trying to write tests to verify the new filtering logic was, as far
 as I could determine, impossible because the Resolver hardcodes a
 ServiceLoader call to discover resolvers defined in resource files,
 all of which happens at static init time of a private member. As a
 result this RB also introduces a generalized version of the Resolver
 object which is paramterized by a Seq[Resolver] producing thunk
 which allows us to assert signifcant properties of Resolver such
 as: defining multiple resolvers for the same schemes throws and
 that twcache is in fact a special case. That change isn't essential
 and if gets too much pushback I'm okay to drop it as the important
 result here is to unblock the finagle-memcachedx rollout.

 Result

 1) Netty4 migration is unblocked and we can proceed with porting
 services to finagle-memcachedx incrementally without threat of
 runtime TwitterCacheResolver scheme collision related failures.
 2) Implicit assumption that the TwitterCacheResolver defined in
 finagle-memcached and finagle-memcachedx will not diverge.
 3) More testable Resolver

RB_ID=484357
[split]  finagle-memcachedx: sync commit a403a0a7d66 from finagle-memcached

 syncing

 commit a403a0a7d6689a60905a6b39ff860673905bc815
 Author: Evan Jones <ejones@twitter.com>
 Date:   Thu Oct 9 22:28:48 2014 +0000

     finagle-memcached: KetamaClient: Add test for concelled requests

     Adds unit test for commit 4c29ba95b3

     RB_ID=473329

 to finagle-memcachedx

RB_ID=485881
TBR=true
[split] Trace, Context: add transitional APIs

In order to get the request context change[1] shipped, we need to
introduce a transitional API so that we can introduce it to science
without having an intermediate broken state.

I have a separate branch in science that makes changes according to
this, and they seem to be all that's required.

[1] https://reviewboard.twitter.biz/r/469081/

RB_ID=480925
[split] finagle loadbalancer: remove a stat from emwa

Problem

This defines a stat per host/port endpoint in the emwa load balancer,
which has GC characteristics of per-host stats.  IE: large cluster
rollouts to mesos will GC and repromote a ton of stats.

Solution

Deleting this stat is acceptable since it's mostly for load balancer
debugging.

RB_ID=483375
[split] CSL-1191 - flaky: com.twitter.finagle.stats.StatsReceiverTest.rollup statsReceiver work in action

RB_ID=487717
TBR=true
NO-QUEUE=true
[split]  finagle: define sbt builds for -x projects

 define sbt builds for finagle-memcachedx, finagle-kestrelx and finagle-httpx

RB_ID=485655
[split] Fix Travis CI config and add missing dependency to SBT build

Problem

We're no longer cross-building against 2.9.2, but that's what's in the Travis
configuration. The SBT build is also missing the ScalaCheck dependency.

Solution

Update the version, add the dependency.

Result

Tests run as expected on Travis.

RB_ID=484635
Merge branch 'tmp' into develop
[split] util-logging: factor out testing code into new package util-test

Problem

util-logging exported a dependency on scalatest. This causes broken
builds when used in Science, which is still on Scalatest 1.x.

Solution

Factor this out into its own package, and use selectively.

before% ./pants goal dependencies twitter-server/src/main/scala | grep scalatest
3rdparty:scalatest
org.scalatest:scalatest_2.10:2.2.2
before%

after% ./pants goal dependencies twitter-server/src/main/scala | grep scalatest
after%

RB_ID=482011
[split] Strip Dtab headers from Http requests before adding Dtab.local to request headers

Problem:

Finagle encodes Dtab.local into request headers. However, it's possible, for instance if a request object is accidentally reused, to add many Dtabs to a request.

Solution:

Ensure that a request is stripped of Dtab headers before appending Dtab.local to Http requests.

RB_ID=478527