Unify headers

Summary:
title

Test Plan: build mcrouter

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, vikas, shilin, fugalh, alikhtarov

FB internal diff: D1573292
Fix opensource build

Summary: <config.h> is not resolved properly.

Test Plan: verify mcrouter build

Reviewed By: stepan@fb.com

Subscribers: alikhtarov

FB internal diff: D1582899
Reduce logging verbosity

Summary:
Static initialization of these classes log to stderr which breaks
assumptions in other projects about errors parsing.

Test Plan: unit tests and sandcastle

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1581766
Fix on_up callback been called from zombie client

Summary:
Currently we don't fail outstanding requests immediately (if there're any). And we actually shouldn't get here if we have them.
This is a fix "just to be safe".

Test Plan:
unit tests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1584272

Tasks: 5230657
Negative caching logic for L1/L2

Summary: First pass. The update period is a simple counter, not randomized - easy to change later.

Test Plan:
unit test included

Reviewed By: stepan@fb.com

Subscribers: trunkagent, omry, alikhtarov

FB internal diff: D1494383
Fix build

Summary: title

Test Plan: build mcrouter

Reviewed By: omry@fb.com

Subscribers: omry, alikhtarov

FB internal diff: D1590128

Blame Revision: D1494383
Improve performance of AllSync and AllAsync

Summary:
title

Test Plan: mcrouter unit tests

Reviewed By: stepan@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1587750

Tasks: 5214563
Only unmark TKO on probes

Summary: We don't want outstanding requests to unmakr TKO on a box. This creates an unpredictable scenario for TKO, as instead of needing 3 consecutive failures or whatever, we actually may need 20 because of outstanding requests. It also undermines initial probe delay and the predictability of that

Test Plan: unit tests

Reviewed By: pavlo@fb.com

Subscribers: meisner, trunkagent, sameen, alikhtarov

FB internal diff: D1587681

Tasks: 5275894
Properly track used config files

Summary: currently after each reconfiguration we only add additional files to track. With this change, we will reconfigure only if files from current config are updated.

Test Plan:
unit tests

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1588701

Tasks: 5147262
Reduce log level

Summary: this spams in HHVM logs.

Test Plan: run mcrouter unit tests

Reviewed By: stepan@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1594436

Tasks: 5301590
Compatibility with boost 1.56

Summary: boost context API has changed with new version of boost. This diff adds a wrapper around calls to this library, so mcrouter works with all versions of boost since 1.51.

Test Plan: run mcrouter unit tests with different versions of boost

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1590515
Simplify ProxyDestinationMap reconfigure

Summary: this diff simplifies logic of reusing/removing ProxyDestinations on reconfigure.

Test Plan: mcrouter unit tests, add/remove servers to mcrouter config and check ProxyDestinations are reused/destroyed correctly.

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1583861
Add logFailure, version 2

Summary:
Logging for failures (something broken pretty badly, we want to let system administrator know about it).
The logic is following:
1) Each service on startup sets its 'context': options, version, etc.
2) We may specify set of actions for "logFailure": log to stderr, custom action handler, throw an exception or exit(EXIT_FAILURE)
This way, if we want to verify config, we'll simply call "failure::setFailureAction(/* crash, throw, whatever */)" in main.
3) In the code itself just use "logFailure" to log whatever we want. Corresponding actions will be done; context will be included in logs.

Test Plan: mcrouter unit tests, run mcrouter and check the logs

Reviewed By: alikhtarov@fb.com

Subscribers: chip, zhuohuang, trunkagent, fugalh, alikhtarov

FB internal diff: D1571544

Tasks: 5147288
Fix clang build

Test Plan:
build it

Reviewed By: alikhtarov@fb.com

Subscribers: mathieubaudet, alikhtarov

FB internal diff: D1606293
Add fiber::forEach, improve whenAll

Summary:
Add method that would run tasks andfor each of them call callback when it's completed. In contrast to whenN, it allows us to save one fiber (i.e. we would run n-1 task on new fibers and would use current fiber to run the last one).
This in turn makes whenAll faster and efficient: one less malloc (for context), one less fiber usage.
ForEach also provides a way to run tasks without additional allocations at all (we still do allocate 3 vectors inside of whenAll).

Test Plan: unit tests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov, mpawlowski

FB internal diff: D1609172

Tasks: 5214563
Hotfix crashes

Summary: D1571544 caused lots of test failures; this diff otfixes the problem

Test Plan:
unit tests

Reviewed By: chip@fb.com

Subscribers: chip, alikhtarov

FB internal diff: D1612126

Tasks: 5353022

Blame Revision: D1571544
Fix MigrateRoute couldRouteTo

Summary: oops, it was broken: for deletes during migration it returned 0 zero route handles, but should have returned {from, to}

Test Plan: unit test attached

Reviewed By: alikhtarov@fb.com

Subscribers: alikhtarov

FB internal diff: D1613780
RoutingPrefix

Summary:
This diff introduces RoutingPrefix structure to parse and store mcrouter's routing prefix (e.g. default_route). It simplifies accessing route and cluster parts of routing prefix and improves validation.
Running mcrouter with broken default route:
E1006 10:45:09.554698 24735 main.cpp:577] CRITICAL: Option parse error: default_route=/broken_route/, couldn't convert value to routing prefix. Exception: Routing prefix (/broken_route/) should be of the form /region/cluster/
... here comes print_usage_and_die ...

Example of broken routing prefix in mcrouter config:
E1006 10:42:19.191120 20975 proxy.cpp:830] CRITICAL: Error creating ProxyRoute: Routing prefix (/broken_prefix/) should be of the form /region/cluster/

Test Plan: mcrouter unit tests

Reviewed By: alikhtarov@fb.com

Subscribers: alikhtarov

FB internal diff: D1597515
Improve AllSyncRoute

Summary:
This diff reduces 3 vector allocations and ~1-2N std::moves of Replies in AllSyncRoute
We don't need to allocate vectors for storring and re-ordering replies, since we are going to perform pairwise reduce anyway.

Test Plan: tests

Reviewed By: pavlo@fb.com

Subscribers: mpawlowski, alikhtarov

FB internal diff: D1613435

Tasks: 5214563
Remove unnecessary moving follyMoveWrapper

Summary: Remove unnecessary moves of functions.

Test Plan: tests

Reviewed By: andrii@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1613317