In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the role of DelegateConsistencyServiceImpl in nacos. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
ConsistencyService
Nacos-1.1.3/naming/src/main/java/com/alibaba/nacos/naming/consistency/ConsistencyService.java
Public interface ConsistencyService {/ * * Put a data related to a key to Nacos cluster * * @ param key key of data, this key should be globally unique * @ param value value of data * @ throws NacosException * @ see * / void put (String key, Record value) throws NacosException / * Remove a data from Nacos cluster * * @ param key key of data * @ throws NacosException * / void remove (String key) throws NacosException; / * Get a data from Nacos cluster * * @ param key key of data * @ return data related to the key * @ throws NacosException * / Datum get (String key) throws NacosException / * Listen for changes of a data * * @ param key key of data * @ param listener callback of data change * @ throws NacosException * / void listen (String key, RecordListener listener) throws NacosException / * Cancel listening of a data * * @ param key key of data * @ param listener callback of data change * @ throws NacosException * / void unlisten (String key, RecordListener listener) throws NacosException; / * * Tell the status of this consistency service * * @ return true if available * / boolean isAvailable ();}
ConsistencyService defines put, remove, get, listen, unlisten, isAvailable methods
DelegateConsistencyServiceImpl
Nacos-1.1.3/naming/src/main/java/com/alibaba/nacos/naming/consistency/DelegateConsistencyServiceImpl.java
@ Service ("consistencyDelegate") public class DelegateConsistencyServiceImpl implements ConsistencyService {@ Autowired private PersistentConsistencyService persistentConsistencyService; @ Autowired private EphemeralConsistencyService ephemeralConsistencyService; @ Override public void put (String key, Record value) throws NacosException {mapConsistencyService (key) .put (key, value);} @ Override public void remove (String key) throws NacosException {mapConsistencyService (key) .remove (key);} @ Override public Datum get (String key) throws NacosException {return mapConsistencyService (key) .get (key) } @ Override public void listen (String key, RecordListener listener) throws NacosException {/ / this special key is listened by both: if (KeyBuilder.SERVICE_META_KEY_PREFIX.equals (key)) {persistentConsistencyService.listen (key, listener); ephemeralConsistencyService.listen (key, listener); return;} mapConsistencyService (key) .requests (key, listener) } @ Override public void unlisten (String key, RecordListener listener) throws NacosException {mapConsistencyService (key) .unchecked (key, listener);} @ Override public boolean isAvailable () {return ephemeralConsistencyService.isAvailable () & & persistentConsistencyService.isAvailable ();} private ConsistencyService mapConsistencyService (String key) {return KeyBuilder.matchEphemeralKey (key)? EphemeralConsistencyService: persistentConsistencyService;}}
DelegateConsistencyServiceImpl implements the ConsistencyService interface; mapConsistencyService is used inside its put, remove, get, listen and unlisten methods to determine whether to use ephemeralConsistencyService or persistentConsistencyService;. Its isAvailable method requires that both ephemeralConsistencyService and persistentConsistencyService are available.
Summary
ConsistencyService defines put, remove, get, listen, unlisten, isAvailable methods; DelegateConsistencyServiceImpl implements the ConsistencyService interface; mapConsistencyService is used inside its put, remove, get, listen and unlisten methods to determine whether to use ephemeralConsistencyService or persistentConsistencyService; and its isAvailable method requires ephemeralConsistencyService and persistentConsistencyService to be available
The above is what the role of DelegateConsistencyServiceImpl in nacos is shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.