Search in sources :

Example 1 with TaskCloseable

use of io.perfmark.TaskCloseable in project zuul by Netflix.

the class BaseZuulFilterRunner method invokeNextStage.

protected final void invokeNextStage(final O zuulMesg, final HttpContent chunk) {
    if (nextStage != null) {
        try (TaskCloseable ignored = traceTask(this, s -> s.getClass().getSimpleName() + ".invokeNextStageChunk")) {
            addPerfMarkTags(zuulMesg);
            nextStage.filter(zuulMesg, chunk);
        }
    } else {
        // Next stage is Netty channel handler
        try (TaskCloseable ignored = traceTask(this, s -> s.getClass().getSimpleName() + ".fireChannelReadChunk")) {
            addPerfMarkTags(zuulMesg);
            getChannelHandlerContext(zuulMesg).fireChannelRead(chunk);
        }
    }
}
Also used : TaskCloseable(io.perfmark.TaskCloseable)

Example 2 with TaskCloseable

use of io.perfmark.TaskCloseable 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 TaskCloseable

use of io.perfmark.TaskCloseable in project zuul by Netflix.

the class ZuulFilterChainRunner method resume.

@Override
protected void resume(final T inMesg) {
    try (TaskCloseable ignored = PerfMark.traceTask(this, s -> s.getClass().getSimpleName() + ".resume")) {
        final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
        runningFilterIdx.incrementAndGet();
        runFilters(inMesg, runningFilterIdx);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TaskCloseable(io.perfmark.TaskCloseable)

Example 4 with TaskCloseable

use of io.perfmark.TaskCloseable in project zuul by Netflix.

the class ZuulFilterChainRunner method filter.

@Override
public void filter(final T inMesg) {
    try (TaskCloseable ignored = PerfMark.traceTask(this, s -> s.getClass().getSimpleName() + ".filter")) {
        addPerfMarkTags(inMesg);
        runFilters(inMesg, initRunningFilterIndex(inMesg));
    }
}
Also used : TaskCloseable(io.perfmark.TaskCloseable)

Example 5 with TaskCloseable

use of io.perfmark.TaskCloseable in project zuul by Netflix.

the class ClientRequestReceiver method write.

@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
    try (TaskCloseable ignored = PerfMark.traceTask("CRR.write")) {
        if (msg instanceof HttpResponse) {
            promise.addListener((future) -> {
                if (!future.isSuccess()) {
                    fireWriteError("response headers", future.cause(), ctx);
                }
            });
            super.write(ctx, msg, promise);
        } else if (msg instanceof HttpContent) {
            promise.addListener((future) -> {
                if (!future.isSuccess()) {
                    fireWriteError("response content", future.cause(), ctx);
                }
            });
            super.write(ctx, msg, promise);
        } else {
            // should never happen
            ReferenceCountUtil.release(msg);
            throw new ZuulException("Attempt to write invalid content type to client: " + msg.getClass().getSimpleName(), true);
        }
    }
}
Also used : AttributeKey(io.netty.util.AttributeKey) SocketAddress(java.net.SocketAddress) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) LoggerFactory(org.slf4j.LoggerFactory) SslHandshakeInfo(com.netflix.netty.common.ssl.SslHandshakeInfo) Debug(com.netflix.zuul.context.Debug) CurrentPassport(com.netflix.zuul.passport.CurrentPassport) Matcher(java.util.regex.Matcher) ChannelPromise(io.netty.channel.ChannelPromise) Spectator(com.netflix.spectator.api.Spectator) Map(java.util.Map) TaskCloseable(io.perfmark.TaskCloseable) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) HttpRequest(io.netty.handler.codec.http.HttpRequest) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) InetSocketAddress(java.net.InetSocketAddress) PerfMark(io.perfmark.PerfMark) ZuulException(com.netflix.zuul.exception.ZuulException) List(java.util.List) HttpResponseMessage(com.netflix.zuul.message.http.HttpResponseMessage) PassportState(com.netflix.zuul.passport.PassportState) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) CommonContextKeys(com.netflix.zuul.context.CommonContextKeys) HttpResponse(io.netty.handler.codec.http.HttpResponse) SessionContextDecorator(com.netflix.zuul.context.SessionContextDecorator) Pattern(java.util.regex.Pattern) SslHandshakeInfoHandler(com.netflix.zuul.netty.server.ssl.SslHandshakeInfoHandler) ChannelUtils(com.netflix.zuul.netty.ChannelUtils) StatusCategoryUtils(com.netflix.zuul.stats.status.StatusCategoryUtils) RejectionUtils(com.netflix.netty.common.throttle.RejectionUtils) HttpVersion(io.netty.handler.codec.http.HttpVersion) Errors(io.netty.channel.unix.Errors) LastHttpContent(io.netty.handler.codec.http.LastHttpContent) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ZuulStatusCategory(com.netflix.zuul.stats.status.ZuulStatusCategory) ByteBuf(io.netty.buffer.ByteBuf) PROTOCOL_NAME(com.netflix.zuul.netty.server.http2.Http2OrHttpHandler.PROTOCOL_NAME) HttpQueryParams(com.netflix.zuul.message.http.HttpQueryParams) Headers(com.netflix.zuul.message.Headers) CompleteEvent(com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteEvent) SourceAddressChannelHandler(com.netflix.netty.common.SourceAddressChannelHandler) HttpContent(io.netty.handler.codec.http.HttpContent) Logger(org.slf4j.Logger) HttpUtils(com.netflix.zuul.util.HttpUtils) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) SessionContext(com.netflix.zuul.context.SessionContext) HttpRequestMessage(com.netflix.zuul.message.http.HttpRequestMessage) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) HAProxyMessage(io.netty.handler.codec.haproxy.HAProxyMessage) DefaultLastHttpContent(io.netty.handler.codec.http.DefaultLastHttpContent) CompleteReason(com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) SESSION_COMPLETE(com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason.SESSION_COMPLETE) HttpUtil(io.netty.handler.codec.http.HttpUtil) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) HttpResponse(io.netty.handler.codec.http.HttpResponse) ZuulException(com.netflix.zuul.exception.ZuulException) LastHttpContent(io.netty.handler.codec.http.LastHttpContent) HttpContent(io.netty.handler.codec.http.HttpContent) DefaultLastHttpContent(io.netty.handler.codec.http.DefaultLastHttpContent) TaskCloseable(io.perfmark.TaskCloseable)

Aggregations

TaskCloseable (io.perfmark.TaskCloseable)10 HttpRequestMessage (com.netflix.zuul.message.http.HttpRequestMessage)4 HttpResponseMessage (com.netflix.zuul.message.http.HttpResponseMessage)4 HttpContent (io.netty.handler.codec.http.HttpContent)3 ZuulException (com.netflix.zuul.exception.ZuulException)2 ProxyEndpoint (com.netflix.zuul.filters.endpoint.ProxyEndpoint)2 CurrentPassport (com.netflix.zuul.passport.CurrentPassport)2 ClientException (com.netflix.client.ClientException)1 CompleteEvent (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteEvent)1 CompleteReason (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason)1 SESSION_COMPLETE (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason.SESSION_COMPLETE)1 SourceAddressChannelHandler (com.netflix.netty.common.SourceAddressChannelHandler)1 SslHandshakeInfo (com.netflix.netty.common.ssl.SslHandshakeInfo)1 RejectionUtils (com.netflix.netty.common.throttle.RejectionUtils)1 Spectator (com.netflix.spectator.api.Spectator)1 ExecutionStatus (com.netflix.zuul.ExecutionStatus)1 CommonContextKeys (com.netflix.zuul.context.CommonContextKeys)1 Debug (com.netflix.zuul.context.Debug)1 SessionContext (com.netflix.zuul.context.SessionContext)1 SessionContextDecorator (com.netflix.zuul.context.SessionContextDecorator)1