in zuul-core/src/main/java/com/netflix/zuul/filters/endpoint/ProxyEndpoint.java [476:523]
private void proxyRequestToOrigin() {
Promise<PooledConnection> promise = null;
try {
attemptNum += 1;
/*
* Before connecting to the origin, we need to compute how much time we have left for this attempt. This
* method is also intended to validate deadline and timeouts boundaries for the request as a whole and could
* throw an exception, skipping the logic below.
*/
timeLeftForAttempt = originTimeoutManager.computeReadTimeout(zuulRequest, attemptNum);
currentRequestStat = createRequestStat();
origin.preRequestChecks(zuulRequest);
concurrentReqCount.incrementAndGet();
// update RPS trackers
updateOriginRpsTrackers(origin, attemptNum);
// We pass this AtomicReference<Server> here and the origin impl will assign the chosen server to it.
promise = origin.connectToOrigin(
zuulRequest, channelCtx.channel().eventLoop(), attemptNum, passport, chosenServer, chosenHostAddr);
storeAndLogOriginRequestInfo();
currentRequestAttempt =
origin.newRequestAttempt(chosenServer.get(), chosenHostAddr.get(), context, attemptNum);
requestAttempts.add(currentRequestAttempt);
passport.add(PassportState.ORIGIN_CONN_ACQUIRE_START);
if (promise.isDone()) {
operationComplete(promise);
} else {
promise.addListener(this);
}
} catch (Exception ex) {
if (ex instanceof RequestExpiredException) {
logger.debug("Request deadline expired while connecting to origin, UUID {}", context.getUUID(), ex);
} else {
logger.error("Error while connecting to origin, UUID {}", context.getUUID(), ex);
}
storeAndLogOriginRequestInfo();
if (promise != null && !promise.isDone()) {
promise.setFailure(ex);
} else {
errorFromOrigin(ex);
}
}
}