gpt4 book ai didi

com.netflix.zuul.netty.filter.ZuulFilterChainRunner类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 21:37:31 25 4
gpt4 key购买 nike

本文整理了Java中com.netflix.zuul.netty.filter.ZuulFilterChainRunner类的一些代码示例,展示了ZuulFilterChainRunner类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZuulFilterChainRunner类的具体详情如下:
包路径:com.netflix.zuul.netty.filter.ZuulFilterChainRunner
类名称:ZuulFilterChainRunner

ZuulFilterChainRunner介绍

[英]This class is supposed to be thread safe and hence should not have any non final member variables Created by saroskar on 5/17/17.
[中]这个类应该是线程安全的,因此不应该有saroskar在2017年5月17日创建的任何非最终成员变量。

代码示例

代码示例来源:origin: Netflix/zuul

protected <T extends ZuulMessage, R extends ZuulMessage> ZuulFilterChainRunner<T> getFilterChainRunner(ZuulFilter<T, T>[] filters,
                                        FilterUsageNotifier filterUsageNotifier,
                                        FilterRunner<T, R> filterRunner) {
  return new ZuulFilterChainRunner<>(filters, filterUsageNotifier, filterRunner);
}

代码示例来源:origin: Netflix/zuul

private final void runFilters(final T mesg, final AtomicInteger runningFilterIdx) {
  T inMesg = mesg;
  String filterName = "-";
  try {
    Preconditions.checkNotNull(mesg, "Input message");
    int i = runningFilterIdx.get();
    while (i < filters.length) {
      final ZuulFilter<T, T> filter = filters[i];
      filterName = filter.filterName();
      final T outMesg = filter(filter, inMesg);
      if (outMesg == null) {
        return; //either async filter or waiting for the message body to be buffered
      }
      inMesg = outMesg;
      i = runningFilterIdx.incrementAndGet();
    }
    //Filter chain has reached its end, pass result to the next stage
    invokeNextStage(inMesg);
  }
  catch (Exception ex) {
    handleException(inMesg, filterName, ex);
  }
}

代码示例来源:origin: Netflix/zuul

@Override
protected void resume(final T inMesg) {
  final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
  runningFilterIdx.incrementAndGet();
  runFilters(inMesg, runningFilterIdx);
}

代码示例来源:origin: Netflix/zuul

@Override
public void filter(final T inMesg) {
  runFilters(inMesg, initRunningFilterIndex(inMesg));
}

代码示例来源:origin: Netflix/zuul

Preconditions.checkNotNull(inMesg, "input message");
final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
final int limit = runningFilterIdx.get();
for (int i = 0; i < limit; i++) {
  final ZuulFilter<T, T> filter = filters[i];
  filterName = filter.filterName();
  if ((! filter.isDisabled()) && (! shouldSkipFilter(inMesg, filter))) {
    final HttpContent newChunk = filter.processContentChunk(inMesg, chunk);
    if (newChunk == null)  {
  invokeNextStage(inMesg, chunk);
} else {
  inMesg.bufferBodyContents(chunk);
  boolean isAwaitingBody = isFilterAwaitingBody(inMesg);
    runFilters(inMesg, runningFilterIdx);
handleException(inMesg, filterName, ex);

代码示例来源:origin: Netflix/zuul

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  if (msg instanceof HttpRequestMessage) {
    zuulRequest = (HttpRequestMessage)msg;
    //Replace NETTY_SERVER_CHANNEL_HANDLER_CONTEXT in SessionContext
    final SessionContext zuulCtx = zuulRequest.getContext();
    zuulCtx.put(NETTY_SERVER_CHANNEL_HANDLER_CONTEXT, ctx);
    zuulCtx.put(ZUUL_FILTER_CHAIN, requestFilterChain);
    requestFilterChain.filter(zuulRequest);
  }
  else if ((msg instanceof HttpContent)&&(zuulRequest != null)) {
    requestFilterChain.filter(zuulRequest, (HttpContent) msg);
  }
  else {
    LOG.debug("Received unrecognized message type. " + msg.getClass().getName());
    ReferenceCountUtil.release(msg);
  }
}

代码示例来源:origin: Netflix/zuul

Preconditions.checkNotNull(inMesg, "input message");
final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
final int limit = runningFilterIdx.get();
for (int i = 0; i < limit; i++) {
  final ZuulFilter<T, T> filter = filters[i];
  filterName = filter.filterName();
  if ((! filter.isDisabled()) && (! shouldSkipFilter(inMesg, filter))) {
    final HttpContent newChunk = filter.processContentChunk(inMesg, chunk);
    if (newChunk == null)  {
  invokeNextStage(inMesg, chunk);
} else {
  inMesg.bufferBodyContents(chunk);
  boolean isAwaitingBody = isFilterAwaitingBody(inMesg);
    runFilters(inMesg, runningFilterIdx);
handleException(inMesg, filterName, ex);

代码示例来源:origin: Netflix/zuul

@Override
public void filter(final T inMesg) {
  runFilters(inMesg, initRunningFilterIndex(inMesg));
}

代码示例来源:origin: Netflix/zuul

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  if (msg instanceof HttpRequestMessage) {
    zuulRequest = (HttpRequestMessage)msg;
    //Replace NETTY_SERVER_CHANNEL_HANDLER_CONTEXT in SessionContext
    final SessionContext zuulCtx = zuulRequest.getContext();
    zuulCtx.put(NETTY_SERVER_CHANNEL_HANDLER_CONTEXT, ctx);
    zuulCtx.put(ZUUL_FILTER_CHAIN, requestFilterChain);
    requestFilterChain.filter(zuulRequest);
  }
  else if ((msg instanceof HttpContent)&&(zuulRequest != null)) {
    requestFilterChain.filter(zuulRequest, (HttpContent) msg);
  }
  else {
    LOG.debug("Received unrecognized message type. " + msg.getClass().getName());
    ReferenceCountUtil.release(msg);
  }
}

代码示例来源:origin: com.netflix.zuul/zuul-core

Preconditions.checkNotNull(inMesg, "input message");
final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
final int limit = runningFilterIdx.get();
for (int i = 0; i < limit; i++) {
  final ZuulFilter<T, T> filter = filters[i];
  filterName = filter.filterName();
  if ((! filter.isDisabled()) && (! shouldSkipFilter(inMesg, filter))) {
    final HttpContent newChunk = filter.processContentChunk(inMesg, chunk);
    if (newChunk == null)  {
  invokeNextStage(inMesg, chunk);
} else {
  inMesg.bufferBodyContents(chunk);
  boolean isAwaitingBody = isFilterAwaitingBody(inMesg);
    runFilters(inMesg, runningFilterIdx);
handleException(inMesg, filterName, ex);

代码示例来源:origin: Netflix/zuul

private final void runFilters(final T mesg, final AtomicInteger runningFilterIdx) {
  T inMesg = mesg;
  String filterName = "-";
  try {
    Preconditions.checkNotNull(mesg, "Input message");
    int i = runningFilterIdx.get();
    while (i < filters.length) {
      final ZuulFilter<T, T> filter = filters[i];
      filterName = filter.filterName();
      final T outMesg = filter(filter, inMesg);
      if (outMesg == null) {
        return; //either async filter or waiting for the message body to be buffered
      }
      inMesg = outMesg;
      i = runningFilterIdx.incrementAndGet();
    }
    //Filter chain has reached its end, pass result to the next stage
    invokeNextStage(inMesg);
  }
  catch (Exception ex) {
    handleException(inMesg, filterName, ex);
  }
}

代码示例来源:origin: Netflix/zuul

@Override
protected void resume(final T inMesg) {
  final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
  runningFilterIdx.incrementAndGet();
  runFilters(inMesg, runningFilterIdx);
}

代码示例来源:origin: com.netflix.zuul/zuul-core

@Override
public void filter(final T inMesg) {
  runFilters(inMesg, initRunningFilterIndex(inMesg));
}

代码示例来源:origin: Netflix/zuul

protected <T extends ZuulMessage> ZuulFilterChainRunner<T> getFilterChainRunner(ZuulFilter<T, T>[] filters,
                                        FilterUsageNotifier filterUsageNotifier) {
  return new ZuulFilterChainRunner<>(filters, filterUsageNotifier);
}

代码示例来源:origin: Netflix/zuul

private void sendResponse(final StatusCategory statusCategory, final int status, ChannelHandlerContext ctx) {
  if (zuulRequest == null) {
    ctx.close();
  }
  else {
    final SessionContext zuulCtx = zuulRequest.getContext();
    StatusCategoryUtils.storeStatusCategoryIfNotAlreadyFailure(zuulCtx, statusCategory);
    final HttpResponseMessage zuulResponse = new HttpResponseMessageImpl(zuulCtx, zuulRequest, status);
    final Headers headers = zuulResponse.getHeaders();
    headers.add("Connection", "close");
    headers.add("Content-Length", "0");
    zuulResponse.finishBufferedBodyIfIncomplete();
    responseFilterChain.filter(zuulResponse);
    fireEndpointFinish(true);
  }
}

代码示例来源:origin: com.netflix.zuul/zuul-core

private final void runFilters(final T mesg, final AtomicInteger runningFilterIdx) {
  T inMesg = mesg;
  String filterName = "-";
  try {
    Preconditions.checkNotNull(mesg, "Input message");
    int i = runningFilterIdx.get();
    while (i < filters.length) {
      final ZuulFilter<T, T> filter = filters[i];
      filterName = filter.filterName();
      final T outMesg = filter(filter, inMesg);
      if (outMesg == null) {
        return; //either async filter or waiting for the message body to be buffered
      }
      inMesg = outMesg;
      i = runningFilterIdx.incrementAndGet();
    }
    //Filter chain has reached its end, pass result to the next stage
    invokeNextStage(inMesg);
  }
  catch (Exception ex) {
    handleException(inMesg, filterName, ex);
  }
}

代码示例来源:origin: com.netflix.zuul/zuul-core

@Override
protected void resume(final T inMesg) {
  final AtomicInteger runningFilterIdx = getRunningFilterIndex(inMesg);
  runningFilterIdx.incrementAndGet();
  runFilters(inMesg, runningFilterIdx);
}

代码示例来源:origin: Netflix/zuul

protected <T extends ZuulMessage, R extends ZuulMessage> ZuulFilterChainRunner<T> getFilterChainRunner(ZuulFilter<T, T>[] filters,
                                        FilterUsageNotifier filterUsageNotifier,
                                        FilterRunner<T, R> filterRunner) {
  return new ZuulFilterChainRunner<>(filters, filterUsageNotifier, filterRunner);
}

代码示例来源:origin: Netflix/zuul

private void sendResponse(final StatusCategory statusCategory, final int status, ChannelHandlerContext ctx) {
  if (zuulRequest == null) {
    ctx.close();
  }
  else {
    final SessionContext zuulCtx = zuulRequest.getContext();
    StatusCategoryUtils.storeStatusCategoryIfNotAlreadyFailure(zuulCtx, statusCategory);
    final HttpResponseMessage zuulResponse = new HttpResponseMessageImpl(zuulCtx, zuulRequest, status);
    final Headers headers = zuulResponse.getHeaders();
    headers.add("Connection", "close");
    headers.add("Content-Length", "0");
    zuulResponse.finishBufferedBodyIfIncomplete();
    responseFilterChain.filter(zuulResponse);
    fireEndpointFinish(true);
  }
}

代码示例来源:origin: Netflix/zuul

protected <T extends ZuulMessage> ZuulFilterChainRunner<T> getFilterChainRunner(ZuulFilter<T, T>[] filters,
                                        FilterUsageNotifier filterUsageNotifier) {
  return new ZuulFilterChainRunner<>(filters, filterUsageNotifier);
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com