CN114327604A - Configuration information obtaining method, system, storage medium and electronic equipment - Google Patents

Configuration information obtaining method, system, storage medium and electronic equipment Download PDF

Info

Publication number
CN114327604A
CN114327604A CN202210009401.8A CN202210009401A CN114327604A CN 114327604 A CN114327604 A CN 114327604A CN 202210009401 A CN202210009401 A CN 202210009401A CN 114327604 A CN114327604 A CN 114327604A
Authority
CN
China
Prior art keywords
configuration information
target
center
target configuration
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210009401.8A
Other languages
Chinese (zh)
Inventor
黄敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Original Assignee
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Happly Sunshine Interactive Entertainment Media Co Ltd filed Critical Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority to CN202210009401.8A priority Critical patent/CN114327604A/en
Publication of CN114327604A publication Critical patent/CN114327604A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention provides a configuration information obtaining method, a configuration information obtaining system, a storage medium and electronic equipment. The method comprises the following steps: acquiring an identifier of target configuration information; when the type of a target configuration center to which the target configuration information belongs is a first type, sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information is changed; and when the type of the target configuration center to which the target configuration information belongs is a second type, acquiring second configuration information of the target configuration center, and acquiring update information of the target configuration information from the second configuration information based on the identifier. The method selects the mode of obtaining the configuration updating information according to the type of the target configuration center to which the target configuration information belongs, can improve the flexibility of obtaining the configuration updating information, and meets the more flexible and higher-level configuration subscription scenes.

Description

Configuration information obtaining method, system, storage medium and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, a system, a storage medium, and an electronic device for obtaining configuration information.
Background
Currently, the manner in which configuration update information is obtained from a configuration center is typically only available in a single manner. For example, in Java development, the configuration dynamics of a Spring Cloud (an ordered set of a series of frames) acquisition configuration center can only be acquired by an @ Value manner, and this configuration update information acquisition manner has poor flexibility, and cannot acquire changed configuration information in time when the configuration information changes, which cannot meet the needs of some service scenarios.
Disclosure of Invention
Embodiments of the present invention provide a method, a system, a storage medium, and an electronic device for obtaining configuration information, which can improve flexibility of a configuration update information obtaining manner. The specific technical scheme is as follows:
the invention provides a configuration information obtaining method, which comprises the following steps:
acquiring an identifier of target configuration information; wherein, the target configuration information is at least part of configuration information of a target configuration center;
when the type of the target configuration center to which the target configuration information belongs is a first type, sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information is changed, wherein the first configuration information is update information of the target configuration information;
and when the type of the target configuration center to which the target configuration information belongs is a second type, acquiring second configuration information of the target configuration center, and acquiring update information of the target configuration information from the second configuration information based on the identifier, wherein the second configuration information is all configuration information of the target configuration center.
Optionally, when the type of the target configuration center to which the target configuration information belongs is a second type, obtaining second configuration information of the target configuration center, and obtaining update information of the target configuration information from the second configuration information based on the identifier specifically includes:
when the target configuration center is a Consul configuration center, acquiring a current time point, when a difference value between the current time point and a stored information acquisition time point is equal to a preset difference value, acquiring all configuration information of the Consul configuration center, and updating the stored information acquisition time point by using acquisition moments of all configuration information of the Consul configuration center;
obtaining the target configuration information from all the configuration information based on the identification;
comparing the obtained Index value of the target configuration information with the stored Index value of the target configuration information;
and when the Index values are not consistent, using the obtained target configuration information as the update information of the target configuration information, and using the update information of the target configuration information as the stored target configuration information.
Optionally, when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is a Zookeeper configuration center, generating a path directory based on the identifier; the generated path directory is the same as the path directory of the Zookeeper configuration center, and the path directory of the Zookeeper configuration center is provided with a plurality of nodes carrying configuration information;
determining the node of the target configuration information in the path directory to obtain a target node; the path information of the target node is the identifier of the target configuration information;
and periodically sending the path information of the target node to the Zookeeper configuration center according to a preset period, and receiving the first configuration information sent by the Zookeeper configuration center after the configuration information of the target node is changed.
Optionally, when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is an Etcd configuration center, converting the type of the identifier from a character string type to a byte sequence type to obtain a first conversion identifier;
sending the first conversion identifier to the Etcd configuration center, and receiving first configuration information sent by the Etcd configuration center after the target configuration information changes;
and screening out the configuration information of which the event type is a modification type and/or a deletion type from the first configuration information.
Optionally, when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is a Redis configuration center, converting the type of the identifier from a character string type to a Pattern Topic type to obtain a second conversion identifier;
and sending the second conversion identifier to the Redis configuration center, and receiving first configuration information sent by the Redis configuration center after the target configuration information is changed.
Optionally, the identifying comprises: packet information and data ID information; when the type of the target configuration center to which the target configuration information belongs is a first type, sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information changes, specifically including:
when the target configuration center is a Nacos configuration center, sending the grouping information and the data ID information to the Nacos configuration center, and receiving first configuration information sent by the Nacos configuration center after the target configuration information is changed; the target configuration information is configuration information corresponding to both the grouping information and the data ID information.
Optionally, when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is an Apollo configuration center, sending the identifier serving as a keyword to the Apollo configuration center, and receiving first configuration information sent by the Apollo configuration center after the target configuration information is changed; the target configuration information is a value corresponding to the keyword.
The present invention also provides a configuration information obtaining system, including:
the identification acquisition module is used for acquiring an identification of the target configuration information; wherein, the target configuration information is at least part of configuration information of a target configuration center;
a first configuration information obtaining module, configured to send the identifier to the target configuration center when the type of the target configuration center to which the target configuration information belongs is a first type, and receive first configuration information sent by the target configuration center after the target configuration information changes, where the first configuration information is update information of the target configuration information;
a second configuration information obtaining module, configured to, when the type of the target configuration center to which the target configuration information belongs is a second type, obtain second configuration information of the target configuration center, and obtain update information of the target configuration information from the second configuration information based on the identifier, where the second configuration information is all configuration information of the target configuration center.
The present invention also provides a computer-readable storage medium having stored thereon a program which, when executed by a processor, implements the above-described configuration information obtaining method.
The present invention also provides an electronic device comprising:
at least one processor, and at least one memory, bus connected with the processor;
the processor and the memory complete mutual communication through the bus; the processor is used for calling the program instructions in the memory so as to execute the configuration information obtaining method.
The method comprises the steps of sending an identifier to a target configuration center when the type of the target configuration center is a first type, and receiving first configuration information sent by the target configuration center after the target configuration information changes; and when the type of the target configuration center is a second type, obtaining the update information of the target configuration information from the second configuration information based on the identification. The method selects the mode of obtaining the configuration updating information according to the type of the target configuration center to which the target configuration information belongs, can improve the flexibility of obtaining the configuration updating information, and meets the more flexible and higher-level configuration subscription scenes.
Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a configuration information obtaining method according to an embodiment of the present invention;
fig. 2 is a structural diagram of a configuration information obtaining system according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a configuration information obtaining method, as shown in fig. 1, the method includes:
step 101: acquiring an identifier of target configuration information; the target configuration information is at least part of configuration information of the target configuration center.
The configuration center is a basic service component for uniformly managing various application configurations. The target configuration information is stored in the configuration center, and in order to find the target configuration information in the configuration center, the identification of the target configuration information needs to be obtained. Optionally, the target configuration information may be all configuration information of the target configuration center, or may be partial configuration information of the target configuration center. In the present embodiment, the configuration center has six types, i.e., Nacos, Apollo (Apollo), Consul, Etcd, Redis, and Zookeeper. The target configuration information may be different for different configuration centers, and the identity of different target configuration information may also be different.
In this embodiment, before acquiring the identifier of the target configuration information, a configuration center to which the target configuration information belongs needs to be determined, and after the target configuration center is determined, link information for linking the target configuration center needs to be acquired, and the configuration center is linked based on the link information.
Alternatively, the link information may be a configuration center address, configuration center port information, a user name and a user password for accessing the configuration center, and the like. The link information of the configuration centers that need to be loaded by the heterogeneous configuration centers may be different. Alternatively, the loaded configuration file may be of the yml type or properties type.
In order to obtain configuration update information of the configuration center, the invention provides an adapter Interface, which includes API interfaces (Application Programming interfaces) such as beforeInit, init, asterinit, getGroup, getDataId, changeCallback and the like, so as to realize the link between the adapter and the configuration center or close the link to the configuration center. The beforeInit interface is used for loading link information of the configuration center, the init interface is used for being linked with the configuration center, the afterInit is used for achieving the function of obtaining the configuration information after the link configuration center succeeds, the getGroup and getDataId are used for locating the configuration information, and the changeCallback is used for performing callback operation when the group-dataId changes.
Step 102: when the type of the target configuration center to which the target configuration information belongs is a first type, the identifier is sent to the target configuration center, and first configuration information sent by the target configuration center after the target configuration information is changed is received, wherein the first configuration information is update information of the target configuration information.
In an optional embodiment, when the target configuration center is a Zookeeper configuration center, step 102 specifically includes: generating a path directory based on the identification; the generated path directory is the same as that of the Zookeeper configuration center, and the path directory of the Zookeeper configuration center is provided with a plurality of nodes carrying configuration information; determining a node of the target configuration information in a path directory to obtain a target node; the path information of the target node is the mark of the target configuration information; according to a preset period, periodically sending the path information of the target node to a Zookeeper configuration center, and receiving first configuration information sent by the Zookeeper configuration center after the configuration information at the target node is changed.
When the path directory is generated based on the identifier, the path directory is generated through group (grouping) and serviceId (service number), and the group and serviceId information of the generated directory includes the identifier group and serviceId information. The method comprises the steps that path information of a node can be obtained based on group information and serviceId information, the path information of a target node is used as an identifier of target configuration information, the path information of the target node is sent to a Zookeeper configuration center, and first configuration information sent by the Zookeeper configuration center after the configuration information of the target node is changed is received.
The generated path directory is the same as the path directory of the Zookeeper configuration center, so that the Zookeeper configuration center can find the target configuration information according to the path of the target node when the path information of the target node is sent to the Zookeeper configuration center. If the two path directories are different, after the path information of the target node is sent to the Zookeeper configuration center, the Zookeeper configuration center cannot find the target configuration information or find other configuration information, and the first configuration information sent after the configuration information of the Zookeeper configuration center at the target node is changed is prevented from being received and not meeting the requirement.
After receiving the first configuration information sent by the Zookeeper configuration center, the Zookeeper configuration center does not actively notify the changed configuration information, and therefore, the route information of the target node needs to be periodically sent to the Zookeeper configuration center according to a preset period, so as to receive the first configuration information sent by the Zookeeper configuration center after the configuration information at the target node is changed.
Further, the configuration update information of the Zookeeper configuration center can be acquired through clients such as Zookeeper, curater, zkcent and the like. For example, Curator is selected to implement the configuration acquisition. Step one, setting a callback processing interface Zookeeper subscription callback interface, wherein only one callback method is arranged inside the callback processing interface Zookeeper subscription callback interface. And step two, constructing a path directory (path directory) through the group and the serviceId. And step three, following the path to create NodeCache (directory node), starting a monitoring mode, and testing a monitoring interface NodeCacheListener (directory node monitor) of the client. And step four, following the NodeCache and NodeCacheListener to create a zookeeper Listener monitoring module and starting monitoring. And step five, if monitoring configuration updating, calling back the first configuration information by calling a callback method.
As another optional implementation manner, when the target configuration center is an Etcd configuration center, step 102 specifically includes: converting the type of the identifier from a character string type to a byte sequence type to obtain a first conversion identifier; sending the first conversion identifier to an Etcd configuration center, and receiving first configuration information sent by the Etcd configuration center after the target configuration information changes; and screening the configuration information of which the event type is the modification type and/or the deletion type from the first configuration information.
After the first conversion identifier is sent to the Etcd configuration center, the Etcd configuration center sends all message types related to the target configuration information. However, the Etcd configuration center sends a part of message types which are not required target configuration update information, so that the messages sent by the first configuration center need to be screened based on the message types. Optionally, the configuration information with event type of modified type (PUT) and/or deleted type (DELETE) is screened out. While for the event type Create (CREAT), SET (SET) is filtered out.
Further, the Etcd configuration center provides a Watch monitoring class in the Java client, but this monitors all events, and some events do not need to be monitored, so that only call-back processing needs to be performed on PUT and DELETE events. Step one, setting a callback processing interface Etcd SubscribeCallback (Etcd subscription callback interface), wherein only one callback method is used. And step two, converting the configured key words (key) from the character String type (String type) into a byte sequence (ByteSequence). And thirdly, realizing a client monitoring interface (Listener interface), judging the event type (eventType) in the interface, and acquiring the changed value through event. And fourthly, calling back the callback method by using the value to obtain the configuration information of which the event type is the modification type and/or the deletion type.
As another optional implementation manner, when the target configuration center is a Redis configuration center, step 102 specifically includes: converting the type of the identifier from a character string type to a Pattern Topic type to obtain a second conversion identifier; and sending the second conversion identifier to a Redis configuration center, and receiving first configuration information sent by the Redis configuration center after the target configuration information changes.
Optionally, the listening to the Redis configuration center may be implemented using spring to provide the Redis client. Step one, setting a callback processing interface Redis SubscribeCallback (Redis subscription callback interface), wherein only one callback method is used. And step two, creating an object messagelistenerdadapter (information monitoring adapter) through two parameters of a monitoring object and a subscription configuration method. And step three, converting the configured key from the String type into a Pattern object (pattern theme). And step four, calling the Redis information monitoring adapter Redis MessageListenerContainer to change the change of addMessageListener (adding a message monitor) monitoring value. And step five, if monitoring configuration updating, calling back the first configuration information by calling a callback method.
As another optional implementation manner, when the target configuration center is a Nacos configuration center, step 102 specifically includes: sending the grouping information and the data ID information to a Nacos configuration center, and receiving first configuration information sent by the Nacos configuration center after the target configuration information is changed; the target configuration information is configuration information corresponding to both the grouping information and the data ID information.
Optionally, the monitoring of the Nacos configuration center may be implemented by first loading information such as a Nacos address through loadProperties (loading a property file) and performing link initialization, where the Nacos provides an http interface, and the monitoring of the interface is implemented in a subscriber mode development manner, and when a corresponding value of a monitored group-dataId (packet information-data ID information) changes, a callback manner (change callback) is used to obtain first configuration information.
As another optional implementation, when the target configuration center is an Apollo configuration center, step 102 specifically includes: sending the identifier as the key word to an Apollo configuration center, and receiving first configuration information sent by the Apollo configuration center after the target configuration information is changed; the target configuration information is a value corresponding to the keyword.
Optionally, the monitoring of the Apollo configuration center can be directly performed by using a Java client provided by the configuration center for docking, and the http interface and the callback monitoring mode are used in a link mode. Step one, setting a callback processing interface ApolloSubscribeCallback (Apollo subscription callback interface), wherein only one callback method is used. And step two, realizing that a ConfigChangeListener (configuration change listener) monitors a callback interface, rewriting an onChange method and obtaining a changed value. And thirdly, calling back the callback method by using the value to obtain first configuration updating information.
Step 103: and when the type of the target configuration center to which the target configuration information belongs is a second type, acquiring second configuration information of the target configuration center, and acquiring update information of the target configuration information from the second configuration information based on the identifier, wherein the second configuration information is all configuration information of the target configuration center.
As an optional implementation manner, when the target configuration center is a Consul configuration center, step 103 specifically includes: acquiring a current time point, acquiring all configuration information of a Consul configuration center when a difference value between the current time point and a stored information acquisition time point is equal to a preset difference value, and updating the stored information acquisition time point by using the acquisition time of all the configuration information of the Consul configuration center; obtaining target configuration information from all configuration information based on the identification; comparing the obtained Index value of the target configuration information with the stored Index value of the target configuration information; and when the Index values are not consistent, using the obtained target configuration information as the update information of the target configuration information, and using the update information of the target configuration information as the stored target configuration information.
Since the Consul configuration center can only provide an interface for acquiring configuration information, and cannot acquire change information of the target configuration information based on the interface, all configuration information of the Consul configuration center needs to be pulled from the Consul configuration center at regular time, the target configuration information needs to be acquired from all configuration information based on the identifier, whether configuration changes can be judged by comparing the Index value of the stored target configuration information with the received Index value, and when the Index values are inconsistent, update information of the target configuration information is obtained.
Further, the Consul configuration center provides Java clients, but only obtains configuration information interfaces. Step one, setting a callback processing interface ConsubscribelCallback (Consul subscription callback interface), wherein only one callback method is used. And step two, realizing a thread (Runable) interface, pulling the configuration information once per second in the thread through consuclent.getKVvalue, and comparing whether the configuration information is updated or not from the consulIndex and the current index (version number). And step three, if the update is available, the latest value is obtained through the getValue, and then the callback method is called to call back the update information of the target configuration information.
The invention can realize the configuration center adapter by using an inheritance mode, namely the adapter can realize the monitoring of configuration information of six types of Nacos, Apollo, Consul, Etcd, Redis and Zookeeper. When different configuration centers are switched and monitored, the operation can be completed only by changing the inheritance class or modifying the configuration without modifying other codes. The time for developers to write codes in different configuration centers is saved, the efficiency is improved, and the development cost is reduced. The invention can improve the flexibility of configuration acquisition by carrying out different configuration information monitoring operations on different types of configuration centers so as to meet more flexible and higher-level configuration subscription scenes.
The present invention also provides a configuration information obtaining system, as shown in fig. 2, the system including:
an identifier obtaining module 201, configured to obtain an identifier of the target configuration information; the target configuration information is at least part of configuration information of the target configuration center.
The first configuration information obtaining module 202 is configured to send the identifier to the target configuration center when the type of the target configuration center to which the target configuration information belongs is the first type, and receive first configuration information sent by the target configuration center after the target configuration information changes, where the first configuration information is update information of the target configuration information.
The first configuration information obtaining module 202 specifically includes:
a first configuration information obtaining unit, configured to generate a path directory based on the identifier when the target configuration center is a Zookeeper configuration center; the generated path directory is the same as that of the Zookeeper configuration center, and the path directory of the Zookeeper configuration center is provided with a plurality of nodes carrying configuration information; determining a node of the target configuration information in a path directory to obtain a target node; the path information of the target node is the mark of the target configuration information; according to a preset period, periodically sending the path information of the target node to a Zookeeper configuration center, and receiving first configuration information sent by the Zookeeper configuration center after the configuration information at the target node is changed.
The second configuration information obtaining unit is used for converting the type of the identifier from the character string type into the byte sequence type to obtain a first conversion identifier when the target configuration center is the Etcd configuration center; sending the first conversion identifier to an Etcd configuration center, and receiving first configuration information sent by the Etcd configuration center after the target configuration information changes; and screening the configuration information of which the event type is the modification type and/or the deletion type from the first configuration information.
A third configuration information obtaining unit, configured to, when the target configuration center is a Redis configuration center, convert the type of the identifier from a string type to a Pattern Topic type, and obtain a second conversion identifier; and sending the second conversion identifier to a Redis configuration center, and receiving first configuration information sent by the Redis configuration center after the target configuration information changes.
The fourth configuration information obtaining unit is used for sending the grouping information and the data ID information to the Nacos configuration center and receiving the first configuration information sent by the Nacos configuration center after the target configuration information is changed when the target configuration center is the Nacos configuration center; the target configuration information is configuration information corresponding to both the grouping information and the data ID information.
A fifth configuration information obtaining unit, configured to send, when the target configuration center is an Apollo configuration center, the identifier serving as the keyword to the Apollo configuration center, and receive first configuration information sent by the Apollo configuration center after the target configuration information changes; the target configuration information is a value corresponding to the keyword.
The second configuration information obtaining module 203 is configured to, when the type of the target configuration center to which the target configuration information belongs is a second type, obtain second configuration information of the target configuration center, and obtain update information of the target configuration information from the second configuration information based on the identifier, where the second configuration information is all configuration information of the target configuration center.
The second configuration information obtaining module 203 specifically includes:
a sixth configuration information obtaining unit, configured to, when the target configuration center is a Consul configuration center, obtain a current time point, when a difference between the current time point and a stored information obtaining time point is equal to a preset difference, obtain all configuration information of the Consul configuration center, and update the stored information obtaining time point using obtaining times of all configuration information of the Consul configuration center; obtaining target configuration information from all configuration information based on the identification; comparing the obtained Index value of the target configuration information with the stored Index value of the target configuration information; and when the Index values are not consistent, using the obtained target configuration information as the update information of the target configuration information, and using the update information of the target configuration information as the stored target configuration information.
An embodiment of the present invention provides a computer-readable storage medium on which a program is stored, the program implementing the above-described configuration information obtaining method when executed by a processor.
An embodiment of the present invention provides an electronic device, as shown in fig. 3, an electronic device 30 includes at least one processor 301, and at least one memory 302 and a bus 303 connected to the processor 301; wherein, the processor 301 and the memory 302 complete the communication with each other through the bus 303; the processor 301 is used to call program instructions in the memory 302 to execute the above-mentioned configuration information obtaining method. The electronic device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application also provides a computer program product adapted to execute a program initialized with the steps comprised by the above-mentioned configuration information obtaining method, when executed on a data processing device.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, systems and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a device includes one or more processors (CPUs), memory, and a bus. The device may also include input/output interfaces, network interfaces, and the like.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for obtaining configuration information, comprising:
acquiring an identifier of target configuration information; wherein, the target configuration information is at least part of configuration information of a target configuration center;
when the type of the target configuration center to which the target configuration information belongs is a first type, sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information is changed, wherein the first configuration information is update information of the target configuration information;
and when the type of the target configuration center to which the target configuration information belongs is a second type, acquiring second configuration information of the target configuration center, and acquiring update information of the target configuration information from the second configuration information based on the identifier, wherein the second configuration information is all configuration information of the target configuration center.
2. The method according to claim 1, wherein when the type of the target configuration center to which the target configuration information belongs is a second type, acquiring second configuration information of the target configuration center, and acquiring update information of the target configuration information from the second configuration information based on the identifier specifically includes:
when the target configuration center is a Consul configuration center, acquiring a current time point, when a difference value between the current time point and a stored information acquisition time point is equal to a preset difference value, acquiring all configuration information of the Consul configuration center, and updating the stored information acquisition time point by using acquisition moments of all configuration information of the Consul configuration center;
obtaining the target configuration information from all the configuration information based on the identification;
comparing the obtained Index value of the target configuration information with the stored Index value of the target configuration information;
and when the Index values are not consistent, using the obtained target configuration information as the update information of the target configuration information, and using the update information of the target configuration information as the stored target configuration information.
3. The method according to claim 1, wherein when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving the first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is a Zookeeper configuration center, generating a path directory based on the identifier; the generated path directory is the same as the path directory of the Zookeeper configuration center, and the path directory of the Zookeeper configuration center is provided with a plurality of nodes carrying configuration information;
determining the node of the target configuration information in the path directory to obtain a target node; the path information of the target node is the identifier of the target configuration information;
and periodically sending the path information of the target node to the Zookeeper configuration center according to a preset period, and receiving the first configuration information sent by the Zookeeper configuration center after the configuration information of the target node is changed.
4. The method according to claim 1, wherein when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving the first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is an Etcd configuration center, converting the type of the identifier from a character string type to a byte sequence type to obtain a first conversion identifier;
sending the first conversion identifier to the Etcd configuration center, and receiving first configuration information sent by the Etcd configuration center after the target configuration information changes;
and screening out the configuration information of which the event type is a modification type and/or a deletion type from the first configuration information.
5. The method according to claim 1, wherein when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving the first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is a Redis configuration center, converting the type of the identifier from a character string type to a Pattern Topic type to obtain a second conversion identifier;
and sending the second conversion identifier to the Redis configuration center, and receiving first configuration information sent by the Redis configuration center after the target configuration information is changed.
6. The method according to claim 1, wherein the identifying comprises: packet information and data ID information; when the type of the target configuration center to which the target configuration information belongs is a first type, sending the identifier to the target configuration center, and receiving first configuration information sent by the target configuration center after the target configuration information changes, specifically including:
when the target configuration center is a Nacos configuration center, sending the grouping information and the data ID information to the Nacos configuration center, and receiving first configuration information sent by the Nacos configuration center after the target configuration information is changed; the target configuration information is configuration information corresponding to both the grouping information and the data ID information.
7. The method according to claim 1, wherein when the type of the target configuration center to which the target configuration information belongs is a first type, the sending the identifier to the target configuration center, and receiving the first configuration information sent by the target configuration center after the target configuration information changes includes:
when the target configuration center is an Apollo configuration center, sending the identifier serving as a keyword to the Apollo configuration center, and receiving first configuration information sent by the Apollo configuration center after the target configuration information is changed; the target configuration information is a value corresponding to the keyword.
8. A configuration information obtaining system, comprising:
the identification acquisition module is used for acquiring an identification of the target configuration information; wherein, the target configuration information is at least part of configuration information of a target configuration center;
a first configuration information obtaining module, configured to send the identifier to the target configuration center when the type of the target configuration center to which the target configuration information belongs is a first type, and receive first configuration information sent by the target configuration center after the target configuration information changes, where the first configuration information is update information of the target configuration information;
a second configuration information obtaining module, configured to, when the type of the target configuration center to which the target configuration information belongs is a second type, obtain second configuration information of the target configuration center, and obtain update information of the target configuration information from the second configuration information based on the identifier, where the second configuration information is all configuration information of the target configuration center.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a program which, when executed by a processor, implements the configuration information obtaining method of any one of claims 1 to 7.
10. An electronic device, comprising:
at least one processor, and at least one memory, bus connected with the processor;
the processor and the memory complete mutual communication through the bus; the processor is configured to call program instructions in the memory to perform the configuration information obtaining method of any one of claims 1-7.
CN202210009401.8A 2022-01-05 2022-01-05 Configuration information obtaining method, system, storage medium and electronic equipment Pending CN114327604A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210009401.8A CN114327604A (en) 2022-01-05 2022-01-05 Configuration information obtaining method, system, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210009401.8A CN114327604A (en) 2022-01-05 2022-01-05 Configuration information obtaining method, system, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN114327604A true CN114327604A (en) 2022-04-12

Family

ID=81025245

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210009401.8A Pending CN114327604A (en) 2022-01-05 2022-01-05 Configuration information obtaining method, system, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114327604A (en)

Similar Documents

Publication Publication Date Title
CN111752799A (en) Service link tracking method, device, equipment and storage medium
CN110535928B (en) Event pushing method for JAVA intelligent contract of block chain
CN111090423A (en) Webhook framework system and method for realizing active calling and event triggering
CN108366098B (en) Data interaction method and device for network nodes
CN108255708A (en) Method, apparatus, storage medium and the equipment of production file are accessed in test environment
CA3065729A1 (en) Business rules processing framework
CN106936660B (en) Data acquisition method and device
CN112346872A (en) Cloud computing capacity expansion method and device based on service call link
CN114327604A (en) Configuration information obtaining method, system, storage medium and electronic equipment
CN112579877A (en) Information source system control method, device, storage medium and equipment
CN110968406A (en) Method, device, storage medium and processor for processing task
CN115567388A (en) Method, system, device and storage medium for automatically updating network slice configuration
CN111884932B (en) Link determining method, device, equipment and computer readable storage medium
CN114328129A (en) Message sending method, device, equipment and storage medium
CN109918147B (en) Expansion method and device for drive under OpenStack and electronic equipment
CN110968888B (en) Data processing method and device
CN112463616A (en) Chaos testing method and device for Kubernetes container platform
CN112579325A (en) Business object processing method and device, electronic equipment and storage medium
CN111913789A (en) Program tracking method, device and medium supporting micro-service architecture
CN111488388B (en) Deployment method, device and equipment of data storage contract
CN111078430A (en) Message notification processing method, device and storage medium
CN109428915B (en) Data acquisition method and device
CN107861822B (en) Method, device and equipment for simulating broadcast notification in client
CN113852919B (en) Method and device for generating early warning message, storage medium and electronic device
CN112579009A (en) Error log printing method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination