Search in sources :

Example 1 with ProxyEndpoint

use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.

the class ZuulFilterChainHandler method fireEndpointFinish.

protected void fireEndpointFinish(final boolean error) {
    final ZuulFilter endpoint = ZuulEndPointRunner.getEndpoint(zuulRequest);
    if (endpoint instanceof ProxyEndpoint) {
        final ProxyEndpoint edgeProxyEndpoint = (ProxyEndpoint) endpoint;
        edgeProxyEndpoint.finish(error);
    }
    zuulRequest = null;
}
Also used : ZuulFilter(com.netflix.zuul.filters.ZuulFilter) ProxyEndpoint(com.netflix.zuul.filters.endpoint.ProxyEndpoint)

Example 2 with ProxyEndpoint

use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.

the class ZuulEndPointRunner method filter.

@Override
public void filter(final HttpRequestMessage zuulReq) {
    if (zuulReq.getContext().isCancelled()) {
        PerfMark.event(getClass().getName(), "filterCancelled");
        zuulReq.disposeBufferedBody();
        logger.debug("Request was cancelled, UUID {}", zuulReq.getContext().getUUID());
        return;
    }
    final String endpointName = getEndPointName(zuulReq.getContext());
    try (TaskCloseable ignored = PerfMark.traceTask(this, s -> s.getClass().getSimpleName() + ".filter")) {
        Preconditions.checkNotNull(zuulReq, "input message");
        addPerfMarkTags(zuulReq);
        final ZuulFilter<HttpRequestMessage, HttpResponseMessage> endpoint = getEndpoint(endpointName, zuulReq);
        logger.debug("Got endpoint {}, UUID {}", endpoint.filterName(), zuulReq.getContext().getUUID());
        setEndpoint(zuulReq, endpoint);
        final HttpResponseMessage zuulResp = filter(endpoint, zuulReq);
        if ((zuulResp != null) && (!(endpoint instanceof ProxyEndpoint))) {
            // EdgeProxyEndpoint calls invokeNextStage internally
            logger.debug("Endpoint calling invokeNextStage, UUID {}", zuulReq.getContext().getUUID());
            invokeNextStage(zuulResp);
        }
    } catch (Exception ex) {
        handleException(zuulReq, endpointName, ex);
    }
}
Also used : HttpResponseMessage(com.netflix.zuul.message.http.HttpResponseMessage) HttpRequestMessage(com.netflix.zuul.message.http.HttpRequestMessage) ProxyEndpoint(com.netflix.zuul.filters.endpoint.ProxyEndpoint) TaskCloseable(io.perfmark.TaskCloseable)

Example 3 with ProxyEndpoint

use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.

the class OriginResponseReceiver method fireWriteError.

private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
    String errMesg = "Error while proxying " + requestPart + " to origin ";
    if (edgeProxy != null) {
        final ProxyEndpoint ep = edgeProxy;
        edgeProxy = null;
        errMesg += ep.getOrigin().getName();
        ep.errorFromOrigin(cause);
    }
    ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
Also used : ZuulException(com.netflix.zuul.exception.ZuulException) ProxyEndpoint(com.netflix.zuul.filters.endpoint.ProxyEndpoint)

Example 4 with ProxyEndpoint

use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.

the class ZuulEndPointRunner method filter.

@Override
public void filter(final HttpRequestMessage zuulReq, final HttpContent chunk) {
    if (zuulReq.getContext().isCancelled()) {
        chunk.release();
        return;
    }
    String endpointName = "-";
    try (TaskCloseable ignored = PerfMark.traceTask(this, s -> s.getClass().getSimpleName() + ".filterChunk")) {
        addPerfMarkTags(zuulReq);
        ZuulFilter<HttpRequestMessage, HttpResponseMessage> endpoint = Preconditions.checkNotNull(getEndpoint(zuulReq), "endpoint");
        endpointName = endpoint.filterName();
        final HttpContent newChunk = endpoint.processContentChunk(zuulReq, chunk);
        if (newChunk != null) {
            // Endpoints do not directly forward content chunks to next stage in the filter chain.
            zuulReq.bufferBodyContents(newChunk);
            // deallocate original chunk if necessary
            if (newChunk != chunk) {
                chunk.release();
            }
            if (isFilterAwaitingBody(zuulReq) && zuulReq.hasCompleteBody() && !(endpoint instanceof ProxyEndpoint)) {
                // whole body has arrived, resume filter chain
                invokeNextStage(filter(endpoint, zuulReq));
            }
        }
    } catch (Exception ex) {
        handleException(zuulReq, endpointName, ex);
    }
}
Also used : HttpResponseMessage(com.netflix.zuul.message.http.HttpResponseMessage) HttpRequestMessage(com.netflix.zuul.message.http.HttpRequestMessage) ProxyEndpoint(com.netflix.zuul.filters.endpoint.ProxyEndpoint) HttpContent(io.netty.handler.codec.http.HttpContent) TaskCloseable(io.perfmark.TaskCloseable)

Aggregations

ProxyEndpoint (com.netflix.zuul.filters.endpoint.ProxyEndpoint)4 HttpRequestMessage (com.netflix.zuul.message.http.HttpRequestMessage)2 HttpResponseMessage (com.netflix.zuul.message.http.HttpResponseMessage)2 TaskCloseable (io.perfmark.TaskCloseable)2 ZuulException (com.netflix.zuul.exception.ZuulException)1 ZuulFilter (com.netflix.zuul.filters.ZuulFilter)1 HttpContent (io.netty.handler.codec.http.HttpContent)1