From 7bf2a809e9ea60c38a22662a9617dcc4721f67c2 Mon Sep 17 00:00:00 2001
From: Eric Zhao
* Note that 'origin' usually is Service Consumer's app name.
*
- * the longer the application runs, the more stable this mapping will + * The longer the application runs, the more stable this mapping will * become. so we don't concurrent map but a lock. as this lock only happens - * at the very beginning while concurrent map will hold the lock all the - * time - *
+ * at the very beginning while concurrent map will hold the lock all the time. */ - private HashMapGet {@link Node} of the specific origin. Usually the origin is the Service Consumer's app name.
+ *If the origin node for given origin is absent, then a new {@link StatisticNode} + * for the origin will be created and returned.
* - * @param origin The caller's name. It is declared in the + * @param origin The caller's name, which is designated in the {@code parameter} parameter * {@link ContextUtil#enter(String name, String origin)}. - * @return the {@link Node} of the specific origin. + * @return the {@link Node} of the specific origin */ - public Node getOriginNode(String origin) { + public Node getOrCreateOriginNode(String origin) { StatisticNode statisticNode = originCountMap.get(origin); if (statisticNode == null) { try { lock.lock(); statisticNode = originCountMap.get(origin); if (statisticNode == null) { + // The node is absent, create a new node for the origin. statisticNode = new StatisticNode(); HashMap* Remember that same resource({@link ResourceWrapper#equals(Object)}) will share * the same {@link ProcessorSlotChain} globally, no matter in witch context. So if - * code goes into {@link #entry(Context, ResourceWrapper, DefaultNode, int, Object...)}, + * code goes into {@link #entry(Context, ResourceWrapper, DefaultNode, int, boolean, Object...)}, * the resource name must be same but context name may not. *
*
@@ -62,8 +62,7 @@ public class ClusterBuilderSlot extends AbstractLinkedProcessorSlot
* The longer the application runs, the more stable this mapping will
* become. so we don't concurrent map but a lock. as this lock only happens
- * at the very beginning while concurrent map will hold the lock all the
- * time
+ * at the very beginning while concurrent map will hold the lock all the time.
*