Java Code Examples for com.netflix.zuul.context.RequestContext#remove()

The following examples show how to use com.netflix.zuul.context.RequestContext#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SentinelEntryUtils.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
static void tryExitFromCurrentContext() {
    RequestContext ctx = RequestContext.getCurrentContext();
    if (ctx.containsKey(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY)) {
        Deque<AsyncEntry> asyncEntries = (Deque<AsyncEntry>) ctx.get(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
        AsyncEntry entry;
        while (!asyncEntries.isEmpty()) {
            entry = asyncEntries.pop();
            entry.exit();
        }
        ctx.remove(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
    }

    ContextUtil.exit();
}
 
Example 2
Source File: SentinelEntryUtils.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
static void tryTraceExceptionThenExitFromCurrentContext(Throwable t) {
    RequestContext ctx = RequestContext.getCurrentContext();
    if (ctx.containsKey(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY)) {
        Deque<AsyncEntry> asyncEntries = (Deque<AsyncEntry>) ctx.get(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
        AsyncEntry entry;
        while (!asyncEntries.isEmpty()) {
            entry = asyncEntries.pop();
            Tracer.traceEntry(t, entry);
            entry.exit();
        }
        ctx.remove(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
    }
    ContextUtil.exit();
}
 
Example 3
Source File: TracePostZuulFilter.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
@Override
public Object run() {
  final RequestContext context = RequestContext.getCurrentContext();
  final Object spanObject = context.get(TracePreZuulFilter.CONTEXT_SPAN_KEY);
  if (spanObject instanceof Span) {
    final Span span = (Span)spanObject;
    span.setTag(Tags.HTTP_STATUS.getKey(), context.getResponseStatusCode());
    if (context.getThrowable() != null) {
      onError(context.getThrowable(), span);
    }
    else {
      final Object error = context.get("error.exception");
      if (error instanceof Exception)
        onError((Exception)error, span);
    }

    if (context.getRouteHost() != null)
      span.setTag(ROUTE_HOST_TAG, context.getRouteHost().toString());

    final Object scopeObject = context.get(TracePreZuulFilter.CONTEXT_SCOPE_KEY);
    if (scopeObject instanceof Scope)
      ((Scope)scopeObject).close();

    span.finish();
    context.remove(TracePreZuulFilter.CONTEXT_SPAN_KEY);
  }

  return null;
}
 
Example 4
Source File: SentinelEntryUtils.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
static void tryExitFromCurrentContext() {
    RequestContext ctx = RequestContext.getCurrentContext();
    if (ctx.containsKey(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY)) {
        Deque<EntryHolder> holders = (Deque<EntryHolder>) ctx.get(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
        EntryHolder holder;
        while (!holders.isEmpty()) {
            holder = holders.pop();
            exit(holder);
        }
        ctx.remove(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
    }

    ContextUtil.exit();
}
 
Example 5
Source File: SentinelEntryUtils.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
static void tryTraceExceptionThenExitFromCurrentContext(Throwable t) {
    RequestContext ctx = RequestContext.getCurrentContext();
    if (ctx.containsKey(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY)) {
        Deque<EntryHolder> holders = (Deque<EntryHolder>) ctx.get(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
        EntryHolder holder;
        while (!holders.isEmpty()) {
            holder = holders.pop();
            Tracer.traceEntry(t, holder.getEntry());
            exit(holder);
        }
        ctx.remove(ZuulConstant.ZUUL_CTX_SENTINEL_ENTRIES_KEY);
    }
    ContextUtil.exit();
}