Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多线程情况下,如果使用默认contextName的context访问同一个resource时,使用的是同一个DefaultNode #9

Open
XiongMMaq opened this issue Mar 25, 2021 · 0 comments

Comments

@XiongMMaq
Copy link

image
图片中,这句话是不是描述的由问题?

没有认为设置contextName时,使用呢默认的:Constants.CONTEXT_DEFAULT_NAME(sentinel_default_context)
if (context == null) { // Using default context. context = InternalContextUtil.internalEnter(Constants.CONTEXT_DEFAULT_NAME); }

如下图在NodeSelectorSlot中,通过context.getName()获取DefaultNode
` 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);
    fireEntry(context, resourceWrapper, node, count, prioritized, args);`
@XiongMMaq XiongMMaq changed the title 多线程情况下,如果使用默认的context访问同一个resource时,使用的是同一个DefaultNode 多线程情况下,如果使用默认condexName的context访问同一个resource时,使用的是同一个DefaultNode Mar 25, 2021
@XiongMMaq XiongMMaq changed the title 多线程情况下,如果使用默认condexName的context访问同一个resource时,使用的是同一个DefaultNode 多线程情况下,如果使用默认contextName的context访问同一个resource时,使用的是同一个DefaultNode Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant