in mcrouter/routes/McRouteHandleProvider.cpp [153:210]
std::shared_ptr<AccessPoint> createAccessPoint(
folly::StringPiece apString,
uint32_t failureDomain,
CarbonRouterInstanceBase& router,
const CommonAccessPointAttributes& apAttr) {
auto& protocol = apAttr.protocol;
auto& mech = apAttr.mech;
auto& mechOverride = apAttr.mechOverride;
auto& withinDcMech = apAttr.withinDcMech;
auto& crossDcMech = apAttr.crossDcMech;
auto& crossDcPort = apAttr.crossDcPort;
auto& withinDcPort = apAttr.withinDcPort;
auto& port = apAttr.port;
auto& enableCompression = apAttr.enableCompression;
auto ap = AccessPoint::create(
apString, protocol, mech, port, enableCompression, failureDomain);
checkLogic(ap != nullptr, "invalid server {}", apString);
if (mechOverride.has_value()) {
ap->setSecurityMech(mechOverride.value());
}
if (withinDcMech.has_value() || crossDcMech.has_value() ||
withinDcPort.has_value() || crossDcPort.has_value()) {
bool isInLocalDc = isInLocalDatacenter(ap->getHost());
if (isInLocalDc) {
if (withinDcMech.has_value()) {
ap->setSecurityMech(withinDcMech.value());
}
if (withinDcPort.has_value()) {
ap->setPort(withinDcPort.value());
}
} else {
if (crossDcMech.has_value()) {
ap->setSecurityMech(crossDcMech.value());
}
if (crossDcPort.has_value()) {
ap->setPort(crossDcPort.value());
}
}
}
if (ap->compressed() && router.getCodecManager() == nullptr) {
if (!initCompression(router)) {
MC_LOG_FAILURE(
router.opts(),
failure::Category::kBadEnvironment,
"Pool {}: Failed to initialize compression. "
"Disabling compression for host: {}",
apAttr.poolName,
apString);
ap->disableCompression();
}
}
return ap;
}