Class KeyPartitionProfilerManager

java.lang.Object
com.linkedin.venice.listener.profiler.KeyPartitionProfilerManager

public final class KeyPartitionProfilerManager extends Object
Tracks active KeyPartitionProfiler sessions and exposes a near-zero-cost guard for the read hot path.

When a session's window expires, the result is emitted to the server log, The session is then removed and the fast-path boolean is cleared once the last session is gone.

  • Field Details

    • DEFAULT_MAX_CONCURRENT_SESSIONS

      public static final int DEFAULT_MAX_CONCURRENT_SESSIONS
      See Also:
    • DEFAULT_TOP_K

      public static final int DEFAULT_TOP_K
      See Also:
    • MAX_DURATION_MS

      public static final long MAX_DURATION_MS
      Upper bound on a single session's profiling window. Prevents accidental long-running sessions.
    • MAX_TOP_K

      public static final int MAX_TOP_K
      Upper bound on per-partition top-K size. Bounds per-session memory growth.
      See Also:
    • LOG_PREFIX

      public static final String LOG_PREFIX
      See Also:
  • Constructor Details

    • KeyPartitionProfilerManager

      public KeyPartitionProfilerManager(ToIntFunction<String> partitionCountResolver, int maxConcurrentSessions, LogContext logContext)
  • Method Details

    • isAnyProfilingActive

      public boolean isAnyProfilingActive()
      Hot-path entry point. Returns true when at least one profiling session is currently running and the read path should record key/partition activity.
    • getProfiler

      public KeyPartitionProfiler getProfiler(String storeName)
      Returns the active profiler for storeName or null if no session is running for that store. Should only be called when isAnyProfilingActive() returned true.
    • startProfiling

      public KeyPartitionProfilerManager.StartResult startProfiling(String storeName, String storeVersion, long durationMs, int topK)
      Starts a profiling session for storeName. Returns a description of the action taken (always-on capability; no config flag).
    • stopProfiling

      public Optional<KeyPartitionProfiler> stopProfiling(String storeName)
      Stops the profiling session for storeName early and emits its result. Returns the stopped KeyPartitionProfiler (carrying the actual storeVersion of the session) so callers can build accurate audit messages, or Optional.empty() if no session was running for the store.
    • shutdown

      public void shutdown()