Пример #1
0
  public static CallContext unregister() {
    CallContext context = s_currentContext.get();
    if (context == null) {
      return null;
    }
    s_currentContext.remove();
    if (s_logger.isTraceEnabled()) {
      s_logger.trace("Unregistered: " + context);
    }
    String contextId = context.getContextId();
    String sessionIdOnStack = null;
    String sessionIdPushedToNDC = "ctx-" + UuidUtils.first(contextId);
    while ((sessionIdOnStack = NDC.pop()) != null) {
      if (sessionIdPushedToNDC.equals(sessionIdOnStack)) {
        break;
      }
      if (s_logger.isTraceEnabled()) {
        s_logger.trace("Popping from NDC: " + contextId);
      }
    }

    Stack<CallContext> stack = s_currentContextStack.get();
    stack.pop();

    if (!stack.isEmpty()) {
      s_currentContext.set(stack.peek());
    }

    return context;
  }
Пример #2
0
 public static CallContext registerSystemCallContextOnceOnly() {
   try {
     CallContext context = s_currentContext.get();
     if (context == null) {
       return register(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM);
     }
     assert context.getCallingUserId() == User.UID_SYSTEM
         : "You are calling a very specific method that registers a one time system context.  This method is meant for background threads that does processing.";
     return context;
   } catch (Exception e) {
     s_logger.fatal(
         "Exiting the system because we're unable to register the system call context.", e);
     System.exit(1);
     throw new CloudRuntimeException("Should never hit this");
   }
 }
Пример #3
0
 public static CallContext current() {
   return s_currentContext.get();
 }