Package org.apache.flink.util
Class MdcUtils
- java.lang.Object
-
- org.apache.flink.util.MdcUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MdcUtils.MdcCloseable
AutoCloseable
that restores theMDC
contents on close.
-
Constructor Summary
Constructors Constructor Description MdcUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,String>
asContextData(JobID jobID)
static Executor
scopeToJob(JobID jobID, Executor executor)
static ExecutorService
scopeToJob(JobID jobID, ExecutorService delegate)
Wrap the givenExecutorService
so that the givenJobID
is added before it executes any submitted commands and removed afterward.static ScheduledExecutorService
scopeToJob(JobID jobID, ScheduledExecutorService ses)
Wrap the givenScheduledExecutorService
so that the givenJobID
is added before it executes any submitted commands and removed afterward.static MdcUtils.MdcCloseable
withContext(Map<String,String> context)
Replace MDC contents with the provided one and return a closeable object that can be used to restore the original MDC.static <T> Callable<T>
wrapCallable(Map<String,String> contextData, Callable<T> command)
Wrap the givenCallable
so that the given data is added toMDC
before its execution and removed afterward.static Runnable
wrapRunnable(Map<String,String> contextData, Runnable command)
Wrap the givenRunnable
so that the given data is added toMDC
before its execution and removed afterward.
-
-
-
Field Detail
-
JOB_ID
public static final String JOB_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
withContext
public static MdcUtils.MdcCloseable withContext(Map<String,String> context)
Replace MDC contents with the provided one and return a closeable object that can be used to restore the original MDC.- Parameters:
context
- to put into MDC
-
wrapRunnable
public static Runnable wrapRunnable(Map<String,String> contextData, Runnable command)
Wrap the givenRunnable
so that the given data is added toMDC
before its execution and removed afterward.
-
wrapCallable
public static <T> Callable<T> wrapCallable(Map<String,String> contextData, Callable<T> command)
Wrap the givenCallable
so that the given data is added toMDC
before its execution and removed afterward.
-
scopeToJob
public static ExecutorService scopeToJob(JobID jobID, ExecutorService delegate)
Wrap the givenExecutorService
so that the givenJobID
is added before it executes any submitted commands and removed afterward.
-
scopeToJob
public static ScheduledExecutorService scopeToJob(JobID jobID, ScheduledExecutorService ses)
Wrap the givenScheduledExecutorService
so that the givenJobID
is added before it executes any submitted commands and removed afterward.
-
-