-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split McRouteHandleProvider.cpp to speed up compile time
Summary: Split McRouteHandleProvider.cpp to speed up compile time Reviewed By: danobi Differential Revision: D26886048 fbshipit-source-id: 8af5f4196f5e178c7145d530f1a9832e534770f6
- Loading branch information
1 parent
99133d2
commit a3d9640
Showing
7 changed files
with
268 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "mcrouter/routes/McRouteHandleProvider.h" | ||
|
||
#include "mcrouter/routes/AllAsyncRouteFactory.h" | ||
#include "mcrouter/routes/AllFastestRouteFactory.h" | ||
#include "mcrouter/routes/AllInitialRouteFactory.h" | ||
#include "mcrouter/routes/AllMajorityRouteFactory.h" | ||
#include "mcrouter/routes/AllSyncRouteFactory.h" | ||
#include "mcrouter/routes/BlackholeRoute.h" | ||
#include "mcrouter/routes/CarbonLookasideRoute.h" | ||
|
||
namespace facebook { | ||
namespace memcache { | ||
namespace mcrouter { | ||
|
||
using McRouteHandleFactory = RouteHandleFactory<McrouterRouteHandleIf>; | ||
using MemcacheRouterInfo = facebook::memcache::MemcacheRouterInfo; | ||
|
||
/** | ||
* This implementation is only for test purposes. Typically the users of | ||
* CarbonLookaside will be services other than memcache. | ||
*/ | ||
class MemcacheCarbonLookasideHelper { | ||
public: | ||
MemcacheCarbonLookasideHelper(const folly::dynamic* /* jsonConfig */) {} | ||
|
||
static std::string name() { | ||
return "MemcacheCarbonLookasideHelper"; | ||
} | ||
|
||
template <typename Request> | ||
bool cacheCandidate(const Request& /* unused */) const { | ||
if (HasKeyTrait<Request>::value) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
template <typename Request> | ||
std::string buildKey(const Request& req) const { | ||
if (HasKeyTrait<Request>::value) { | ||
return req.key_ref()->fullKey().str(); | ||
} | ||
return std::string(); | ||
} | ||
|
||
template <typename Reply> | ||
bool shouldCacheReply(const Reply& /* unused */) const { | ||
return true; | ||
} | ||
|
||
template <typename Reply> | ||
void postProcessCachedReply(Reply& /* reply */) const {} | ||
}; | ||
|
||
template <> | ||
void McRouteHandleProvider<MemcacheRouterInfo>::buildRouteMap0( | ||
RouteHandleFactoryMap& map) { | ||
map.insert( | ||
std::make_pair("AllAsyncRoute", &makeAllAsyncRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"AllFastestRoute", &makeAllFastestRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"AllInitialRoute", &makeAllInitialRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"AllMajorityRoute", &makeAllMajorityRoute<MemcacheRouterInfo>)); | ||
map.insert( | ||
std::make_pair("AllSyncRoute", &makeAllSyncRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"BlackholeRoute", &makeBlackholeRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"CarbonLookasideRoute", | ||
&createCarbonLookasideRoute< | ||
MemcacheRouterInfo, | ||
MemcacheCarbonLookasideHelper>)); | ||
} | ||
|
||
} // namespace mcrouter | ||
} // namespace memcache | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "mcrouter/routes/McRouteHandleProvider.h" | ||
|
||
#include "mcrouter/routes/DevNullRoute.h" | ||
#include "mcrouter/routes/ErrorRoute.h" | ||
#include "mcrouter/routes/FailoverRoute.h" | ||
#include "mcrouter/routes/FailoverWithExptimeRouteFactory.h" | ||
#include "mcrouter/routes/HashRouteFactory.h" | ||
#include "mcrouter/routes/HostIdRouteFactory.h" | ||
#include "mcrouter/routes/L1L2CacheRouteFactory.h" | ||
#include "mcrouter/routes/LatencyInjectionRoute.h" | ||
|
||
namespace facebook { | ||
namespace memcache { | ||
namespace mcrouter { | ||
|
||
using McRouteHandleFactory = RouteHandleFactory<McrouterRouteHandleIf>; | ||
using MemcacheRouterInfo = facebook::memcache::MemcacheRouterInfo; | ||
|
||
template <> | ||
void McRouteHandleProvider<MemcacheRouterInfo>::buildRouteMap1( | ||
RouteHandleFactoryMap& map) { | ||
map.insert( | ||
std::make_pair("DevNullRoute", &makeDevNullRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair("ErrorRoute", &makeErrorRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"FailoverWithExptimeRoute", | ||
&makeFailoverWithExptimeRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"HashRoute", | ||
[](McRouteHandleFactory& factory, const folly::dynamic& json) { | ||
return makeHashRoute<McrouterRouterInfo>(factory, json); | ||
})); | ||
map.insert( | ||
std::make_pair("HostIdRoute", &makeHostIdRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"LatencyInjectionRoute", &makeLatencyInjectionRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"L1L2CacheRoute", &makeL1L2CacheRoute<MemcacheRouterInfo>)); | ||
} | ||
|
||
} // namespace mcrouter | ||
} // namespace memcache | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "mcrouter/routes/McRouteHandleProvider.h" | ||
|
||
#include "mcrouter/routes/KeySplitRoute.h" | ||
#include "mcrouter/routes/L1L2SizeSplitRoute.h" | ||
#include "mcrouter/routes/LatestRoute.h" | ||
#include "mcrouter/routes/LoadBalancerRoute.h" | ||
#include "mcrouter/routes/LoggingRoute.h" | ||
#include "mcrouter/routes/MigrateRouteFactory.h" | ||
#include "mcrouter/routes/MissFailoverRoute.h" | ||
|
||
namespace facebook { | ||
namespace memcache { | ||
namespace mcrouter { | ||
|
||
using McRouteHandleFactory = RouteHandleFactory<McrouterRouteHandleIf>; | ||
using MemcacheRouterInfo = facebook::memcache::MemcacheRouterInfo; | ||
|
||
template <> | ||
void McRouteHandleProvider<MemcacheRouterInfo>::buildRouteMap2( | ||
RouteHandleFactoryMap& map) { | ||
map.insert(std::make_pair("L1L2SizeSplitRoute", &makeL1L2SizeSplitRoute)); | ||
map.insert(std::make_pair("KeySplitRoute", &makeKeySplitRoute)); | ||
map.insert( | ||
std::make_pair("LatestRoute", &makeLatestRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"LoadBalancerRoute", &makeLoadBalancerRoute<MemcacheRouterInfo>)); | ||
map.insert( | ||
std::make_pair("LoggingRoute", &makeLoggingRoute<MemcacheRouterInfo>)); | ||
map.insert( | ||
std::make_pair("MigrateRoute", &makeMigrateRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"MissFailoverRoute", &makeMissFailoverRoute<MemcacheRouterInfo>)); | ||
} | ||
|
||
} // namespace mcrouter | ||
} // namespace memcache | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "mcrouter/routes/McRouteHandleProvider.h" | ||
|
||
#include "mcrouter/routes/ModifyExptimeRoute.h" | ||
#include "mcrouter/routes/ModifyKeyRoute.h" | ||
#include "mcrouter/routes/OperationSelectorRoute.h" | ||
#include "mcrouter/routes/OriginalClientHashRoute.h" | ||
#include "mcrouter/routes/RandomRouteFactory.h" | ||
#include "mcrouter/routes/RoutingGroupRoute.h" | ||
#include "mcrouter/routes/ShadowRoute.h" | ||
#include "mcrouter/routes/StagingRoute.h" | ||
|
||
namespace facebook { | ||
namespace memcache { | ||
namespace mcrouter { | ||
|
||
using McRouteHandleFactory = RouteHandleFactory<McrouterRouteHandleIf>; | ||
using MemcacheRouterInfo = facebook::memcache::MemcacheRouterInfo; | ||
|
||
McrouterRouteHandlePtr makeWarmUpRoute( | ||
McRouteHandleFactory& factory, | ||
const folly::dynamic& json); | ||
|
||
template <> | ||
void McRouteHandleProvider<MemcacheRouterInfo>::buildRouteMap3( | ||
RouteHandleFactoryMap& map) { | ||
map.insert(std::make_pair( | ||
"ModifyKeyRoute", &makeModifyKeyRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"ModifyExptimeRoute", &makeModifyExptimeRoute<MemcacheRouterInfo>)); | ||
map.insert( | ||
std::make_pair("NullRoute", &makeNullRoute<MemcacheRouteHandleIf>)); | ||
map.insert(std::make_pair( | ||
"OperationSelectorRoute", | ||
&makeOperationSelectorRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"OriginalClientHashRoute", | ||
&makeOriginalClientHashRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"PoolRoute", | ||
[this](McRouteHandleFactory& factory, const folly::dynamic& json) { | ||
return makePoolRoute(factory, json); | ||
})); | ||
map.insert(std::make_pair( | ||
"PrefixPolicyRoute", &makeOperationSelectorRoute<MemcacheRouterInfo>)); | ||
map.insert( | ||
std::make_pair("RandomRoute", &makeRandomRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair( | ||
"RateLimitRoute", | ||
[](McRouteHandleFactory& factory, const folly::dynamic& json) { | ||
return makeRateLimitRoute(factory, json); | ||
})); | ||
map.insert(std::make_pair( | ||
"RoutingGroupRoute", &makeRoutingGroupRoute<MemcacheRouterInfo>)); | ||
map.insert(std::make_pair("StagingRoute", &makeStagingRoute)); | ||
map.insert(std::make_pair( | ||
"SRRoute", | ||
[this](McRouteHandleFactory& factory, const folly::dynamic& json) { | ||
return createSRRoute(factory, json); | ||
})); | ||
map.insert(std::make_pair("WarmUpRoute", &makeWarmUpRoute)); | ||
} | ||
|
||
} // namespace mcrouter | ||
} // namespace memcache | ||
} // namespace facebook |
Oops, something went wrong.