CN107807931B - Method and system for template information management - Google Patents

Method and system for template information management Download PDF

Info

Publication number
CN107807931B
CN107807931B CN201610812601.1A CN201610812601A CN107807931B CN 107807931 B CN107807931 B CN 107807931B CN 201610812601 A CN201610812601 A CN 201610812601A CN 107807931 B CN107807931 B CN 107807931B
Authority
CN
China
Prior art keywords
template
change
memory
changed
server
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.)
Active
Application number
CN201610812601.1A
Other languages
Chinese (zh)
Other versions
CN107807931A (en
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 Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201610812601.1A priority Critical patent/CN107807931B/en
Publication of CN107807931A publication Critical patent/CN107807931A/en
Application granted granted Critical
Publication of CN107807931B publication Critical patent/CN107807931B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method and a system for managing template information, which can provide high-efficiency query service under the conditions of large template information content and more query requirements; and supporting the synchronous operation and concurrency problem after the template is changed in the distributed cluster deployment; and the data source of the query template can be intelligently switched according to the memory performance. The method comprises the following steps: initializing templates in a database into a memory by each server in the distributed cluster for template query and/or change; when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database; and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and the other servers in the distributed cluster change the corresponding template in the memory according to the changed template so as to synchronize the changed template to the other servers in the distributed cluster.

Description

Method and system for template information management
Technical Field
The invention relates to the field of computer technology and software, in particular to a method and a system for managing template information.
Background
With the continuous development of cluster technology, template information services provided by using a distributed cluster mode become more and more extensive. Taking the invoice field as an example, roll-type value-added tax common invoices can be developed in all regions of the whole country at present, but the invoice templates in each region are different, and in addition, the number and the types of invoice printers used in each region are numerous, so that the printers in all the regions need a single set of adaptive invoice templates to ensure the accuracy and effectiveness of invoice printing. Therefore, in the invoice issuing business process, the invoice template service adopts distributed cluster deployment to provide an efficient invoice template obtaining mode.
At present, the template management has a plurality of difficulties, which are as follows:
1. the template information content is large. Taking an invoice as an example, one template information usually includes the layout, the issuing content, the invoice number, the stamp and the like of the invoice in the area;
2. the query demand is large. When a large number of concurrent calls exist, the query performance is sharply reduced;
3. when the template information needs to be changed, the situation that the template information is changed concurrently may exist;
4. other machine service information is not synchronized when the template is modified.
In the prior art, the distributed cluster deployment management template usually stores the template in a Redis cache or a server memory of the distributed cluster. However, the above problems cannot be completely solved no matter the template is stored in the Redis cache or the memory:
if the mode of storing the template into Redis cache is adopted, the problem of synchronization of the modified template can be solved, but because the information content of the template is possibly large, the performance is sharply reduced when a large amount of concurrent calls are carried out; if the template information is stored in the memory, the problem of performance reduction of a large number of concurrent calls can be solved, but the problem of information asynchronism after the template is modified under the condition of distributed deployment cannot be solved. In addition, the template is stored in the memory, and when the number of accesses reaches a certain amount, the system performance is affected, and no corresponding degradation scheme exists, so that the whole template service is unavailable.
Therefore, in distributed cluster deployment, how to provide a highly available query service while ensuring that templates on one of the servers are modified and template information can be accurately and rapidly synchronized by other machines is ensured to be reduced in performance due to frequent use of memory is a problem to be solved at present.
Disclosure of Invention
In view of this, the present invention provides a method and a system for template information management, which can provide efficient template query service under the conditions of large template information content and many query requirements; and supporting the synchronous operation and concurrency problem after the template is changed in the distributed cluster deployment; and the data source of the query template can be intelligently switched according to the memory performance.
To achieve the above object, according to one aspect of the present invention, there is provided a method of template information management.
The template information management method of the invention comprises the following steps: initializing templates in a database into a memory by each server in the distributed cluster for template query and/or change; when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database; and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and the other servers in the distributed cluster change the corresponding template in the memory according to the changed template so as to synchronize the changed template to the other servers in the distributed cluster.
Optionally, the method further comprises: and after the server changes the corresponding template in the memory according to the acquired template change request, adding a change lock mark into the cache, wherein the change lock mark comprises the name and the timestamp of the changed template and the number of servers to be synchronized.
Optionally, after the server changes the corresponding template in the memory according to the obtained template change request, adding a change lock flag to the cache further includes: if the corresponding template in the server memory is changed concurrently, the cache only stores the latest change lock mark of the timestamp after adding the change lock mark into the cache.
Optionally, the method further comprises: the changed template comprises a template change timestamp; after receiving the changed template, other servers in the distributed cluster acquire a change lock mark, then compare the template change timestamp of the changed template with the timestamp of the change lock mark, if the template change timestamp of the changed template is consistent with the timestamp of the change lock mark, change the corresponding template in the memory, otherwise, do not process the corresponding template; and each other server in the distributed cluster reduces the number of the servers needing to be synchronized by one after the corresponding template in the memory is changed according to the changed template, and clears the change lock mark when the number of the servers needing to be synchronized is reduced to zero.
Optionally, the method further comprises: when a template query requirement exists, the server judges whether a change lock mark related to the template to be queried exists in the cache according to the received query request, if so, the template is obtained from the database, otherwise, the template is obtained from the memory.
Optionally, the method further comprises: monitoring the memory use condition of each server in the distributed cluster, acquiring the template from the database according to the template query requirement when the memory use condition exceeds a preset threshold value, and acquiring the template from the memory according to the template query requirement when the memory use condition does not exceed the preset threshold value.
To achieve the above object, according to another aspect of the present invention, there is provided a system for template information management.
The template information management system of the present invention includes: each server and database in the distributed cluster, wherein: initializing templates in a database into a memory by each server in the distributed cluster for template query and/or change; when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database; and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and the other servers in the distributed cluster change the corresponding template in the memory according to the changed template so as to synchronize the changed template to the other servers in the distributed cluster.
Optionally, the system further comprises: a cache module; and after the server changes the corresponding template in the memory according to the acquired template change request, adding a change lock mark into the cache module, wherein the change lock mark comprises the name and the timestamp of the changed template and the number of servers to be synchronized.
Optionally, the cache module is further configured to: if the corresponding template in the memory of the server is changed concurrently, the cache module only stores the latest change lock tag of the timestamp after adding the change lock tag into the cache module.
Optionally, the system is further configured to: the changed template comprises a template change timestamp; after receiving the changed template, other servers in the distributed cluster acquire a change lock mark, then compare the template change timestamp of the changed template with the timestamp of the change lock mark, if the template change timestamp of the changed template is consistent with the timestamp of the change lock mark, change the corresponding template in the memory, otherwise, do not process the corresponding template; and each other server in the distributed cluster reduces the number of the servers needing to be synchronized by one after the corresponding template in the memory is changed according to the changed template, and clears the change lock mark when the number of the servers needing to be synchronized is reduced to zero.
Optionally, the system is further configured to: when a template query requirement exists, the server judges whether a change lock mark related to the template to be queried exists in the cache module according to the received query request, if so, the template is obtained from the database, otherwise, the template is obtained from the memory.
Optionally, the system is further configured to: monitoring the memory use condition of each server in the distributed cluster, acquiring the template from the database according to the template query requirement when the memory use condition exceeds a preset threshold value, and acquiring the template from the memory according to the template query requirement when the memory use condition does not exceed the preset threshold value.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any of the embodiments described above.
According to another aspect of the embodiments of the present invention, there is also provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements the method of any of the above embodiments.
According to the technical scheme of the invention, a large amount of concurrent query services can be provided by initializing the template in the database into the memory; the group communication assembly is used for communication, so that the information of template change can be timely and accurately sent to other servers needing synchronization, and the synchronization operation can be efficiently completed; the changed template is stored in the database, so that the synchronous process of the template can be ensured, and the data in the database can be used; by adding the change lock mark into the cache after the template in the memory is changed, on one hand, the data source inquired during external inquiry can be ensured to be effective data in the database in the synchronization process of changing the template, and on the other hand, other servers in the cluster can be ensured to accurately acquire template synchronization information to complete synchronization operation; in addition, only the latest change lock mark of the timestamp is stored in the cache, so that the synchronous information of the distributed clusters is ensured to be the same information when the template is changed concurrently, and the error of data synchronization is avoided; by monitoring the occupation condition of the memory, the data source queried by the template can be intelligently switched, and the distributed cluster is prevented from being crashed due to the fact that the service condition of the memory of the server exceeds a threshold value.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of the main steps of a method of template information management according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a main flow of synchronizing a changed template to other servers in a distributed cluster in a template information management method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a main part of a system for template information management according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The scheme design of the template information management of the embodiment of the invention is as follows: various types of templates adopt a memory storage mode, so that the service of efficiently inquiring the template information is provided; based on the group communication component, the problem of template information synchronization under distributed cluster deployment is solved, so that the template of any server in the cluster is changed, and the latest template can be quickly and accurately synchronized to other servers under the cluster; the problem of concurrent change of templates is solved based on a cache technology such as a change lock mechanism of Redis; by using the change lock mark, the query data source is dynamically switched to the database before the template information is synchronized, so that the template information obtained by query is consistent and accurate; and monitoring the memory use condition of the current server, and intelligently switching the data source from the memory to the database if the current memory use is more, so that the availability of the distributed cluster is improved.
Fig. 1 is a schematic diagram of main steps of a method of template information management according to an embodiment of the present invention.
As shown in fig. 1, the method for managing template information according to the embodiment of the present invention includes:
step S11: initializing templates in a database into a memory by each server in the distributed cluster for template query and/or change;
step S12: when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database;
step S13: and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and the other servers in the distributed cluster change the corresponding template in the memory according to the changed template so as to synchronize the changed template to the other servers in the distributed cluster.
In addition, the method for managing the template information of the embodiment of the invention further comprises the following steps: and after the server changes the corresponding template in the memory according to the acquired template change request, adding a change lock mark into the cache, wherein the change lock mark comprises the name and the timestamp of the changed template and the number of servers to be synchronized.
If the template in the server memory is concurrently changed, the change lock mark is concurrently added into the cache, but the cache only stores the change lock mark with the latest timestamp display time.
The template after the change includes a template change time stamp. When other servers in the distributed cluster receive the changed template, firstly, the changed lock mark in the cache is obtained, then, the template change timestamp of the changed template is compared with the timestamp of the changed lock mark, if the template change timestamp of the changed template is consistent with the timestamp of the changed lock mark, the corresponding template in the memory is changed, and otherwise, the corresponding template is not processed. And after each other server in the distributed cluster changes the corresponding template in the memory according to the changed template, reducing the number of the servers needing to be synchronized by one, and when the number of the servers needing to be synchronized is reduced to zero, namely the last server completes synchronization, reducing the number of the servers needing to be synchronized by one, and clearing the change lock marks together.
The cache only stores the change lock mark with the latest timestamp display time, namely, the server in the distributed cluster carries out template synchronization according to the template change information, so that the phenomenon of inaccurate template synchronization is prevented.
In the process of synchronizing the template information according to the changed template, if an inquiry request is required, if an external inquiry request is received, in order to ensure that the inquired template data is accurate and latest template data, the inquiry data source is switched to the database, and the template data is not acquired from the memory. Therefore, when a template query requirement exists, the server judges whether a change lock mark related to the template to be queried exists in the cache according to the received query request, if so, the template is obtained from the database, otherwise, the template is obtained from the memory.
In addition, in the process of improving the template query service by the distributed cluster, in order to ensure that the distributed cluster operates effectively, the embodiment of the invention further comprises the step of monitoring the memory use condition of each server in the distributed cluster at regular time or at irregular time. And when the memory use condition exceeds a preset threshold value, acquiring the template from the database according to the template query requirement, and when the memory use condition does not exceed the preset threshold value, acquiring the template from the memory according to the template query requirement.
Fig. 2 is a schematic diagram of a main flow of synchronizing a changed template to other servers in a distributed cluster in a template information management method according to an embodiment of the present invention.
The following describes a detailed flow of the template information management method by taking an invoice template as an example, with reference to fig. 1 and 2. Of course, the invention can also solve the problem of synchronization of other information under distributed deployment, and is not limited to the invoice template.
First, in the embodiment of the present invention, in order to ensure that when a template in a memory of one server is changed, information is timely and accurately sent to other servers in a distributed cluster, each server needs to be connected to the same group name through a group communication component: for example, it may be INVOICE _ TEMPLATE _ JGROUPS. At this time, in the distributed cluster, each server can be used as a client to send information to the servers in the same group, so as to ensure the mutual communication among the servers without maintaining an additional machine used as a server.
The Jgroups used by the group communication component in the embodiment of the invention are reliable group communication tools written by open-source pure java. Which is a reliable multicast communication tool set. Its mode of operation is based on IP Multicast (note that it is not necessary to use IP Multicast here, but JGroups can also be implemented using TCP), but it can be extended in terms of reliability and group membership management. The structure of the system is flexible in design, a protocol stack which is flexible and compatible with various protocols is provided, and different reliability requirements are met for each product. Such a protocol stack may allow a user to define reliability and performance indicators. Jgroups can be used to create a group, where members of the group can send messages to other members.
In addition, in order to reduce the pressure on accessing the database, each server in the distributed cluster initializes the Template information sets in the database, such as the invoice Template information of each region and each printer model in the Template _ List, into the memory for querying and changing. And after each change, the invoice template in the database can be correspondingly modified, and the latest invoice template information is guaranteed to fall to the database.
For example, the Template information in the Template _ List is: TEMP _ a _20150606121212, TEMP _ B _20150606121212, etc., where TEMP _ a _20150606121212 is the template information of the a region and TEMP _ B _20150606121212 is the template information of the B region. Each template information includes the layout, the content of the invoice, the invoice number, the stamp and the like of the invoice in the area.
In the running process of the invoice issuing system, if the information of one template TEMP _ a _20150606121212 needs to be changed (for example, one or more of new addition, modification and deletion), since the change operation occurs in one server in the cluster, the changed invoice template needs to be synchronized into the memory of other servers in the cluster, and the template contents obtained when the template information of the area a is inquired externally are completely consistent.
As shown in fig. 2, first, the S _1 server receives a request for a change operation on the a-region invoice template TEMP _ a _20150606121212, after the change operation is performed on the a-region invoice template, the change template information is stored in the database (i.e. the database is firstly guaranteed to be available), and then a change LOCK flag (for example, Redis _ LOCK _ TEMP _ a _20160606121212_3) is stored in a cache (for example, but not limited to, one of Redis, Memcache, and the like), and each server can read the change LOCK flag through the cache, where the change LOCK flag includes: the name of the template to be changed, the timestamp of the change operation, and the number of servers to be synchronized. The change lock mark mechanism in the cache can ensure the value in the same cache, only one is successfully modified, the number of the servers needing to be synchronized of the change lock mark is reduced by one after each server executes the synchronization operation, and the change lock mark is cleared after all the servers finish the synchronization execution.
The modified INVOICE TEMPLATE (the TEMPLATE information contains the timestamp of the TEMPLATE change) of the area A is sent to other servers under the group INVOICE _ TEMPLATE _ JGROUPS through the sendMessage method of the group communication component: s _2, S _3, etc.
Other servers under group INVOIC _ TEMPLATE _ JGROUPS: and S _2, S _3 and the like, receiving the sent modified template information of the area A by a receive method of the group communication assembly. Taking S _2 server synchronization as an example, the S _2 server first obtains a relevant change LOCK tag from the cache, the template LOCK tag of the a-region is REDIS _ LOCK _ TEMP _ a _20160606121212_3, and when it is verified that the timestamp in the change LOCK tag is consistent with the timestamp of the currently received template change of the modified template, the received modified template information of the a-region is used to overwrite the template information of the a-region in the current server memory. And until the template synchronization update of the current S _2 server is completed, reducing the number of the servers needing to be synchronized in the change lock mark by one: REDIS _ LOCK _ TEMP _ a _20160606121212_ 2. And clearing the change lock mark until the last server is synchronized.
In the embodiment of the invention, if the invoice template in the area A is changed concurrently, only the change lock mark of the last change of the template is stored in the cache: if REDIS _ LOCK _ TEMP _ a _20160606121212_3, REDIS _ LOCK _ TEMP _ a _20160606121313_3, two concurrent changes, then only the LOCK flag with the latest timestamp is stored: REDIS _ LOCK _ TEMP _ a _20160606121313_ 3. If the S _2 server receives TEMP _ A _20160606121212 template change information firstly and finds that the received template change timestamp is smaller than the timestamp in the change lock mark when inquiring the change lock mark of the invoice template in the area A, the template synchronization is not executed, the current change is omitted, and the latest change template is waited; if the S _2 server receives TEMP _ A _20160606121313 template change information firstly, and finds that the timestamps of the change lock marks of the invoice templates of the inquired A area are consistent with the timestamps of the change lock marks of the invoice templates of the inquired A area, the template information of the A area in the memory is updated, and the number of the servers needing to be synchronized in the change lock marks is reduced by one: REDIS _ LOCK _ TEMP _ a _20160606121313_ 2. And clearing the lock mark until the last server completes the synchronization.
When a request for inquiring the invoice template of the area A from the outside exists, the server firstly acquires a change lock mark of the invoice template of the area A in the cache, if the change lock mark of the invoice template of the area A exists, the synchronous updating of the template is probably carried out at the moment, a data source is degraded, namely, a database is inquired, the inquired template information is ensured to be the latest, and the inquiry results of all the servers are consistent; if the change lock mark of the invoice template in the area A does not exist, the invoice template in the area A is indicated to have no change operation, and the query memory is only required to be the latest invoice template. This is to dynamically switch data sources using the change lock flag.
In addition, in the embodiment of the present invention, in order to improve the availability of the distributed template service cluster, the memory usage of the server of the current distributed cluster is monitored in a polling manner, for example, the usage rate is monitored, and if the memory usage rate is monitored to reach a preset threshold, for example, set to K, the query data source is intelligently switched to the database; and if the utilization rate of the memory is reduced to be lower than K, switching the data source back to the memory.
According to the template information management method, the templates in the database are initialized into the memory, so that a large amount of concurrent query services can be provided; the group communication assembly is used for communication, so that the information of template change can be timely and accurately sent to other servers needing synchronization, and the synchronization operation can be efficiently completed; the changed template is stored in the database, so that the synchronous process of the template can be ensured, and the data in the database can be used; by adding the change lock mark into the cache after the template in the memory is changed, on one hand, the data source inquired during external inquiry can be ensured to be effective data in the database in the synchronization process of changing the template, and on the other hand, other servers in the cluster can be ensured to accurately acquire template synchronization information to complete synchronization operation; in addition, only the latest change lock mark of the timestamp is stored in the cache, so that the synchronous information of the distributed clusters is ensured to be the same information when the template is changed concurrently, and the error of data synchronization is avoided; by monitoring the occupation condition of the memory, the data source queried by the template can be intelligently switched, and the distributed cluster is prevented from being crashed due to the fact that the service condition of the memory of the server exceeds a threshold value.
Fig. 3 is a schematic diagram of a main part of a system for template information management according to an embodiment of the present invention.
As shown in fig. 3, a system 30 for template information management according to an embodiment of the present invention includes: servers 301 and databases 302 in a distributed cluster, wherein:
initializing templates in a database 302 to a memory by each server 301 in the distributed cluster for template query and/or change;
when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database 302;
and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and the other servers in the distributed cluster change the corresponding template in the memory according to the changed template so as to synchronize the changed template to the other servers in the distributed cluster.
The system 30 may further include: a buffer module (not shown in the figure); and after the server changes the corresponding template in the memory according to the acquired template change request, adding a change lock mark into the cache module, wherein the change lock mark comprises the name and the timestamp of the changed template and the number of servers to be synchronized.
The cache module is further configured to: if the corresponding template in the memory of the server is changed concurrently, the cache module only stores the latest change lock tag of the timestamp after adding the change lock tag into the cache module.
In addition, the system 30 is further configured to: the changed template comprises a template change timestamp; after receiving the changed template, other servers in the distributed cluster acquire a change lock mark, then compare the template change timestamp of the changed template with the timestamp of the change lock mark, if the template change timestamp of the changed template is consistent with the timestamp of the change lock mark, change the corresponding template in the memory, otherwise, do not process the corresponding template; and each other server in the distributed cluster reduces the number of the servers needing to be synchronized by one after the corresponding template in the memory is changed according to the changed template, and clears the change lock mark when the number of the servers needing to be synchronized is reduced to zero.
The system 30 may also be used to: when a template query requirement exists, the server judges whether a change lock mark related to the template to be queried exists in the cache module according to the received query request, if so, the template is obtained from the database 302, otherwise, the template is obtained from the memory.
In addition, the system 30 may also be used to: monitoring the memory use condition of each server 301 in the distributed cluster, acquiring a template from the database according to the template query requirement when the memory use condition exceeds a preset threshold, and acquiring the template from the memory according to the template query requirement when the memory use condition does not exceed the preset threshold.
Monitoring the memory use condition of each server in the distributed cluster, acquiring the template from the database 302 according to the template query requirement when the memory use condition exceeds a preset threshold value, and acquiring the template from the memory according to the template query requirement when the memory use condition does not exceed the preset threshold value.
As can be seen from the above description, by initializing the templates in the database into the memory, a large number of concurrent query services can be provided; the group communication assembly is used for communication, so that the information of template change can be timely and accurately sent to other servers needing synchronization, and the synchronization operation can be efficiently completed; the changed template is stored in the database, so that the synchronous process of the template can be ensured, and the data in the database can be used; by adding the change lock mark into the cache after the template in the memory is changed, on one hand, the data source inquired during external inquiry can be ensured to be effective data in the database in the synchronization process of changing the template, and on the other hand, other servers in the cluster can be ensured to accurately acquire template synchronization information to complete synchronization operation; in addition, only the latest change lock mark of the timestamp is stored in the cache, so that the synchronous information of the distributed clusters is ensured to be the same information when the template is changed concurrently, and the error of data synchronization is avoided; by monitoring the occupation condition of the memory, the data source queried by the template can be intelligently switched, and the distributed cluster is prevented from being crashed due to the fact that the service condition of the memory of the server exceeds a threshold value.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (14)

1. A method for template information management, comprising:
initializing templates in a database into a memory by each server in the distributed cluster for template query and/or change;
when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database; after the server changes the corresponding template in the memory according to the acquired template change request, adding a change lock mark into the cache;
and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and under the condition that the other servers in the distributed cluster confirm that the template change timestamp of the changed template is consistent with the timestamp of the change lock mark, the corresponding template in the memory is changed according to the changed template, so that the changed template is synchronized to other servers in the distributed cluster.
2. The method of claim 1, wherein the change lock flag comprises a name of a template in which the change occurred, a timestamp, and a number of servers to be synchronized.
3. The method according to claim 2, wherein the step of adding a change lock tag to the cache after the server changes the corresponding template in the memory according to the obtained template change request further comprises:
if the corresponding template in the server memory is changed concurrently, the cache only stores the latest change lock mark of the timestamp after adding the change lock mark into the cache.
4. The method of claim 2, further comprising:
and after each other server in the distributed cluster changes the corresponding template in the memory according to the changed template, reducing the number of the servers needing to be synchronized by one, and clearing the change lock mark when the number of the servers needing to be synchronized is reduced to zero.
5. The method of claim 2, further comprising:
when a template query requirement exists, the server judges whether a change lock mark related to the template to be queried exists in the cache according to the received query request, if so, the template is obtained from the database, otherwise, the template is obtained from the memory.
6. The method of claim 1, further comprising:
monitoring the memory use condition of each server in the distributed cluster, acquiring the template from the database according to the template query requirement when the memory use condition exceeds a preset threshold value, and acquiring the template from the memory according to the template query requirement when the memory use condition does not exceed the preset threshold value.
7. A system for template information management, comprising: each server, database, cache module in distributed cluster, wherein:
initializing templates in a database into a memory by each server in the distributed cluster for template query and/or change;
when a template change requirement exists, the server changes a corresponding template in the memory according to the obtained template change request, and stores the changed template in the database; after the server changes the corresponding template in the memory according to the acquired template change request, adding a change lock mark into the cache module;
and then, the changed template is sent to other servers in the distributed cluster by using the group communication component, and under the condition that the other servers in the distributed cluster confirm that the template change timestamp of the changed template is consistent with the timestamp of the change lock mark, the corresponding template in the memory is changed according to the changed template, so that the changed template is synchronized to other servers in the distributed cluster.
8. The system of claim 7, wherein the change lock flag comprises a name of a template where the change occurred, a timestamp, and a number of servers to be synchronized.
9. The system of claim 8, wherein the caching module is further configured to:
if the corresponding template in the memory of the server is changed concurrently, the cache module only stores the latest change lock tag of the timestamp after adding the change lock tag into the cache module.
10. The system of claim 8, wherein the system is further configured to:
and after each other server in the distributed cluster changes the corresponding template in the memory according to the changed template, reducing the number of the servers needing to be synchronized by one, and clearing the change lock mark when the number of the servers needing to be synchronized is reduced to zero.
11. The system of claim 8, wherein the system is further configured to:
when a template query requirement exists, the server judges whether a change lock mark related to the template to be queried exists in the cache module according to the received query request, if so, the template is obtained from the database, otherwise, the template is obtained from the memory.
12. The system of claim 7, wherein the system is further configured to:
monitoring the memory use condition of each server in the distributed cluster, acquiring the template from the database according to the template query requirement when the memory use condition exceeds a preset threshold value, and acquiring the template from the memory according to the template query requirement when the memory use condition does not exceed the preset threshold value.
13. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
14. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201610812601.1A 2016-09-09 2016-09-09 Method and system for template information management Active CN107807931B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610812601.1A CN107807931B (en) 2016-09-09 2016-09-09 Method and system for template information management

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610812601.1A CN107807931B (en) 2016-09-09 2016-09-09 Method and system for template information management

Publications (2)

Publication Number Publication Date
CN107807931A CN107807931A (en) 2018-03-16
CN107807931B true CN107807931B (en) 2020-09-01

Family

ID=61576261

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610812601.1A Active CN107807931B (en) 2016-09-09 2016-09-09 Method and system for template information management

Country Status (1)

Country Link
CN (1) CN107807931B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108595502B (en) * 2018-03-19 2021-06-22 网宿科技股份有限公司 Method, apparatus and computer readable storage medium for evaluating database service performance
CN111126025A (en) * 2019-12-11 2020-05-08 航天信息股份有限公司 Electronic document format file template management method and system
CN113760871B (en) * 2020-08-17 2024-04-16 北京沃东天骏信息技术有限公司 Template synchronization method and device
CN112118298A (en) * 2020-09-03 2020-12-22 杭州海康威视数字技术股份有限公司 Configuration management method and device for distributed service

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105096172A (en) * 2015-06-12 2015-11-25 北京京东尚科信息技术有限公司 Electronic invoice generating and processing method and system based on e-commerce platform
CN105487859A (en) * 2015-11-25 2016-04-13 北京工业大学 Template based WEB deployment method for big data components

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030088536A1 (en) * 2001-04-09 2003-05-08 Afshin Behnia Platform within an organization for providing knowledge management and decision support services
CN101540700A (en) * 2009-04-10 2009-09-23 成都市华为赛门铁克科技有限公司 Configuration linkage method, system, terminal and network equipment management server
CN102096596B (en) * 2010-11-29 2013-11-06 华中科技大学 Cloud computing service Cache system based on internal memory template of virtual machine
CN102880475B (en) * 2012-10-23 2015-08-12 普元信息技术股份有限公司 Based on the real-time event disposal system of cloud computing and method in computer software
CN104092777B (en) * 2014-07-29 2017-12-26 深圳市富途网络科技有限公司 The method and its system of the layout setting and server sync storage of client
CN104158905B (en) * 2014-08-28 2018-04-20 北京京东尚科信息技术有限公司 The creation method of web container
CN104202440B (en) * 2014-09-02 2016-04-13 腾讯科技(深圳)有限公司 A kind of method of marking terminal, server and system
CN105933136B (en) * 2015-11-30 2019-09-17 中国银联股份有限公司 A kind of resource regulating method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105096172A (en) * 2015-06-12 2015-11-25 北京京东尚科信息技术有限公司 Electronic invoice generating and processing method and system based on e-commerce platform
CN105487859A (en) * 2015-11-25 2016-04-13 北京工业大学 Template based WEB deployment method for big data components

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
H银行国际贸易供应链前端系统批准发票融资交易模块的设计与实现;王晓珺;《中国优秀硕士学位论文全文数据库信息科技辑》;20140515;第I138-904页 *

Also Published As

Publication number Publication date
CN107807931A (en) 2018-03-16

Similar Documents

Publication Publication Date Title
CN107807931B (en) Method and system for template information management
CN107528816B (en) Processing method, management system and server of ID in distributed database
CN101650741B (en) Method and system for updating index of distributed full-text search in real time
US7779418B2 (en) Publisher flow control and bounded guaranteed delivery for message queues
CN109379432B (en) Data processing method, device, server and computer readable storage medium
US10862965B2 (en) System and method for topics implementation in a distributed data computing environment
CN111143382B (en) Data processing method, system and computer readable storage medium
CN105814544B (en) System and method for supporting persistent partition recovery in a distributed data grid
US7818386B2 (en) Repeatable message streams for message queues in distributed systems
CN111404730B (en) State synchronization method and device of virtual router, electronic equipment and storage medium
TWI671643B (en) Configuration change method, device and system
CN108664660A (en) Distributed implementation method, apparatus, equipment and the storage medium of time series database
CN106777311B (en) Flight space state caching method and system
CN112084258A (en) Data synchronization method and device
CN108664520B (en) Method and device for maintaining data consistency, electronic equipment and readable storage medium
CN101706781A (en) Method and system for centralized management of database caches
EP3172682B1 (en) Distributing and processing streams over one or more networks for on-the-fly schema evolution
CN111737204B (en) File directory traversal method, device, equipment and medium
CN110417882B (en) Method and device for determining main node and storage medium
CN110795322A (en) Service monitoring method and device, computer equipment and storage medium
CN101605301A (en) A kind of group system and request message distribution method that carries out the multinode transaction
US8201017B2 (en) Method for queuing message and program recording medium thereof
CN106792825B (en) A kind of management method of distributed network equipment
CN108156015B (en) Data updating method and device
CN107451154B (en) Data table processing method, device and system

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
GR01 Patent grant
GR01 Patent grant