finagle-mux: increase PatienceConfig for scalatest Conductors

Problem

`AlarmTest` has still failed in CI occasionally.

Solution

Try increasing the PatienceConfig timeout before we mark the
test as flakey.

RB_ID=527447
finagle-core: make ResolutionRaceTest more robust

Problem

ResolutionRaceTest uses a lot of ports which are now a constrained
resource in CI.

Solution

Use the loopback interface where we are less constrained and
close clients after usage.

RB_ID=527499
finagle-core: take an Option in ClientBuilder#socksProxy

Problem:

If you set a SOCKS proxy with -socksProxy, there is no way to turn it
off for individual ClientBuilder clients, because the
ClientBuilder#socksProxy method takes a SocketAddress rather than an
Option[SocketAddress].

Solution:

Make ClientBuilder#socksProxy take an Option[SocketAddress].

RB_ID=527809
 [finagle-core] Namer.global: make /$/inet resolution lazy

 Problem
 Namer.global.lookup constructs InetSocketAddresses inline for /$/inet Paths,
 which causes DNS resolution before the Bound Names are actually used. This
 causes problems when using Dtab overrides in restricted network environments
 to avoid /$/inet addresses being resolved.

 Solution
 - In Namer.global.InetPath.unapply, call InetSocketAddress.createUnresolved when both
   host and port are specified.
 - In Namer.glolal.lookup, change the Var.value for InetPath to a Var.async, in which
   unresolved InetSocketAddresses are resolved.

 Result
 InetSocketAddresses in Bound Names returned by Namer.global are only resolved when
 the underlying Var[Addr] is observed.

RB_ID=527679
finagle-core: Use loopback address in WeightedSocketAddressTest

RB_ID=527567
finagle-memcached: flake MigrationClientTest and replace RandomSocket usage

 rescuing https://reviewboard.twitter.biz/r/528985/ and https://reviewboard.twitter.biz/r/527451/
 from birdcage and merging into one rb.

 original descriptions:

 528985:
 MigrationClient's "sending dark trafic" test has been flaking for
 a number of reasons, usually blocking on zk operations, for a while
 so mark it as flaky until someone from cache can take a look.

 527451:
 remove racy RandomSocket usage. between this and https://reviewboard.twitter.biz/r/527451/
 the only remaining RandomSocket use in finagle-memcached|x is in the ExternalMemcached
 object which requires it (for now, see CSL-1403 for details).

RB_ID=529569
GROUPS file cleanup for api/macaw/limiter/ht-team

RB_ID=530049
TBR=true
NO-QUEUE=true
Macaw-Swift PRESUBMIT hook

RB_ID=499417
Avoid Scala 2.11-incompatible APIs and language features

Problem

Case classes without parameter lists are no longer supported in Scala 2.11, and
some packages and methods that were deprecated in 2.10 are no longer available.

Solution

Change code to be compatible with both 2.10 and 2.11.

Result

Most Finagle subprojects can be compiled on 2.11 (with no ABI breakage for
2.10). The SBT build changes to support 2.11 are coming in a separate commit.

RB_ID=531085
finagle-stats: Introduce ImmediateMetricsStatsReceiver

Problem

By default, MetricsStatsReceiver uses WindowedApproxHistogram to report stats on a sliding
window of 60 seconds and with a delay of at most 20 seconds.
This is useful in production but annoying when you want to write tests because you need to
wait before the data will be aggregated.

Solution

Refactor the MetricsStatsReceiver constructor, which now takes a histogram builder parameter.
Introduce a new class ImmediateMetricsStatsReceiver, which uses ApproximateHistogram under
the hood (without any window).

RB_ID=530261
finagle-serversets: Flatten and clean up Zk.scala

- Rename Zk's `op` function to `watchedOperation`
- Remove the ZkFactory/FnZkFactory hierarchy in favor of a flat
  ZkSession class and companion object
- Use implicit timer arguments everywhere rather than requiring them
  to be passed in explicitly
- Simplify the `safeRetry` method by making it take a single
  `=> Future[T]` argument and use the class-scoped `retryBackoffs`
  field rather than passing it in on every usage
- Add a few scaladocs, reword a few variable names

RB_ID=531985
TBR=true
finagle-core: Introduce Status, Service.status, ServiceFactory.status

Problem

Service.isAvailable and ServiceFactory.isAvailable is too
coarse-grained for many uses. For example, we need to be able to
distinguish between a transiently unavailable service and one that is
permanently closed. This is useful in Mux's leasing mechanism as well
as for the upcoming admission controllers.

Solution

Introduce a first-class Status. It's an ADT with variants

	Open
	Busy
	Closed

The Busy variant carries a Future[Unit] indicating when the status has
changed. This is useful for queueing at the appropriate level in the
stack. The other variants don't have arguments.

Discussion

Implementing this without breaking the API was a bit tricky. The
solution is uglier than it should be because of it. I'd like to move
towards finalizing isAvailable, which would make everything much more
consistent. I've inserted notes where appropriate (grep for CSL-1336)
that can be used to track required API changes when we're ready to
pull that trigger.

I've modified the rest of the birdcage, too, to be 'final-safe' -- it
compiles locally if i modify the definition of Service.isAvailable and
ServiceFactory.isAvailable and also fix up the noted usages. The
upshot is that we're very close to being able to do this without
breaking anyone.

This change aims to maintain "isAvailable" parity -- I have not yet
made use of the finer-grained status field; this comes next.

RB_ID=513399
finagle-core: Rm vestigial loadbalancer `Stack.Role`

RB_ID=529531
Problem

The current sections of the user guide covering loadbalancer and
serversets metrics are incomplete and outdated.

Solution

- Replace the serversets section with a comprehensive section on
  service discovery, covering stats on high-level naming and
  lower-level ZK diagnostics.
- Re-label the HeapBalancer section to account for the various LB
  implementations.

While in here, a README is added to finagle/doc with docsite
generation instructions.

RB_ID=530135
finagle-core: Define isAvailable as status == Open

This retains the old definition: isAvailable was false for both
transient and permanent availability issues.

RB_ID=532943
Set up SBT for 2.11 builds and remove StreamyJ dependency

Problem

We want to publish 2.11 versions of as many Finagle subprojects as possible.
Some subprojects can't be built for 2.11 at the moment, since they depend on
either Specs or Ostrich, neither of which have builds for 2.11. One subproject
(finagle-example) depends on StreamyJ, which also has no 2.11 build. We're also
using Jackson 2.3.1 internally, and the Jackson Scala module for that version is
not available for 2.11.

Solution

Because StreamyJ is used in a single test and nowhere else in Finagle, I've
simply ported the test to use vanilla Jackson, which allows us to remove the
dependency. The Jackson version used in the SBT builds for Finagle and
twitter-server now depends on the Scala version, and Finagle subprojects that we
can't build for 2.11 are excluded from the root finagle project. I've also
updated the Scala 2.11 versions in the SBT builds for Util and Scrooge from
2.11.2 to 2.11.4.

Result

We can publish 2.11 builds for twitter-server and all but five Finagle
subprojects. Note that finagle-example, finagle-ostrich4, finagle-redis, and
finagle-stress now must be tested and published individually, since they're no
longer aggregated by the root finagle project (this is similar to the current
status of util-eval).

RB_ID=532745
finagle-stream: ensure StreamServerDispatcher's response is released

Problem

StreamResponse release() callback is not always triggered when
clients disconnect.

Solution

Add an interrupt handler to ensure the response gets released.

RB_ID=532979
finagle-serversets: Rename core classes and separate them into distinct files

The following changes are made to the organization of
finagle-serversets:

- Move Zk2Resolver from ServerSet2.scala into Zk2Resolver.scala
- Zk.scala -> ZkSession.scala
- Rename ServerSet2 class/file to ServiceDiscoverer and update its
  Scaladoc
- Rename `ServerSet2.weighted` companion object function to
  `ServiceDiscoverer.zipWithWeights`
- Make the `entriesOf` and `vectorsOf` SS2 functions private[this],
  since they're only used internally to the class
- Repurpose `SS2.weightedOf` as `ServiceDiscoverer.apply`
- The appropriate test file/class name changes to adhere to the above
- Rename ZooKeeperZkTest to ZkSessionEndToEndTest

RB_ID=532959
finagle-core: Acknowledge ResolutionRaceTest is flakey

Problem

ResolutionRaceTest still fails intermittently in CI.

Solution

Mark it as flakey again.

RB_ID=534727
Introduce request contexts

Problem

This change solves two related problems.

1. The use of c.t.u.Local is fraught with potential misuse and
confusion. Finagle now delimits Locals in dispatchers, but there are
still many opportunities for misuse. The Local API is not conducive to
proper use. There have also been issues with leaks caused by misuse of
this API.

2. Finagle has no control over how request contexts are delimited. In
practice, they are backed by Locals, and thus suffer the same
problems. This causes confusion and bugs.

Solution

Provide a single, unified way of dealing with request-local data in
Finagle. We introduce type c.t.f.context.Context whose lifetimes are
managed by Finagle itself. There are two variants: Contexts.local
never escapes the local request graph, while Contexts.broadcast may
transit process boundaries, as is the case for current "request
contexts." This has the additional benefit of doing away with service
loading to support marshalled request contexts.

Most uses are ported over, including trace ids; some, like Dtab
locals, remain for porting over later.

Result

Fewer bugs, clearer code.

RB_ID=536961
TBR=true