类 NodeSelectorSlot
- 所有已实现的接口:
ProcessorSlot<Object>
- adding a new
DefaultNodeif needed as the last child in the context. The context's last node is the current node or the parent node of the context. - setting itself to the context current node.
It works as follow:
ContextUtil.enter("entrance1", "appA");
Entry nodeA = SphU.entry("nodeA");
if (nodeA != null) {
nodeA.exit();
}
ContextUtil.exit();
Above code will generate the following invocation structure in memory:
machine-root
/
/
EntranceNode1
/
/
DefaultNode(nodeA)- - - - - -> ClusterNode(nodeA);
Here the EntranceNode represents "entrance1" given by
ContextUtil.enter("entrance1", "appA").
Both DefaultNode(nodeA) and ClusterNode(nodeA) holds statistics of "nodeA", which is given
by SphU.entry("nodeA")
The ClusterNode is uniquely identified by the ResourceId; the DefaultNode
is identified by both the resource id and Context. In other words, one resource
id will generate multiple DefaultNode for each distinct context, but only one
ClusterNode.
the following code shows one resource id in two different context:
ContextUtil.enter("entrance1", "appA");
Entry nodeA = SphU.entry("nodeA");
if (nodeA != null) {
nodeA.exit();
}
ContextUtil.exit();
ContextUtil.enter("entrance2", "appA");
nodeA = SphU.entry("nodeA");
if (nodeA != null) {
nodeA.exit();
}
ContextUtil.exit();
Above code will generate the following invocation structure in memory:
machine-root
/ \
/ \
EntranceNode1 EntranceNode2
/ \
/ \
DefaultNode(nodeA) DefaultNode(nodeA)
| |
+- - - - - - - - - - +- - - - - - -> ClusterNode(nodeA);
As we can see, two DefaultNode are created for "nodeA" in two context, but only one
ClusterNode is created.
We can also check this structure by calling:
curl http://localhost:8719/tree?type=root
- 作者:
- jialiang.linjl
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidentry(Context context, ResourceWrapper resourceWrapper, Object obj, int count, boolean prioritized, Object... args) Entrance of this slot.voidexit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) Exit of this slot.从类继承的方法 com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot
fireEntry, fireExit, getNext, setNext
-
构造器详细资料
-
NodeSelectorSlot
public NodeSelectorSlot()
-
-
方法详细资料
-
entry
public void entry(Context context, ResourceWrapper resourceWrapper, Object obj, int count, boolean prioritized, Object... args) throws Throwable 从接口复制的说明:ProcessorSlotEntrance of this slot. -
exit
从接口复制的说明:ProcessorSlotExit of this slot.- 参数:
context- currentContextresourceWrapper- current resourcecount- tokens neededargs- parameters of the original call
-