Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze the SharedInformer structure in Controller Manager

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

How to analyze the SharedInformer structure in Controller Manager? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Most Controller implementations rely on a special structure-SharedInformer, which is mainly responsible for subscribing to resource changes on the etcd and calling the registered Handlers.

The SharedInformer-related class structure is shown below:

SharedInformer is a complex nested structure with a total of four layers from bottom to top

Queue

The DeltaFIFO structure implements the Queue (and Store) interface and internally uses a map called items to store Delta data. The key of items is calculated for each enrollment object through a pre-passed keyFunc.

The map-based storage structure enables DeltaFIFO to quickly retrieve any internal element (this is also to implement the Store interface), while queue stores the entry order of the elements.

Reflector

The Reflector structure can monitor changes on the etcd through listWatcher and synchronize them to the local store structure in real time.

Controller

Controller initializes a DeltaFIFO structure and creates a Reflector structure as a store to monitor changes to specific etcd resources. The changes observed by listWatcher are stored in the DeltaFIFO, and Controller constantly consumes the elements in the DeltaFIFO as the Process Func passed in when entering the parameter call construction.

SharedIndexInformer

SharedIndexInformer implements the SharedInformer interface, which uses its own HandleDeltas () method as Process Func to construct Controller. All resource changes detected by Controller are called back to sharedIndexInformer.HandleDeltas ().

Indexer is a cache structure that stores the latest data for monitoring resources. When Controller receives a change, it can use indexer to obtain the value of the change data before the change.

SharedProcessor is used to store all registered Listener. When HandleDeltas is called back, the distribute () method on sharedProcessor is triggered to finally invoke all registered Listeners.

Through the combined use of the above four data structures, the whole data link from resource monitoring to Listener callback is finally realized.

This is the answer to the question on how to analyze the SharedInformer structure in Controller Manager. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report