@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, wait
accumulate, accumulateComponent, addToRootParent, combine, detachedChild, detachedChild, getBackendMinLogLevel, getContextMinLogLevel, getDebugDetail, getDebugDetail, getDebugDetail, getMillisToDeadline, getNotClosedParent, getRoot, getRootParent, getSecondsToDeadline, getTimeRelativeToDeadline, getTimeToDeadline, getUncheckedTimeToDeadline, putToRootParent, setBackendMinLogLevel, startChild, startChild
writeJsonTo, writeTo
public BasicExecutionContext(String name, @Nullable CharSequence id, @Nullable ExecutionContext source, ExecutionContext.Relation relation, long startTimeNanos, long deadlineNanos)
public final String getName()
getName
in interface ExecutionContext
public final long getDeadlineNanos()
getDeadlineNanos
in interface ExecutionContext
public final long getStartTimeNanos()
getStartTimeNanos
in interface ExecutionContext
@Nullable @Beta public final <T> T put(@Nonnull ExecutionContext.Tag<T,?> key, @Nonnull T data)
ExecutionContext
put
in interface ExecutionContext
T
- type of data.data
- the data.@Nullable @Beta public final <T> T get(@Nonnull ExecutionContext.Tag<T,?> key)
ExecutionContext
get
in interface ExecutionContext
T
- type of data.key
- key of data.public final <T> ContextValue<T> getContextAndValue(ExecutionContext.Tag<T,?> key)
ExecutionContext
getContextAndValue
in interface ExecutionContext
T
- type of data.key
- key of data.@Nullable @Beta public final <T> T getLocal(@Nonnull ExecutionContext.Tag<T,?> key)
ExecutionContext
getLocal
in interface ExecutionContext
T
- 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)
ExecutionContext
compute
in interface ExecutionContext
public final ExecutionContext getSource()
getSource
in interface ExecutionContext
public void close()
close
in interface AutoCloseable
close
in interface ExecutionContext
public final void detach()
ExecutionContext
detach
in interface ExecutionContext
public final boolean isAttached()
isAttached
in interface ExecutionContext
public final void attach()
ExecutionContext
attach
in interface ExecutionContext
public String toString()
public void writeJsonTo(Appendable appendable) throws IOException
writeJsonTo
in interface JsonWriteable
appendable
- IOException
public final void addLog(Slf4jLogRecord log)
addLog
in interface ExecutionContext
@Beta public final void addCloseable(AutoCloseable closeable)
ExecutionContext
addCloseable
in interface ExecutionContext
public final void addLogs(Collection<Slf4jLogRecord> pLogs)
addLogs
in interface ExecutionContext
public final void streamLogs(Consumer<Slf4jLogRecord> to)
streamLogs
in interface ExecutionContext
public final void streamLogs(Consumer<Slf4jLogRecord> to, int maxNr)
streamLogs
in interface ExecutionContext
public Level getContextMinLogLevel(String loggerName)
getContextMinLogLevel
in interface ExecutionContext
loggerName
- public Level getBackendMinLogLevel(String loggerName)
getBackendMinLogLevel
in interface ExecutionContext
loggerName
- public Level setBackendMinLogLevel(String loggerName, Level level)
setBackendMinLogLevel
in interface ExecutionContext
loggerName
- public final CharSequence getId()
getId
in interface ExecutionContext
public final long nextChildId()
nextChildId
in interface ExecutionContext
public void add(StackTraceElement[] sample)
add
in interface ExecutionContext
sample
- @Nullable public StackSamples getAndClearStackSamples()
getAndClearStackSamples
in interface ExecutionContext
@Nullable public StackSamples getStackSamples()
getStackSamples
in interface ExecutionContext
public final boolean isClosed()
isClosed
in interface ExecutionContext
public final ExecutionContext.Relation getRelationToSource()
getRelationToSource
in interface ExecutionContext
public void add(StackSamples samples)
add
in interface ExecutionContext
samples
- Copyright © 2021 SPF4J. All rights reserved.