@ThreadSafe @ParametersAreNonnullByDefault public class BasicExecutionContext extends Object implements ExecutionContext
ExecutionContext.Relation, ExecutionContext.SimpleTag<T>, ExecutionContext.Tag<T,A>| Constructor and Description |
|---|
BasicExecutionContext(String name,
CharSequence id,
ExecutionContext source,
ExecutionContext.Relation relation,
long startTimeNanos,
long deadlineNanos) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(StackSamples samples)
add a bunch of samples to this context.
|
void |
add(StackTraceElement[] sample)
Add a sample to this execution context.
|
void |
addCloseable(AutoCloseable closeable)
Attach a AutoCloseable to execution context.
|
void |
addLog(Slf4jLogRecord log) |
void |
addLogs(Collection<Slf4jLogRecord> pLogs) |
void |
attach()
Attach execution context to the current thread.
|
void |
close()
Close might be overridable to close any additional stuff added in the extended class.
|
<V,A> V |
compute(ExecutionContext.Tag<V,A> key,
BiFunction<ExecutionContext.Tag<V,A>,V,V> compute)
Compute context associated data.
|
void |
detach()
Detach this execution context from the current Thread.
|
<T> T |
get(ExecutionContext.Tag<T,?> key)
Method to get context associated data.
|
StackSamples |
getAndClearStackSamples()
get the collected stack samples.
|
Level |
getBackendMinLogLevel(String loggerName)
Overwrite for more configurable implementation.
|
<T> ContextValue<T> |
getContextAndValue(ExecutionContext.Tag<T,?> key)
Method to get context associated data.
|
Level |
getContextMinLogLevel(String loggerName)
Overwrite for more configurable implementation.
|
long |
getDeadlineNanos() |
CharSequence |
getId() |
<T> T |
getLocal(ExecutionContext.Tag<T,?> key)
Method to get context associated data.
|
String |
getName() |
ExecutionContext.Relation |
getRelationToSource() |
ExecutionContext |
getSource() |
StackSamples |
getStackSamples()
overwrite in a context that supports this functionality.
|
long |
getStartTimeNanos() |
boolean |
isAttached() |
boolean |
isClosed() |
long |
nextChildId() |
<T> T |
put(ExecutionContext.Tag<T,?> key,
T data)
Method to put context associated data.
|
Level |
setBackendMinLogLevel(String loggerName,
Level level)
Overwrite for more configurable implementation.
|
void |
streamLogs(Consumer<Slf4jLogRecord> to) |
void |
streamLogs(Consumer<Slf4jLogRecord> to,
int maxNr) |
String |
toString()
Overwrite as needed for debug string.
|
void |
writeJsonTo(Appendable appendable)
Overwrite this method to change default json format.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaccumulate, accumulateComponent, addToRootParent, combine, detachedChild, detachedChild, getBackendMinLogLevel, getContextMinLogLevel, getDebugDetail, getDebugDetail, getDebugDetail, getMillisToDeadline, getNotClosedParent, getRoot, getRootParent, getSecondsToDeadline, getTimeRelativeToDeadline, getTimeToDeadline, getUncheckedTimeToDeadline, putToRootParent, setBackendMinLogLevel, startChild, startChildwriteJsonTo, writeTopublic BasicExecutionContext(String name, @Nullable CharSequence id, @Nullable ExecutionContext source, ExecutionContext.Relation relation, long startTimeNanos, long deadlineNanos)
public final String getName()
getName in interface ExecutionContextpublic final long getDeadlineNanos()
getDeadlineNanos in interface ExecutionContextpublic final long getStartTimeNanos()
getStartTimeNanos in interface ExecutionContext@Nullable @Beta public final <T> T put(@Nonnull ExecutionContext.Tag<T,?> key, @Nonnull T data)
ExecutionContextput in interface ExecutionContextT - type of data.data - the data.@Nullable @Beta public final <T> T get(@Nonnull ExecutionContext.Tag<T,?> key)
ExecutionContextget in interface ExecutionContextT - type of data.key - key of data.public final <T> ContextValue<T> getContextAndValue(ExecutionContext.Tag<T,?> key)
ExecutionContextgetContextAndValue in interface ExecutionContextT - type of data.key - key of data.@Nullable @Beta public final <T> T getLocal(@Nonnull ExecutionContext.Tag<T,?> key)
ExecutionContextgetLocal in interface ExecutionContextT - type of data.key - key of data.@Nullable public final <V,A> V compute(@Nonnull ExecutionContext.Tag<V,A> key, BiFunction<ExecutionContext.Tag<V,A>,V,V> compute)
ExecutionContextcompute in interface ExecutionContextpublic final ExecutionContext getSource()
getSource in interface ExecutionContextpublic void close()
close in interface AutoCloseableclose in interface ExecutionContextpublic final void detach()
ExecutionContextdetach in interface ExecutionContextpublic final boolean isAttached()
isAttached in interface ExecutionContextpublic final void attach()
ExecutionContextattach in interface ExecutionContextpublic String toString()
public void writeJsonTo(Appendable appendable) throws IOException
writeJsonTo in interface JsonWriteableappendable - IOExceptionpublic final void addLog(Slf4jLogRecord log)
addLog in interface ExecutionContext@Beta public final void addCloseable(AutoCloseable closeable)
ExecutionContextaddCloseable in interface ExecutionContextpublic final void addLogs(Collection<Slf4jLogRecord> pLogs)
addLogs in interface ExecutionContextpublic final void streamLogs(Consumer<Slf4jLogRecord> to)
streamLogs in interface ExecutionContextpublic final void streamLogs(Consumer<Slf4jLogRecord> to, int maxNr)
streamLogs in interface ExecutionContextpublic Level getContextMinLogLevel(String loggerName)
getContextMinLogLevel in interface ExecutionContextloggerName - public Level getBackendMinLogLevel(String loggerName)
getBackendMinLogLevel in interface ExecutionContextloggerName - public Level setBackendMinLogLevel(String loggerName, Level level)
setBackendMinLogLevel in interface ExecutionContextloggerName - public final CharSequence getId()
getId in interface ExecutionContextpublic final long nextChildId()
nextChildId in interface ExecutionContextpublic void add(StackTraceElement[] sample)
add in interface ExecutionContextsample - @Nullable public StackSamples getAndClearStackSamples()
getAndClearStackSamples in interface ExecutionContext@Nullable public StackSamples getStackSamples()
getStackSamples in interface ExecutionContextpublic final boolean isClosed()
isClosed in interface ExecutionContextpublic final ExecutionContext.Relation getRelationToSource()
getRelationToSource in interface ExecutionContextpublic void add(StackSamples samples)
add in interface ExecutionContextsamples - Copyright © 2021 SPF4J. All rights reserved.