[split] Document names and naming in finagle.

RB_ID=334077
[split] [finagle-core] transport should be considered closed if it is failed

Problem

When failing the channel transport, the channel is closed and its
close promise completed. Closing the channel is asynchronous though
so the trasnport still is considered open until the close operation
completes.

Solution

Check the status of "failed" when checking if the channel is open.

Result

Channels that are failing will not be considered open. Services
that dispatch to failing channels will not be considered available.

RB_ID=336543
[split] [finagle-http] fix HttpClientDispatcher

Problem

When reading HTTP chunks from the transport, failures did not
result in the tryDispatch promise being set. This, coupled with
a race condition in ChannelTransport caused requests to become
queued on the dispatcher apply semaphore and never written to the
transport.

Solution

The tryDispatch promise is updated on transport read failures.

Result

Requests no longer block indefinitely on the dispatch apply semaphore.

RB_ID=336297
[split] serverset namer: synthesize nodes for each endpoint

Problem

Some serversets make use of endpoints, e.g. cuckoo's http endpoint.
These are inaccessible through Wily.

Solution

Synthesize nodes for each endpoint, using the character ':' to
indicate that the endpoint name follows. Endpoints can now be
accessed; for example

	/s/cuckoo/read:http

(Note that there is nothing special about this path -- we have just
synthesized nodes through a convention.)

(Joint work with ver@)

RB_ID=336619
[split] finagle: Add a new sbt target to publish locally to m2

Problem

Publishing the maven-scrooge-plugin requires having access to the latest finagle.
Every time we publish, we need to wait for the finagle release to be available on Sonatype.

Solution

Rather than waiting for the release to be available on Sonatype, this new sbt target
installs it locally.

Result

./sbt +publish-m2 publish the jars in the local maven repository

RB_ID=337149
[split] Move mysql testing out of finagle-mysql

Problem:
In our attempts to move finagle into aviary, I discovered a library for
testing finagle-mysql that's defined in the tests section.  We do not
publish finagle testing jars, so when finagle goes to jars, this library
will break.

Solution:
Moving these classes (which actually aren't used or tested by
finagle-mysql) into their own project so that they can stay in birdcage
and perhaps be moved later when the dependees are all in aviary.

RB_ID=335581
[split] finagle-stats: Enable cumulative gauges in MetricsStatsReceiver

Motivation:
MetricsStatsReceiver was lacking support for cumulative gauges.
Indeed there's a few usage of that in finagle, when two code path create
a gauge with the same name, they're summed during the collection.

Modifications:
- MetricsStatsReceiver now inherits StatsReceiverWithCumulativeGauges
- Port Spec tests to scalatest
- Add a new test for cumulative gauges
- Avoid sorting the stats on "non-pretty-printed" collection

Result:
Adding two gauges with the same name results in one gauge, its value is the sum
of the two previous one.

RB_ID=326301
[split] finagle-stats: upgrade to the latest version of metrics

Problem
The version of c.t.c.metrics currently used is old and doesn't contains all
the new optimizations.

Solution
Bump the version to 0.0.24 (the one with the lazy buffer allocation)

RB_ID=337833
TBR=true
[split] Add license to finagle-thrift ruby gemspec

Signed-off-by: Moses Nakamura <mnakamura@twitter.com>

RB_ID=337957
[split] [finagle-core] fix truncation in ChannelBufferBuf#slice()

Problem

The contract for slice() request that out of bounds indices
be truncated, but instead, ChannelBufferBuf#slice() throws
an exception if i > 0 and j-i > length + buf.capacity().

Solution

Check for out of bounds indices and truncate the length in
the call to buf.slice().

Result

slice() can be called with out of bounds indices.

RB_ID=338297
[split] Upgrade metrics, which pulls in java 7 jars.

RB_ID=338801
[split] finagle: Fixes the sbt build Problem http://bigbird.sf.office.twttr.net/job/sbt-continuous-testing/60/console

Solution
Updated util, finagle Build.scalas

Result
sbt-continuous-test no longer fails

RB_ID=339213
[split] finagle-stats: unregister cumulative gauges when all references have been collected

Problem

MetricsStatsReceiver recently implemented StatsReceiverWithCumulativeGauges.
StatsReceiverWithCumulativeGauges need to unregister gauges (from the underlying metrics
library) that are not strongly referenced anymore.

Solution

Wire the functions, 'deregisterGauge' now is calling 'registry.unregister'

RB_ID=340689
[split] finagle-doc: fix image size in client stack figure.

RB_ID=340957
TBR=true
[split] Add Socks Proxy Authentication support (updated from RB=284289)

RB_ID=337745
[split] ChannelTransport: don't discard outstanding readq elements

Problem

There exists a race between fully reading a queue and failing it due
to some exception (e.g. channel closed). This was observed in
streaming HTTP with Connection: close, where a server will send data
and then immediately close the connection. Thus a race between fully
reading the stream and the server closing the connection.

Solution

Add an option to AsyncQueue.fail to not discard the queue, but instead
wait to fail pollers until any pending elements have been read.

Result

No more races.

RB_ID=342467
[split] [finagle-http] temporary fix for CSL-915

Problem

ExpiringService may close client connections before
all HTTP chunks have been read.

Solution

Wrap with DelayedReleaseService in prepareConnFactory.

Result

Close calls are blocked until all chunks have been read.

RB_ID=344615
[split] Finagle HTTP: fix basic authentication with special characters

https://github.com/twitter/finagle/pull/262

     Problem
     HTTP basic authentication for users that have special characters
     in their name or password didn't work (for example, joe@host.com)

     Solution
     Changed RequestBuilder.url() to use java.net.URI.getUserInfo
     which correctly performs unescaping instead of java.net.URL.getUserInfo which simply returns raw data

     Result
     Users that have special characters in their name or password can successfully
     authenticate themselves via basic authentication

RB_ID=342229
[split] [finagle-http] create HttpTransport in codec

Problem

RichHttp client wraps the transport with the HTTP connection
manager inside HttpClientDispatcher. This causes any calls
from the underlying client dispatcher to bypass the wrapped
transport.

Solution

Wrap the transport using the provided codec API.

Result

HttpTransport is available to both HttpClientDispatcher as
well as GenSerialClientDispatcher.

RB_ID=344597
[split]  Remove the references to org.jboss.netty.util.CharsetUtil

Motivation

In preparation for migration from Netty 3 to 4, we should not use
CharsetUtil from Netty 3 but use com.twitter.io.Charsets.

Modification

- Use com.twitter.io.Charsets instead of CharsetUtil wherever possible
- Remove some unused imports and sort imports of the modified files

Result

The half of the step 1 of the Netty 4 migration plan is fulfilled. [1]

[1] https://confluence.twitter.biz/display/CSL/Finagle+Netty+4+migration

RB_ID=337167
TBR=true