CN115309421A - Static variable synchronization method, device, equipment and storage medium of single-point system - Google Patents

Static variable synchronization method, device, equipment and storage medium of single-point system Download PDF

Info

Publication number
CN115309421A
CN115309421A CN202210806011.3A CN202210806011A CN115309421A CN 115309421 A CN115309421 A CN 115309421A CN 202210806011 A CN202210806011 A CN 202210806011A CN 115309421 A CN115309421 A CN 115309421A
Authority
CN
China
Prior art keywords
static variable
version number
target
static
variable
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
CN202210806011.3A
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.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software 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 Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202210806011.3A priority Critical patent/CN115309421A/en
Publication of CN115309421A publication Critical patent/CN115309421A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Multi Processors (AREA)

Abstract

The disclosure relates to a static variable synchronization method, a device, equipment and a storage medium of a single-point system, wherein the method comprises the following steps: responding to the starting of a local application program, and determining a target static variable to be monitored; obtaining a static variable node corresponding to the target static variable in the zookeeper, wherein the static variable node comprises static variable data and a first version number of the target static variable; and creating a monitoring thread aiming at the target static variable, and synchronizing the static variable data of the target static variable in the local and the static variable data in the static variable node based on the first version number and the second version number of the target static variable in the local. According to the technical scheme disclosed by the invention, the original system service codes are not required to be modified while the synchronous static variables are realized, the universality is strong, the code modification workload when a single-point system is upgraded and deployed is reduced, and the working cost when the single-point system is upgraded is saved.

Description

Static variable synchronization method, device, equipment and storage medium of single-point system
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to a static variable synchronization method, device, and apparatus for a single-point system, and a storage medium.
Background
In order to meet the requirement of the system on response speed, the running application system is usually deployed in a cluster manner to improve the system performance, and for the application system developed by java, the cluster manner is implemented by running a plurality of application instances on different JVM virtual machines, and memories between the different JVM virtual machines are isolated from each other, but in many cases, some global variables need to be shared between the JVM memories of different application instances, and the operation of each application instance on the global variables needs to be synchronized to other application instances to ensure the normal running of services. In order to meet the requirement, the global variable data is usually stored in a third-party service such as redis, and each application instance directly performs an add-delete-modify operation on the data in the redis so as to ensure the consistency of the data among different JVMs.
However, for a part of old systems or developed systems, since the development is performed on the premise of a single-point operation mode in the initial development stage, global variables of such memory level are usually put into the JVM memory in the form of static variables for use among different services, and if cluster deployment is performed on such single-point system, the static variables cannot be synchronized in the whole application system cluster. At present, a global static variable is stored in a third-party service in a mode of modifying a business code, so that the workload of modifying the code is large, the development cost is high, and the problem that part of systems cannot modify the business code exists.
Disclosure of Invention
In order to solve the technical problem, the present disclosure provides a static variable synchronization method, device, apparatus, and storage medium for a single-point system.
In a first aspect, an embodiment of the present disclosure provides a static variable synchronization method for a single-point system, including:
responding to the starting of a local application program, and determining a target static variable to be monitored;
obtaining a static variable node corresponding to the target static variable in the zookeeper, wherein the static variable node comprises static variable data and a first version number of the target static variable;
and creating a monitoring thread aiming at the target static variable, and synchronizing the static variable data of the target static variable in the local and the static variable data in the static variable node based on the first version number and the second version number of the target static variable in the local.
Optionally, the determining a target static variable to be listened to includes:
acquiring member variables of each class corresponding to the application program and acquiring modifiers of the member variables;
determining the member variable of which the modifier meets a preset condition from all the member variables as a static variable;
and determining a target static variable from all static variables according to the variable type, the variable name and the class to which the variable belongs.
Optionally, the obtaining a static variable node corresponding to the target static variable in the zookeeper includes:
when it is detected that no static variable node corresponding to the target static variable exists in the zookeeper, static variable data corresponding to the target static variable is acquired and stored locally, wherein the static variable data comprises a name attribute and a variable value of the target static variable;
the initial value of the version number is used as a second version number and is stored to the local;
and registering the static variable node according to the local static variable data of the target static variable and the initial value of the version number.
Optionally, the synchronizing, based on the first version number and the second version number of the target static variable locally, the static variable data of the target static variable locally with the static variable data in the static variable node includes:
and updating the second version number to the first version number and updating the local static variable data to the static variable data in the static variable node when the first version number is larger than the second version number.
Optionally, the synchronizing, based on the first version number and a second version number of the target static variable locally, static variable data of the target static variable locally with static variable data in the static variable node includes:
when the change of the static variable data of the target static variable in the local is detected, updating the static variable data in the static variable node according to the changed static variable data;
and adding one to the first version number and the second version number.
Optionally, the updating the static variable data in the static variable node according to the changed static variable data includes:
and modifying a static variable node corresponding to the target static variable in the zookeeper according to the changed static variable data in a distributed locking mode.
Optionally, the registering the static variable node according to the local static variable data of the target static variable and the version number initial value includes:
taking the name attribute as a node name of the static variable node, wherein the name attribute comprises a variable name and a class name;
taking the initialized variable value as the node content of the static variable node;
and taking the initial value of the version number as a first version number of the static variable node.
In a second aspect, an embodiment of the present disclosure provides a static variable synchronization apparatus for a single-point system, including:
the determining module is used for responding to the starting of the local application program and determining a target static variable to be monitored;
the acquisition module is used for acquiring a static variable node corresponding to the target static variable in the zookeeper, wherein the static variable node comprises static variable data and a first version number of the target static variable;
and the synchronization module is used for creating a monitoring thread aiming at the target static variable, and synchronizing the static variable data of the target static variable in the local and the static variable data in the static variable node based on the first version number and the second version number of the target static variable in the local.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor; a memory for storing the processor-executable instructions; the processor is configured to read the executable instruction from the memory, and execute the instruction to implement the static variable synchronization method of the single-point system according to the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable storage medium, where the storage medium stores a computer program, and the computer program, when executed by a processor, implements the static variable synchronization method of the single-point system according to the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages: the method includes the steps that static variable nodes corresponding to target static variables to be monitored in a zookeeper are obtained, monitoring threads for the target static variables are created, static variable data of the target static variables in the local are synchronized with static variable data of the static variable nodes based on a first version number and a second version number of the target static variables in the static variable nodes, and therefore the method is applied to a single-point system, high in universality, capable of achieving synchronization of global variables without modifying original system service codes, capable of being embedded into the original system as a service, capable of reducing code modification workload when the single-point system is used for upgrading clusters on the premise that the original codes cannot be modified, and capable of saving working cost of synchronizing the global variables when the single-point system needs cluster upgrading.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic flowchart of a static variable synchronization method of a single-point system according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram of static variable synchronization of a single-point system according to an embodiment of the disclosure;
fig. 3 is a schematic structural diagram of a static variable synchronization apparatus of a single-point system according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that the embodiments and features of the embodiments of the present disclosure may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
Fig. 1 is a schematic flowchart of a static variable synchronization method of a single-point system according to an embodiment of the present disclosure, where the method provided by the embodiment of the present disclosure may be executed by a static variable synchronization apparatus of the single-point system, and the apparatus may be implemented by software and/or hardware, and may be integrated on any electronic device with computing capability.
As shown in fig. 1, a static variable synchronization method of a single-point system according to an embodiment of the present disclosure may include:
step 101, responding to the start of the local application program, determining a target static variable to be monitored.
The method of the embodiment of the disclosure is applied to a single-point system. In this embodiment, the single-point system is deployed and operated in a cluster manner, and the single-point system includes a plurality of JVM (Java Virtual Machine) Virtual machines, and is specifically applied to synchronization of global static variables between different Virtual machines.
In this embodiment, taking one of the virtual machines as an example, in response to the start of the local application, a global static variable that needs to be synchronized in the virtual machine is first determined.
In one embodiment of the present disclosure, determining a target static variable to be listened to includes: acquiring member variables of each class corresponding to the application program and acquiring modifiers of the member variables; determining the member variable of which the modifier meets a preset condition from all the member variables as a static variable; and determining a target static variable from all static variables according to the variable type, the variable name and the class to which the variable belongs.
After the local application system is started, a set of application programs loaded into a JVM (Java virtual machine) class is obtained through a java AppClassLoader class loader, the class set is circulated, member variables of each class in the class set are obtained through java reflection, and static variables are determined according to modifiers of the member variables, for example, the variables of which the modifiers are 10 are the static variables. Furthermore, because the class loaded into the JVM class by the application program contains the class in the third-party jar package, static variables which do not need to be synchronized in the application program can be filtered through condition configuration such as variable types, variable names, class information to which the variables belong and the like.
Step 102, obtaining a static variable node corresponding to the target static variable in a zookeeper (reliable coordination software for a distributed system), wherein the static variable node comprises static variable data of the target static variable and a first version number.
In this embodiment, the version number is used to indicate an updated version of data. Taking one of the virtual machines as an example, there are two cases: a static variable node corresponding to the target static variable exists in the zookeeper, or a static variable node corresponding to the target static variable does not exist in the zookeeper.
In an embodiment of the disclosure, when it is detected that a static variable node corresponding to the target static variable does not exist in the zookeeper, static variable data corresponding to the target static variable is acquired and stored locally, wherein the static variable data includes a name attribute and a variable value of the target static variable; saving the initial value of the version number as a second version number to the local; and registering the static variable node according to the local static variable data of the target static variable and the initial value of the version number.
If the node does not exist in the zookeeper, it is indicated that the static variable is not registered in the zookeeper, and at this time, the local application needs to store three attributes of the static variable, including: after initializing the name attribute, the version number, and the variable value, an MD5 (Message-Digest Algorithm) value (hereinafter, u) is obtained, where the name attribute includes a variable name and a class name, the class name is used to distinguish static variables having the same variable name, and the initial value of the version number is 0. Optionally, the name attribute is used as a node name of the static variable node, the initialized data is used as node content, that is, a character string value obtained by performing toJSONString character string processing on the variable value is used as the node content of the static variable node, and the initial value of the version number is used as the version number of the node. If the static variable is not initialized in the memory of the JVM, the value of u is-1, and the node content is null.
In one embodiment of the present disclosure, if the static variable node exists in the zookeeper, the node content and the version number of the static variable node are obtained. Taking the first start of one of the virtual machines as an example, if the version number of the static variable node is an initial value, it indicates that other application instances in the cluster have registered the static variable node, but data in the node has not been modified; if the version number of the static variable node is not the initial value, it indicates that other application instances in the cluster modify the content of the static variable node, so that data synchronization needs to be performed locally. Specifically, the node content is synchronized to the locally corresponding static variable according to the type of the static variable through a java reflection mechanism, and then the variable name + class name of the static variable, the version number acquired on the zookeeper node, and the MD5 value of the node content are locally stored, so that under the condition that the cluster is already running, if the application instance of one JVM performs restart operation, the application instance after restart can be ensured to synchronize the latest static variable data.
Step 103, creating a monitoring thread for the target static variable, and synchronizing the static variable data of the target static variable in the local with the static variable data in the static variable node based on the first version number and the second version number of the target static variable in the local.
In this embodiment, a monitoring event is set for a local application program of the virtual machine to monitor whether a static variable node of each target static variable changes.
In one embodiment of the present disclosure, synchronizing the static variable data of the target static variable locally with the static variable data in the static variable node based on the first version number and the second version number of the target static variable locally includes: and updating the second version number to the first version number and updating the local static variable data to the static variable data in the static variable node when the first version number is larger than the second version number.
The method comprises the steps of monitoring the watchdog of the NodeDataChanged based on each local application, obtaining the content and the version number of a node when monitoring the change of the content and the version number of the node corresponding to a static variable on a zookeeper, comparing whether the version number of the static variable node is consistent with the version number of the static variable stored in the local application, and obtaining the locally corresponding static variable through java reflection and synchronizing the content of the node of the static variable node to the local static variable when the version number of the static variable node is larger than the version number stored in the local application so as to update the version number of the locally stored static variable and the corresponding u value.
In one embodiment of the present disclosure, synchronizing the static variable data of the target static variable locally with the static variable data in the static variable node based on the first version number and the second version number of the target static variable locally includes: when the change of the static variable data of the target static variable in the local is detected, updating the static variable data in the static variable node according to the changed static variable data; and adding one to the first version number and the second version number.
After the node registration is started/completed, the local application creates a listening thread for each target static variable to be synchronized, and the listening thread is executed periodically, for example, once every 5 seconds. Obtaining a variable value of the static variable by reflection through the variable name + class name of the static variable, comparing a locally stored u value with an MD5 value obtained after toJSONString processing is carried out on the currently obtained variable value, judging whether the static variable changes, if the static variable does not change, ending the monitoring, if the static variable changes, updating the node content of a corresponding node in the zookeeper, updating the version number of the corresponding node in the zookeeper by adding 1, and updating the version number and the u value of the local application corresponding to the static variable. Optionally, a distributed lock mode is adopted, static variable nodes corresponding to the target static variables in the zookeeper are modified according to the changed static variable data, wherein the same static variable between the JVMs uses the same lock, different static variables use different locks, and the distributed locks are adopted for coordination, so that only one monitoring thread of one application instance at the same time is enabled to modify the same static variable node of the zookeeper.
The following description will be given taking two virtual machines as an example.
For example, the method can be applied to a system developed based on a springboot, in this example, cluster deployment in a load balancing manner is implemented based on nginx, and some global static variables inside the springboot need to be synchronized into a JVM memory of each cluster node. For example, the existing two JVM virtual machines a and B deploy the same application, and the static variable mapData in the com. The specific process is as follows: A. and B, acquiring a loading class set of the springboot application by the two applications through an AppClassLoader class loader, and determining com.test.TestmapData as a global variable needing to be shared among JVMs through filtering. A. B, inquiring whether a node with a node name com.test: mapData exists in the zookeeper by the two applications, if not, acquiring the value of the mapData through reflection and calculating u (the calculation mode is MD5 (JSONARray. ToJSONString (mapData)), and saving com.test.test: mapData, u and version (the initial value is 0); if the version number of the cookie node is 0, obtaining a mapData object through java reflection according to com.test.15. MapData on the cookie, if the version number is not 0, registering the node with the name of com.test.12. MapData and giving the version number of 0 to the cookie, if the two applications in A, B find that the cookie does not exist in the cookie, the two applications in A, B. Both applications in the cookie are the cookie, monitoring whether the version number of the cookie node is consistent with the version number of the cookie, and monitoring the version number of the cookie node B, and if the version number of the cookie is consistent with the version number of the cookie, monitoring the content of the cookie, and monitoring the version number of the cookie, if the version number of the cookie is not consistent with the version number of the cookie A, monitoring the version number of the cookie B, monitoring the version number of the cookie, and monitoring the version number of the cookie B, and the version number of the cookie. And modify the u value and version number stored locally to the B application. A. The B callback method finally needs to register the watch listening of the com. Fig. 2 is a schematic diagram of synchronization between two virtual machines, and through the above process, on the premise of not modifying a service code of an original springboot project, synchronization of mapData static variables in two applications in A, B can be maintained.
According to the technical scheme of the embodiment of the disclosure, static variable nodes corresponding to target static variables to be monitored in the zookeeper are obtained, a monitoring thread for the target static variables is created, and static variable data of the target static variables in the local are synchronized with static variable data of the static variable nodes based on a first version number and a second version number of the target static variables in the static variable nodes. In addition, global static variables in the original system are automatically discovered by comprehensively utilizing a java class loader and a reflection mechanism, and data synchronization among multiple JVM nodes is guaranteed by utilizing the zookeeper nodes, node version numbers, node data change monitoring and the like, and the synchronization after the nodes are restarted is supported.
Fig. 3 is a schematic structural diagram of a static variable synchronization apparatus of a single-point system according to an embodiment of the present disclosure, and as shown in fig. 3, the static variable synchronization apparatus of the single-point system includes: a determination module 31, an acquisition module 32, and a synchronization module 33.
The determining module 31 is configured to determine, in response to starting of the local application program, a target static variable to be monitored;
an obtaining module 32, configured to obtain a static variable node corresponding to the target static variable in the zookeeper, where the static variable node includes static variable data and a first version number of the target static variable;
and a synchronization module 33, configured to create a listening thread for the target static variable, and synchronize, based on the first version number and the second version number of the target static variable in the local, static variable data of the target static variable in the local with static variable data in the static variable node.
In an embodiment of the present disclosure, the determining module 31 is specifically configured to: acquiring member variables of each class corresponding to the application program and acquiring modifiers of the member variables; determining the member variable of which the modifier meets a preset condition from all the member variables as a static variable; and determining a target static variable from all static variables according to the variable type, the variable name and the class to which the variable belongs.
In an embodiment of the present disclosure, the obtaining module 32 is specifically configured to: when it is detected that no static variable node corresponding to the target static variable exists in the zookeeper, static variable data corresponding to the target static variable is acquired and stored locally, wherein the static variable data comprises a name attribute and a variable value of the target static variable; saving the initial value of the version number as a second version number to the local; and registering the static variable node according to the local static variable data of the target static variable and the initial value of the version number.
In an embodiment of the present disclosure, the synchronization module 33 is specifically configured to: and updating the second version number to the first version number and updating the local static variable data to the static variable data in the static variable node when the first version number is larger than the second version number.
In an embodiment of the present disclosure, the synchronization module 33 is specifically configured to: when the change of the static variable data of the target static variable in the local is detected, updating the static variable data in the static variable node according to the changed static variable data; and adding one to the first version number and the second version number.
In an embodiment of the present disclosure, the updating the static variable data in the static variable node according to the changed static variable data includes: and modifying a static variable node corresponding to the target static variable in the zookeeper according to the changed static variable data in a distributed locking mode.
In an embodiment of the present disclosure, the registering the static variable node according to the local static variable data of the target static variable includes: taking the name attribute as a node name of the static variable node, wherein the name attribute comprises a variable name and a class name; taking the initialized variable value as the node content of the static variable node; and taking the initial value of the version number as a first version number of the static variable node.
The static variable synchronization device of the single-point system provided by the embodiment of the disclosure can execute the static variable synchronization method of any single-point system provided by the embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method. Reference may be made to the description of any method embodiment of the disclosure that may not be described in detail in the embodiments of the apparatus of the disclosure.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 4, the electronic device 600 includes one or more processors 601 and memory 602.
The processor 601 may be a Central Processing Unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in the electronic device 600 to perform desired functions.
The memory 602 may include one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory can include, for example, random Access Memory (RAM), cache memory (or the like). The non-volatile memory may include, for example, read Only Memory (ROM), a hard disk, flash memory, and the like. One or more computer program instructions may be stored on a computer-readable storage medium and executed by processor 601 to implement the methods of the embodiments of the present disclosure above and/or other desired functionality. Various contents such as an input signal, a signal component, a noise component, etc. may also be stored in the computer-readable storage medium.
In one example, the electronic device 600 may further include: an input device 603 and an output device 604, which are interconnected by a bus system and/or other form of connection mechanism (not shown). The input device 603 may also include, for example, a keyboard, a mouse, and the like. The output device 604 may output various information including the determined distance information, direction information, and the like to the outside. The output devices 604 may include, for example, a display, speakers, a printer, and a communication network and remote output devices connected thereto, among others.
Of course, for simplicity, only some of the components of the electronic device 600 relevant to the present disclosure are shown in fig. 4, omitting components such as buses, input/output interfaces, and the like. In addition, electronic device 600 may include any other suitable components depending on the particular application.
In addition to the methods and apparatus described above, embodiments of the present disclosure may also be a computer program product comprising computer program instructions that, when executed by a processor, cause the processor to perform any of the methods provided by embodiments of the present disclosure.
The computer program product may write program code for performing operations for embodiments of the present disclosure in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server.
Furthermore, embodiments of the present disclosure may also be a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, cause the processor to perform any of the methods provided by the embodiments of the present disclosure.
A computer-readable storage medium may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It is noted that, in this document, 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. Also, 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 a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present disclosure, which enable those skilled in the art to understand or practice the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A static variable synchronization method of a single-point system is characterized by comprising the following steps:
responding to the starting of a local application program, and determining a target static variable to be monitored;
obtaining a static variable node corresponding to the target static variable in the zookeeper, wherein the static variable node comprises static variable data and a first version number of the target static variable;
and creating a monitoring thread aiming at the target static variable, and synchronizing the static variable data of the target static variable in the local and the static variable data in the static variable node based on the first version number and the second version number of the target static variable in the local.
2. The method of claim 1, wherein the determining a target static variable to listen for comprises:
acquiring member variables of each class corresponding to the application program and acquiring modifiers of the member variables;
determining the member variable of which the modifier meets a preset condition from all the member variables as a static variable;
and determining a target static variable from all static variables according to the variable type, the variable name and the class of the variable.
3. The method of claim 1, wherein obtaining a static variable node in zookeeper corresponding to the target static variable comprises:
when it is detected that no static variable node corresponding to the target static variable exists in the zookeeper, static variable data corresponding to the target static variable is acquired and stored locally, wherein the static variable data comprises a name attribute and a variable value of the target static variable;
saving the initial value of the version number as a second version number to the local;
and registering the static variable node according to the local static variable data of the target static variable and the initial value of the version number.
4. The method of claim 1, wherein synchronizing static variable data of the target static variable local to the static variable data in the static variable node based on the first version number, the second version number of the target static variable local to comprises:
and updating the second version number to the first version number and updating the local static variable data to the static variable data in the static variable node when the first version number is larger than the second version number.
5. The method of claim 1, wherein synchronizing static variable data local to a target static variable with static variable data in the static variable node based on the first version number, the second version number local to the target static variable, comprises:
when the change of the local static variable data of the target static variable is detected, updating the static variable data in the static variable node according to the changed static variable data;
and adding one to the first version number and the second version number.
6. The method of claim 5, wherein updating the static variable data in the static variable node based on the changed static variable data comprises:
and modifying a static variable node corresponding to the target static variable in the zookeeper according to the changed static variable data in a distributed locking mode.
7. The method of claim 3, wherein said registering the static variable node based on the static variable data local to the target static variable and the version number initial value comprises:
taking the name attribute as a node name of the static variable node, wherein the name attribute comprises a variable name and a class name;
taking the initialized variable value as the node content of the static variable node;
and taking the initial value of the version number as a first version number of the static variable node.
8. A static variable synchronization apparatus for a single point system, comprising:
the determining module is used for responding to the starting of the local application program and determining a target static variable to be monitored;
the acquisition module is used for acquiring a static variable node corresponding to the target static variable in the zookeeper, wherein the static variable node comprises static variable data and a first version number of the target static variable;
and the synchronization module is used for creating a monitoring thread aiming at the target static variable, and synchronizing the local static variable data of the target static variable with the static variable data in the static variable node based on the first version number and the local second version number of the target static variable.
9. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor is used for reading the executable instructions from the memory and executing the instructions to realize the static variable synchronization method of the single-point system of any one of the claims 1 to 7.
10. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the static variable synchronization method of a single point system according to any one of claims 1 to 7.
CN202210806011.3A 2022-07-08 2022-07-08 Static variable synchronization method, device, equipment and storage medium of single-point system Pending CN115309421A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210806011.3A CN115309421A (en) 2022-07-08 2022-07-08 Static variable synchronization method, device, equipment and storage medium of single-point system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210806011.3A CN115309421A (en) 2022-07-08 2022-07-08 Static variable synchronization method, device, equipment and storage medium of single-point system

Publications (1)

Publication Number Publication Date
CN115309421A true CN115309421A (en) 2022-11-08

Family

ID=83856162

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210806011.3A Pending CN115309421A (en) 2022-07-08 2022-07-08 Static variable synchronization method, device, equipment and storage medium of single-point system

Country Status (1)

Country Link
CN (1) CN115309421A (en)

Similar Documents

Publication Publication Date Title
US6618857B1 (en) Method and system for installing software on a computer system
US9996341B2 (en) Infrastructure for the automation of the assembly of schema maintenance scripts
US8812451B2 (en) Programming model for synchronizing browser caches across devices and web services
US8930915B2 (en) System and method for mitigating repeated crashes of an application resulting from supplemental code
US8407694B2 (en) System and method for facilitating installing software
US9274811B1 (en) System and method for cloud provisioning and application deployment
US9069620B2 (en) Creating and deploying service-ready virtual hard disks
US8151256B2 (en) Platform independent registry framework
JP2021002317A (en) Method, apparatus, device and storage medium for upgrading application
US7886035B2 (en) Profile service based deployment configuration
KR20160067180A (en) Methods and apparatus to manage virtual machines
US20110055544A1 (en) Systems and methods for tracking a history of changes associated with software packages and configuration management in a computing system
US8499294B2 (en) Persisting the changes for managed components in an application server
US8087015B2 (en) Assignment of application models to deployment targets
JP7493053B2 (en) Image file generating method, device and computer program
US9690564B2 (en) Runtime detection of software configurations and upgrades
US9697009B2 (en) Method for improving the performance of computers
WO2020010725A1 (en) Method and apparatus for automatically synchronously refreshing browser, and computer device
CN112486552A (en) Server hot update method, device, equipment and storage medium
US8918370B2 (en) Dynamic allocation of program libraries
US7818756B2 (en) SKU determination mechanism and API
CN115309421A (en) Static variable synchronization method, device, equipment and storage medium of single-point system
WO2011157105A2 (en) Method and device for component expansion
CN113448493B (en) Method, electronic device and computer readable medium for backing up data
CN115964061A (en) Plug-in updating method and device, electronic equipment and computer readable storage medium

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