You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/05/07 12:07:03 UTC
[GitHub] [dubbo] saleson opened a new issue, #10012: ReferenceCache.get(ReferenceConfigBase) 没有使用缓存,导致dubbo service的consumer节点持续增加 (zookeeper)
saleson opened a new issue, #10012:
URL: https://github.com/apache/dubbo/issues/10012
### Environment
* Dubbo version: 3.5
* Java version: 1.8
出现该问题的代码:
``` java
private static ReferenceCache refCache = SimpleReferenceCache.getCache();
public static GenericService getService(String serviceName, String version){
ReferenceConfig<GeniricService> refConf = new ReferenceConfig();
refConf.setProtocol("zookeeper");
refConf.setAddress(registryAddress);
refConf.setRegistry(registryConfig);
refConf.setGeneric("true");
refConf.setInterface(serviceName);
refConf.setVersion(version);
refConf.setTimeout(5000);
return refCache.get(refConf);
}
```
### Expected Behavior
从缓存中获取GenericService
### Actual Behavior
<!-- What actually happens? -->
SimpleReferenceCache.get()方法没有从缓存中获取,而是直接调用了ReferenceConfig.get(),且执行了ReferenceConfig.init()另外创建了新的GenericService, 在zookeeper上也在相应的service节点下添加了consumer节点
SimpleReferenceCache.get(ReferenceConfigBase):
```
public <T> T get(ReferenceConfigBase<T> rc) {
String key = generator.generateKey(rc);
Class<?> type = rc.getInterfaceClass();
Object proxy = rc.get();
references.computeIfAbsent(rc, _rc -> {
List<ReferenceConfigBase<?>> referencesOfType = referenceTypeMap.computeIfAbsent(type, _t -> Collections.synchronizedList(new ArrayList<>()));
referencesOfType.add(rc);
List<ReferenceConfigBase<?>> referenceConfigList = referenceKeyMap.computeIfAbsent(key, _k -> Collections.synchronizedList(new ArrayList<>()));
referenceConfigList.add(rc);
return proxy;
});
return (T) proxy;
}
```
如果使用DubboBootstrap.getInstance().getCache().get(refConf);也会出现一样的情况,DubboBootstrap.getInstance().getCache()返回的是CompositeReferenceCache对象,而CompositeReferenceCache.get(ReferenceConfigBase)方法如下:
```
public <T> T get(ReferenceConfigBase<T> referenceConfig) {
return referenceConfig.get();
}
```
可以看出,在CompositeReferenceCache.get(ReferenceConfigBase)方法和SimpleReferenceCache.get(ReferenceConfigBase)方法中都没有使用到缓存。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] chickenlj commented on issue #10012: ReferenceCache.get(ReferenceConfigBase) 没有使用缓存,导致dubbo service的consumer节点持续增加 (zookeeper)
Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #10012:
URL: https://github.com/apache/dubbo/issues/10012#issuecomment-1120592568
related https://github.com/apache/dubbo/issues/9829
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] saleson commented on issue #10012: ReferenceCache.get(ReferenceConfigBase) 没有使用缓存,导致dubbo service的consumer节点持续增加 (zookeeper)
Posted by GitBox <gi...@apache.org>.
saleson commented on issue #10012:
URL: https://github.com/apache/dubbo/issues/10012#issuecomment-1120883258
https://github.com/apache/dubbo/issues/9829 修复了SimpleReferenceCache.get(ReferenceConfigBase)中的逻辑, CompositeReferenceCache.get(ReferenceConfigBase)方法仍是没有修复
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] saleson commented on issue #10012: ReferenceCache.get(ReferenceConfigBase) 没有使用缓存,导致dubbo service的consumer节点持续增加 (zookeeper)
Posted by GitBox <gi...@apache.org>.
saleson commented on issue #10012:
URL: https://github.com/apache/dubbo/issues/10012#issuecomment-1124456492
@chickenlj 大佬,CompositeReferenceCache.get(ReferenceConfigBase)方法没有使用缓存的问题需要重新提个issue么?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] chickenlj closed issue #10012: ReferenceCache.get(ReferenceConfigBase) 没有使用缓存,导致dubbo service的consumer节点持续增加 (zookeeper)
Posted by GitBox <gi...@apache.org>.
chickenlj closed issue #10012: ReferenceCache.get(ReferenceConfigBase<T>) 没有使用缓存,导致dubbo service的consumer节点持续增加 (zookeeper)
URL: https://github.com/apache/dubbo/issues/10012
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org