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 interfaceMdcUtils.MdcCloseableAutoCloseablethat restores theMDCcontents 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 ExecutorscopeToJob(JobID jobID, Executor executor)static ExecutorServicescopeToJob(JobID jobID, ExecutorService delegate)Wrap the givenExecutorServiceso that the givenJobIDis added before it executes any submitted commands and removed afterward.static ScheduledExecutorServicescopeToJob(JobID jobID, ScheduledExecutorService ses)Wrap the givenScheduledExecutorServiceso that the givenJobIDis added before it executes any submitted commands and removed afterward.static MdcUtils.MdcCloseablewithContext(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 givenCallableso that the given data is added toMDCbefore its execution and removed afterward.static RunnablewrapRunnable(Map<String,String> contextData, Runnable command)Wrap the givenRunnableso that the given data is added toMDCbefore 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 givenRunnableso that the given data is added toMDCbefore its execution and removed afterward.
-
wrapCallable
public static <T> Callable<T> wrapCallable(Map<String,String> contextData, Callable<T> command)
Wrap the givenCallableso that the given data is added toMDCbefore its execution and removed afterward.
-
scopeToJob
public static ExecutorService scopeToJob(JobID jobID, ExecutorService delegate)
Wrap the givenExecutorServiceso that the givenJobIDis added before it executes any submitted commands and removed afterward.
-
scopeToJob
public static ScheduledExecutorService scopeToJob(JobID jobID, ScheduledExecutorService ses)
Wrap the givenScheduledExecutorServiceso that the givenJobIDis added before it executes any submitted commands and removed afterward.
-
-