java.lang.Object
org.odpi.openmetadata.frameworks.auditlog.requestid.ActiveRequests

public final class ActiveRequests extends Object
ActiveRequests tracks the REST requests that are being processed by the servers running in this JVM (platform).

A request from an external caller often fans out into further REST calls between the servers on the platform - for example, a view server calls the metadata access server on behalf of the same user. Egeria's REST clients pass the caller's request identifier on each of these calls, so a request that arrives carrying the identifier of a request that is still being processed on this platform is a nested call made on behalf of that original (root) request, rather than a new request from an external caller.

This lets the activity reporting (the METADATA-OBSERVABILITY audit log messages) record each external request once, and each anchor element it touches once, rather than once per internal hop. A request identifier is only treated as nested while the root request is in flight, so a client thread that reuses the same request identifier for a sequence of separate calls is still seen as making separate requests.

Calls between servers on different platforms cannot be detected and are reported as new requests.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    beginRequest(String requestId)
    Record that the current thread has started processing a REST request.
    static void
    Record that the current thread has finished processing its most recent REST request.
    static boolean
    isFirstReport(String activityKey)
    Record that an activity has been reported for the root request that the current thread is working on, and return whether this is the first time it has been reported.
    static boolean
    Is the current thread processing a nested call made on behalf of a request that was already being processed on this platform? It returns false when no request is being tracked for the thread.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • beginRequest

      public static void beginRequest(String requestId)
      Record that the current thread has started processing a REST request. Each call must be matched by a call to endRequest() once the request is complete.
      Parameters:
      requestId - identifier of the request (null is ignored)
    • endRequest

      public static void endRequest()
      Record that the current thread has finished processing its most recent REST request.
    • isNestedRequest

      public static boolean isNestedRequest()
      Is the current thread processing a nested call made on behalf of a request that was already being processed on this platform? It returns false when no request is being tracked for the thread.
      Returns:
      boolean
    • isFirstReport

      public static boolean isFirstReport(String activityKey)
      Record that an activity has been reported for the root request that the current thread is working on, and return whether this is the first time it has been reported. When no request is being tracked for the thread, every report is treated as the first.
      Parameters:
      activityKey - key identifying the activity - for example the anchor element's unique identifier and the kind of activity
      Returns:
      true if the activity has not been reported before for this request