Class ProxyEndpoint
java.lang.Object
com.netflix.zuul.filters.SyncZuulFilterAdapter<HttpRequestMessage,HttpResponseMessage>
com.netflix.zuul.filters.endpoint.ProxyEndpoint
- All Implemented Interfaces:
ShouldFilter<HttpRequestMessage>
,SyncZuulFilter<HttpRequestMessage,
,HttpResponseMessage> ZuulFilter<HttpRequestMessage,
,HttpResponseMessage> io.netty.util.concurrent.GenericFutureListener<io.netty.util.concurrent.Future<PooledConnection>>
,EventListener
@Filter(order=0,
type=ENDPOINT)
public class ProxyEndpoint
extends SyncZuulFilterAdapter<HttpRequestMessage,HttpResponseMessage>
implements io.netty.util.concurrent.GenericFutureListener<io.netty.util.concurrent.Future<PooledConnection>>
Not thread safe! New instance of this class is created per HTTP/1.1 request proxied to the origin but NOT for each
attempt/retry. All the retry attempts for a given HTTP/1.1 request proxied share the same EdgeProxyEndpoint instance
Created by saroskar on 5/31/17.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected final AtomicReference<InetAddress>
protected final AtomicReference<com.netflix.zuul.discovery.DiscoveryResult>
protected final SessionContext
protected RequestAttempt
protected RequestStat
protected MethodBinding<?>
protected final NettyOrigin
protected final OriginTimeoutManager
protected final CurrentPassport
static final String
protected final NettyRequestAttemptFactory
protected final RequestAttempts
protected List<RequestStat>
protected boolean
protected Duration
protected final HttpRequestMessage
protected HttpResponseMessage
-
Constructor Summary
ConstructorDescriptionProxyEndpoint
(HttpRequestMessage inMesg, io.netty.channel.ChannelHandlerContext ctx, FilterRunner<HttpResponseMessage, ?> filters, MethodBinding<?> methodBinding) ProxyEndpoint
(HttpRequestMessage inMesg, io.netty.channel.ChannelHandlerContext ctx, FilterRunner<HttpResponseMessage, ?> filters, MethodBinding<?> methodBinding, NettyRequestAttemptFactory requestAttemptFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCustomRequestHeaders
(Headers headers) apply
(HttpRequestMessage input) protected RequestStat
Override to track your own request stats.void
void
finish
(boolean error) int
protected RequestAttempt
Choose a default message to use if the applyAsync() method throws an exception.protected NettyOrigin
getOrigin
(HttpRequestMessage request) Get the implementing origin.protected OriginResponseReceiver
protected OriginTimeoutManager
getTimeoutManager
(NettyOrigin origin) protected void
handleOriginNonSuccessResponse
(io.netty.handler.codec.http.HttpResponse originResponse, com.netflix.zuul.discovery.DiscoveryResult chosenServer) protected void
handleOriginSuccessResponse
(io.netty.handler.codec.http.HttpResponse originResponse, com.netflix.zuul.discovery.DiscoveryResult chosenServer) protected OriginName
injectCustomOriginName
(HttpRequestMessage request) Inject your own custom VIP based on your own processing Note: this method gets called in the constructor so if overloading it or any methods called within, you cannot rely on your own constructor parameters.void
invokeNext
(HttpResponseMessage zuulResponse) void
invokeNext
(io.netty.handler.codec.http.HttpContent chunk) protected boolean
protected boolean
isRemoteZuulRetriesBelowRetryLimit
(int maxAllowedRetries) protected boolean
Request is replayable on a different origin IFF A) we have not started to send response back to the client AND B) we have not lost any of its body chunksprotected boolean
isRetryable
(ErrorType err) boolean
isRetryable5xxResponse
(HttpRequestMessage zuulRequest, io.netty.handler.codec.http.HttpResponse originResponse) void
operationComplete
(io.netty.util.concurrent.Future<PooledConnection> connectResult) protected boolean
originIndicatesRetryableInternalServerError
(io.netty.handler.codec.http.HttpResponse response) protected void
originNotFound
(SessionContext context, String causeName) protected void
postErrorProcessing
(Throwable ex, SessionContext zuulCtx, ErrorType err, com.netflix.zuul.discovery.DiscoveryResult chosenServer, int attemptNum) protected void
preWriteToOrigin
(com.netflix.zuul.discovery.DiscoveryResult chosenServer, HttpRequestMessage zuulRequest) io.netty.handler.codec.http.HttpContent
processContentChunk
(ZuulMessage zuulReq, io.netty.handler.codec.http.HttpContent chunk) Optionally transform HTTP content chunk received.void
responseFromOrigin
(io.netty.handler.codec.http.HttpResponse originResponse) protected HttpRequestMessage
transformRequest
(HttpRequestMessage requestMsg) protected void
updateOriginRpsTrackers
(NettyOrigin origin, int attempt) Methods inherited from class com.netflix.zuul.filters.SyncZuulFilterAdapter
applyAsync, decrementConcurrency, filterOrder, filterType, getSyncType, incrementConcurrency, isDisabled, needsBodyBuffered, overrideStopFilterProcessing, shouldFilter
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.netflix.zuul.filters.ZuulFilter
category
-
Field Details
-
chosenServer
-
chosenHostAddr
-
zuulRequest
-
context
-
origin
-
requestAttempts
-
passport
-
requestAttemptFactory
-
originTimeoutManager
-
methodBinding
-
zuulResponse
-
startedSendingResponseToClient
protected boolean startedSendingResponseToClient -
timeLeftForAttempt
-
attemptNum
protected int attemptNum -
currentRequestAttempt
-
requestStats
-
currentRequestStat
-
IDEMPOTENT_HTTP_METHODS
-
POOLED_ORIGIN_CONNECTION_KEY
- See Also:
-
-
Constructor Details
-
ProxyEndpoint
public ProxyEndpoint(HttpRequestMessage inMesg, io.netty.channel.ChannelHandlerContext ctx, FilterRunner<HttpResponseMessage, ?> filters, MethodBinding<?> methodBinding) -
ProxyEndpoint
public ProxyEndpoint(HttpRequestMessage inMesg, io.netty.channel.ChannelHandlerContext ctx, FilterRunner<HttpResponseMessage, ?> filters, MethodBinding<?> methodBinding, NettyRequestAttemptFactory requestAttemptFactory)
-
-
Method Details
-
getAttemptNum
public int getAttemptNum() -
getRequestAttempts
-
getCurrentRequestAttempt
-
getPassport
-
getOrigin
-
getZuulRequest
-
finish
public void finish(boolean error) -
filterName
- Specified by:
filterName
in interfaceZuulFilter<HttpRequestMessage,
HttpResponseMessage>
-
apply
- Specified by:
apply
in interfaceSyncZuulFilter<HttpRequestMessage,
HttpResponseMessage>
-
processContentChunk
public io.netty.handler.codec.http.HttpContent processContentChunk(ZuulMessage zuulReq, io.netty.handler.codec.http.HttpContent chunk) Description copied from interface:ZuulFilter
Optionally transform HTTP content chunk received.- Specified by:
processContentChunk
in interfaceZuulFilter<HttpRequestMessage,
HttpResponseMessage> - Overrides:
processContentChunk
in classSyncZuulFilterAdapter<HttpRequestMessage,
HttpResponseMessage>
-
getDefaultOutput
Description copied from interface:ZuulFilter
Choose a default message to use if the applyAsync() method throws an exception.- Specified by:
getDefaultOutput
in interfaceZuulFilter<HttpRequestMessage,
HttpResponseMessage> - Returns:
- ZuulMessage
-
invokeNext
-
invokeNext
public void invokeNext(io.netty.handler.codec.http.HttpContent chunk) -
updateOriginRpsTrackers
-
createRequestStat
Override to track your own request stats. -
operationComplete
- Specified by:
operationComplete
in interfaceio.netty.util.concurrent.GenericFutureListener<io.netty.util.concurrent.Future<PooledConnection>>
-
getOriginResponseReceiver
-
preWriteToOrigin
protected void preWriteToOrigin(com.netflix.zuul.discovery.DiscoveryResult chosenServer, HttpRequestMessage zuulRequest) -
isRemoteZuulRetriesBelowRetryLimit
protected boolean isRemoteZuulRetriesBelowRetryLimit(int maxAllowedRetries) -
isBelowRetryLimit
protected boolean isBelowRetryLimit() -
errorFromOrigin
-
postErrorProcessing
protected void postErrorProcessing(Throwable ex, SessionContext zuulCtx, ErrorType err, com.netflix.zuul.discovery.DiscoveryResult chosenServer, int attemptNum) -
isRetryable
-
isRequestReplayable
protected boolean isRequestReplayable()Request is replayable on a different origin IFF A) we have not started to send response back to the client AND B) we have not lost any of its body chunks -
responseFromOrigin
public void responseFromOrigin(io.netty.handler.codec.http.HttpResponse originResponse) -
handleOriginSuccessResponse
protected void handleOriginSuccessResponse(io.netty.handler.codec.http.HttpResponse originResponse, com.netflix.zuul.discovery.DiscoveryResult chosenServer) -
handleOriginNonSuccessResponse
protected void handleOriginNonSuccessResponse(io.netty.handler.codec.http.HttpResponse originResponse, com.netflix.zuul.discovery.DiscoveryResult chosenServer) -
isRetryable5xxResponse
public boolean isRetryable5xxResponse(HttpRequestMessage zuulRequest, io.netty.handler.codec.http.HttpResponse originResponse) -
originIndicatesRetryableInternalServerError
protected boolean originIndicatesRetryableInternalServerError(io.netty.handler.codec.http.HttpResponse response) -
transformRequest
-
addCustomRequestHeaders
-
getOrigin
Get the implementing origin. Note: this method gets called in the constructor so if overloading it or any methods called within, you cannot rely on your own constructor parameters. -
injectCustomOriginName
Inject your own custom VIP based on your own processing Note: this method gets called in the constructor so if overloading it or any methods called within, you cannot rely on your own constructor parameters.- Returns:
null
if unused.
-
originNotFound
-
getTimeoutManager
-