Move AccessPoint to lib/network, code cleanup.

Summary:
Move AccessPoint from mcrouter/ to mcrouter/lib/network
Remove mc_accesspoint_t usage.
Remove mc_transport_t references, since it's just one value, which is always mc_stream.
Remove redundant constructors/operators from AccessPoint.

Test Plan: unit tests

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1703014

Signature: t1:1703014:1417037360:a31631839ac162ccfcca55406f4140e0ed8e525e
FBTrace support in AsyncMcClient (internal use)

Summary: C++-ish rewrite of fbtrace support in mcrouter/lib/mc.

Test Plan: tests

Reviewed By: alikhtarov@fb.com

Subscribers: mibpl, trunkagent, alikhtarov

FB internal diff: D1689330

Tasks: 5400245

Signature: t1:1689330:1417036675:b7919d63182cdaa53926684f0e71b4e7a24afde4
ShardSplitRoute to only broadcast deletes

Summary: Writes should go to the primary split under tao shard splitting, not all splits. This diff changes ShardSplitRoute to send reads to a random split, writes to the primary split, and deletes to all splits. We can create a separate route handle if ShardSplitRoute's old behaviour was useful outside of tao

Test Plan: fbconfig -r mcrouter; fbmake runtests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, vikas, alikhtarov, tao-eng@

FB internal diff: D1704619

Tasks: 4223292

Signature: t1:1704619:1417469710:b3be0ae21c039a4938e0b6f13340a08a5a013f87
Add batching stat

Summary: Add additional stat that show average batch size that been sent by AsyncMcClient

Test Plan:
look at stats file and see that it's here:
"libmcrouter.unknown.web.destination_batch_size" : 3.0474609375,

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1692494

Tasks: 5634695

Signature: t1:1692494:1417050799:fe2881c44eb34313daf403a18be33111d45e8304
Provide user context for addSecureClientSocket

Summary: same as title

Test Plan: - ran all unit tests

Reviewed By: alikhtarov@fb.com

Subscribers: alikhtarov

FB internal diff: D1711830

Signature: t1:1711830:1417484724:3e5994c60d6f7aa62bda4b8b6f9fca8df99dd7d1
Fix use after free

Summary: The original request is kept alive (McMsgRef), but the wrapper McRequest gets destroyed, once we exit the send method.

Test Plan: tests

Reviewed By: alikhtarov@fb.com

Subscribers: alikhtarov

FB internal diff: D1711526

Tasks: 5728329

Signature: t1:1711526:1417481120:f5d7b8764fe833d82cb4dd5b3581aecfdc5b8d8b

Blame Revision: D1689330
Remove per proxy TKO

Summary: Global TKO is live and should probably be launched globally Wednesday. At this point per proxy TKO is legacy, so we should just remove it

Test Plan: unit tests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, sameen, ipozgaj, alikhtarov

FB internal diff: D1505879

Tasks: 4539215

Signature: t1:1505879:1417720421:83a9b290b38f2ab2f65b9c42360ff0be9db60cdd
Updated no-network mode

Summary:
This diff adds AsyncMcClient and protocol parsing/serialization logic into no-network mode.
Now the only thing that is not covered by no-network is folly sockets performance.

Test Plan:
unit tests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1672016

Tasks: 4897690

Signature: t1:1672016:1417635901:f86e126e337e2b58904886600396d2fcec2f7f96
Optimize ConfigPreprocessor, allow spaces in macro call

Summary: most copies replaced with moves, also spaces are trimmed in macro call

Test Plan: mcrouter unit tests, configure mcrouter with different flavors

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1710636

Signature: t1:1710636:1417729556:52dc926eabef2d53cb309a3bdf13b88189618597
Some reconfiguration code refactoring

Summary:

Test Plan:
unit tests; shadow test

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1714000

Signature: t1:1714000:1417748967:1f69d8546c714ab6d58b7ddf0e0e5046568f7bd2
Fix stuck connection when closed in the middle of multiget

Summary:
If we close a connection in the middle of parsing a multiget request (like 'get a b'),
we will never process the terminating mc_op_end.
Pretend that we got mc_op_end in close().

Test Plan:
Started mcrouter on port 5000 and sent 'get a b' without terminating '\r\n':
```
cat <(echo -ne 'get a b') - | nc 0 5000
```
Then sent a SIGINT to mcrouter, and finally newline over the connection.
Without this fix, mcrouter process stays alive. With the fix, SIGINT closes the connection
and responds to the outstanding 'get a' and 'get b' immediately.

Reviewed By: pavlo@fb.com

Subscribers: alikhtarov

FB internal diff: D1723289

Tasks: 5665773

Signature: t1:1723289:1417823539:08b9bb1f909c6e8e638a7a3f1088880d73396b81
Add QoS support

Summary:
This patch adds QoS support to mcrouter. It can be set at 3 distinct
levels: default, pool or server. The order of priority is (as expected) server >
pool > default.
QoS is disabled by default. To enable it, it is necessary to toggle this flag:
--enable-qos.
If QoS is enabled, one might want to set it's default level value (which, if not
informed, is 0). To do so, use the option: --default-qos-class.
QoS classes go from 0 (lowest priority) to 4 (highest priority). Anything
outside this range is considered invalid.

Test Plan:
Added some basic unit tests and executed some tests, which are
detailed bellow:

1) Execute mcrouter with the following command line:

mcrouter -f ... -R ... --num-proxies=32 -p 5000 --enable-qos --default-qos-class 3

2) Execute tshark to inspect the packages with the following command line:

sudo tshark -i eth0 -R "ipv6.class == 128"

3) Sent a GET to mcrouter using the following command line:

echo -ne "get test.key\r\n" | nc 0 5000

4) Verify whether the packages were captured by tshark.

5) Repeat steps 1 to 4 changing the parameters to cover all available QoS
classes, i.e. change parameter default-qos-class on step 1 to 0-4 and change
the parameter "128" in step 2 to [0, 4, 64, 128, 128].

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, ps, bmatheny, alikhtarov

FB internal diff: D1720154

Tasks: 4867290

Signature: t1:1720154:1417748531:8ffc25b0ab827efa582d80aaa9f2379dc146ef99
Improve mcrouter IOBuf usage

Summary: Currently we wrap McMsgRef into IOBuf when we construct ProxyMcRequest, then we unwrap it into McMsgRef (possibly with stripped prefix), then do wrap it again into IOBuf when calling AsyncMcClient.

Test Plan: unittests

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1631432

Tasks: 5414934

Signature: t1:1631432:1417820866:1b633b48569e3890dd38410d949bbc801c256ba3
fix background (-b) mode

Summary:
stable background and unit tests

Test Plan: unittests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1707526

Tasks: 5675248

Signature: t1:1707526:1417726269:101f6f16767280d472de29ffe4aef12c41db1db4