sentinel学习(3)——源码阅读----NodeSelectorSlot.entry()(完)

1:这个slot的作用是什么?

个人觉得 这个 NodeSelectorSlot 是用来后续扩展的: 如果是分布式的时候, 可以选择不同的节点,来处理。(纯猜测!)

public void entry(Context context, ResourceWrapper resourceWrapper, Object obj, int count, boolean prioritized, Object... args)
        throws Throwable {
        //这个map一开始是没值的。是属于NodeSelectorSlot 中的属性,与 ContextUtil中的 contextNameNodeMap属性 不一样。
        DefaultNode node = map.get(context.getName());
        if (node == null) {
            synchronized (this) {
                node = map.get(context.getName());
                if (node == null) {
                    //创建一个默认的节点。
                    node = new DefaultNode(resourceWrapper, null);
                    HashMap<String, DefaultNode> cacheMap = new HashMap<String, DefaultNode>(map.size());
                    cacheMap.putAll(map);
                    cacheMap.put(context.getName(), node);
                    map = cacheMap;
                    // Build invocation tree 
                    //添加到最后一个节点中
                    ((DefaultNode) context.getLastNode()).addChild(node);
                }

            }
        }
		//设置到上下文中
        context.setCurNode(node);
        //进入下一个Slot
        fireEntry(context, resourceWrapper, node, count, prioritized, args);
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值