Package org.apache.bookkeeper.stats
Class ThreadRegistry
- java.lang.Object
-
- org.apache.bookkeeper.stats.ThreadRegistry
-
public class ThreadRegistry extends java.lang.Object
For mapping thread ids to thread pools and threads within those pools or just for lone named threads. Thread scoped metrics add labels to metrics by retrieving the ThreadPoolThread object from this registry. For flexibility, this registry is not based on TLS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThreadRegistry.ThreadPoolThread
Stores the thread pool and ordinal.
-
Constructor Summary
Constructors Constructor Description ThreadRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clear()
static void
forceClearRegistrationForTests(long threadId)
In some tests we run in the same thread activities that should run in different threads from different thread-pools this would trigger assertions to fail.static ThreadRegistry.ThreadPoolThread
get()
static void
register(java.lang.String threadPool)
static void
register(java.lang.String threadPool, boolean force)
static void
register(java.lang.String threadPool, int threadPoolThread)
static void
register(java.lang.String threadPool, int threadPoolThread, long threadId)
static java.lang.Runnable
registerThread(java.lang.Runnable runnable, java.lang.String threadPool)
-
-
-
Method Detail
-
register
public static void register(java.lang.String threadPool)
-
register
public static void register(java.lang.String threadPool, boolean force)
-
forceClearRegistrationForTests
public static void forceClearRegistrationForTests(long threadId)
In some tests we run in the same thread activities that should run in different threads from different thread-pools this would trigger assertions to fail. This is a convenience method to work around such cases. This method shouldn't be used in production code.
-
register
public static void register(java.lang.String threadPool, int threadPoolThread)
-
register
public static void register(java.lang.String threadPool, int threadPoolThread, long threadId)
-
registerThread
public static java.lang.Runnable registerThread(java.lang.Runnable runnable, java.lang.String threadPool)
-
clear
public static void clear()
-
get
public static ThreadRegistry.ThreadPoolThread get()
-
-