| Constructor and Description |
|---|
ContextUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Context |
enter(String name)
Enter the invocation context.
|
static Context |
enter(String name,
String origin)
Enter the invocation context.
|
static void |
exit()
Exit context of current thread, that is removing
Context in the
ThreadLocal. |
static Context |
getContext()
Get
Context of current thread. |
protected static Context |
trueEnter(String name,
String origin) |
public static Context enter(String name, String origin)
Enter the invocation context. The context is ThreadLocal, meaning that
each thread has it's own Context. New context will be created if
current thread doesn't have one.
A context will be related to a EntranceNode, which represents the entrance
of the invocation tree. New EntranceNode will be created if
current context does't have one. Note that same context name will share
same EntranceNode globally.
Note that each distinct origin of name will lead to creating a new
Node, meaning that total Node created will be of:
distinct context name count * distinct origin count
So when origin is too many, memory efficiency should be carefully considered.
Same resource in different context will count separately, see NodeSelectorSlot.
name - the context name.origin - the origin of this invocation, usually the origin could be the Service
Consumer's app name. The origin is useful when we want to control different
invoker/consumer separately.public static Context enter(String name)
Enter the invocation context. The context is ThreadLocal, meaning that
each thread has it's own Context. New context will be created if
current thread doesn't have one.
A context will related to A EntranceNode, which is the entrance
of the invocation tree. New EntranceNode will be created if
current context does't have one. Note that same resource name will share
same EntranceNode globally.
Same resource in different context will count separately, see NodeSelectorSlot.
name - the context name.public static void exit()
Context in the
ThreadLocal.Copyright © 2018 Alibaba Group. All rights reserved.