public class NodeSelectorSlot extends AbstractLinkedProcessorSlot<Object>
DefaultNode if needed as the last child in the context.
The context's last node is the current node or the parent node of the context. 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
EntranceNode,
ContextUtil| Constructor and Description |
|---|
NodeSelectorSlot() |
| Modifier and Type | Method and Description |
|---|---|
void |
entry(Context context,
ResourceWrapper resourceWrapper,
Object obj,
int count,
boolean prioritized,
Object... args)
Entrance of this slot.
|
void |
exit(Context context,
ResourceWrapper resourceWrapper,
int count,
Object... args)
Exit of this slot.
|
fireEntry, fireExit, getNext, setNextpublic void entry(Context context, ResourceWrapper resourceWrapper, Object obj, int count, boolean prioritized, Object... args) throws Throwable
ProcessorSlotpublic void exit(Context context, ResourceWrapper resourceWrapper, int count, Object... args)
ProcessorSlotcontext - current ContextresourceWrapper - current resourcecount - tokens neededargs - parameters of the original callCopyright © 2019 Alibaba Group. All rights reserved.