WO2016082594A1 - Data update processing method and apparatus - Google Patents

Data update processing method and apparatus Download PDF

Info

Publication number
WO2016082594A1
WO2016082594A1 PCT/CN2015/087950 CN2015087950W WO2016082594A1 WO 2016082594 A1 WO2016082594 A1 WO 2016082594A1 CN 2015087950 W CN2015087950 W CN 2015087950W WO 2016082594 A1 WO2016082594 A1 WO 2016082594A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
shared memory
update
keyword
updated
Prior art date
Application number
PCT/CN2015/087950
Other languages
French (fr)
Chinese (zh)
Inventor
朱明全
毛坤伦
孙兴强
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016082594A1 publication Critical patent/WO2016082594A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication

Definitions

  • the present invention relates to the field of communications, and in particular, to a data update processing method and apparatus.
  • control planes With the development of the Internet, the functions of routers are increasingly complex, and centralized control plane processing can no longer meet the needs of operators.
  • the distributed and multi-process implementation of control planes has become a development trend of the devices. The openness, diversity, and various services of traditional telecommunications have been continually migrated to IP bearers, resulting in the rapid launch of various new IP protocols and new services.
  • the multi-process implementation In order to support the cutting of the protocol function, independent release version, and independent upgrade, the multi-process implementation is implemented, and the process is divided very finely, and even each protocol runs in a separate process space. Support protocol distributed operation, different protocol processes can run in different protocol processing units.
  • the multi-process implementation method also solves the problem that the software components fail to interact with each other, avoiding the difficulty of developing functions and the stability of the version, and the slow convergence of the faults as the software scales up.
  • FIG. 1 is a schematic diagram of a data synchronization model in the related art. As shown in FIG. 1 , in a manner of using a message to perform inter-process data synchronization, each process space applies for a memory to store a piece of data.
  • each process uses shared memory to share access to data, it can greatly reduce system memory consumption.
  • the shared memory supported by the operating system only provides the process to actively read and write to the shared memory.
  • the related process cannot be passively aware in time, and only the changed data can be obtained in the subsequent active query. At this time, it is impossible to know which specific information fields have changed, and what is the value before the change. .
  • This method is difficult to meet the implementation needs of some scenarios. For example, after the IP address is configured on the port and the IP information is written to the shared memory, the routing protocol process needs to detect the IP add event on the port and recalculate the route. Insert the fiber into the PPP port and update the physical UP status of the PPP port.
  • the PPP process needs to be aware of the physical UP event and negotiate with the peer device to establish a link. If each protocol periodically polls and checks the change of data, if the timing period is too long, the timeliness cannot be guaranteed. If the timing period is too short, the system performance is greatly consumed, which affects the processing capability of the device for normal services. And through the polling method, after the data is repaired or deleted, it can be found that the data before or before the modification has not been obtained.
  • the present invention provides a data update processing method and apparatus, so as to at least solve the problem that the multi-process uses the shared memory in the related art, and cannot sense the data change in the shared memory in time.
  • a data update processing method including: updating data in a shared memory; transmitting a completion message to the one or more threads that the update of the data in the shared memory is completed; The completion message provides the updated data in the shared memory to the one or more threads for service processing.
  • the method before updating the data in the shared memory, the method further includes: sending an indication message to the one or more threads, wherein the indication message is used to indicate the one or more threads The data is in an updated state.
  • a data update processing method including: receiving a completion message for completing update of data in a shared memory; and accessing the data after completion of updating in the shared memory according to the completion message.
  • the method before receiving the completion message of the data update completion in the shared memory, the method further includes: receiving an indication message indicating that the data in the shared memory is in an update state;
  • the identification is deleted after receiving a completion message for the completion of the update of the data in the shared memory.
  • the method before the updating of the data in the shared memory according to the completion message, the method further includes at least one of the following: receiving the data when the data in the shared memory is updated to add data.
  • An indication message of a keyword having the data creating null data corresponding to the keyword of the data, deleting the null data after adding data to the shared memory, and updating the data in the shared memory to If the data is modified or deleted, the indication message carrying the keyword of the data is received, the old data before the update in the shared memory is obtained according to the keyword of the data, and the backup is performed, and the shared memory is modified or deleted.
  • a data update processing apparatus comprising: an update module configured to update data in a shared memory; and a first sending module configured to send a pair to one or more threads a completion message of the data update completion in the memory; providing a sending module, configured to provide the updated data in the shared memory to the one or more threads for service processing according to the completion message.
  • the apparatus further includes: a second sending module, configured to send an indication message to the one or more threads, wherein the indication message is used to indicate the one or more threads The data is in an updated state.
  • a data update processing apparatus comprising: a first receiving module configured to receive a completion message of completion of data update in a shared memory; and an access module configured to be based on the completion message Access the data in the shared memory after the update is complete.
  • the device further includes: a second receiving module, configured to receive an indication message for indicating that the data in the shared memory is in an updated state; and an establishing module, configured to establish, according to the indication message The identifier is in an update state; the deletion module is configured to delete the identifier after receiving the completion message for completing the update of the data in the shared memory.
  • the apparatus further includes at least one of the following: a first processing module configured to receive an indication of a keyword carrying the data in a case where data in the shared memory is updated to add data a message, creating null data corresponding to the keyword of the data, deleting the null data after adding data to the shared memory is completed; and the second processing module is configured to update the data in the shared memory to be modified or When the data is deleted, the indication message carrying the keyword of the data is received, the old data before the update in the shared memory is acquired according to the keyword of the data, and the backup is performed, and the data is modified or deleted in the shared memory.
  • a first processing module configured to receive an indication of a keyword carrying the data in a case where data in the shared memory is updated to add data a message, creating null data corresponding to the keyword of the data, deleting the null data after adding data to the shared memory is completed
  • the second processing module is configured to update the data in the shared memory to be modified or When the data is deleted, the indication message carrying the keyword of the data is received
  • the third processing module is configured to receive an indication message carrying the keyword of the data when the data in the shared memory is updated to be newly added or restarted by one or more threads.
  • the data is created according to the keyword tag of the data as the overall synchronization phase, and after all the data in the shared memory is created, After the volume synchronization completion message, all created tags are deleted; the fourth processing module is configured to create null data for prohibiting access to data from the shared memory when the data in the shared memory is updated to the Source process restart. Or, an aging flag on the tag to continue accessing the data in the shared memory.
  • updating data in the shared memory is used; sending a completion message to the one or more threads for updating the data in the shared memory; and updating the updated data in the memory according to the completion message Providing the one or more threads for service processing, and solving the problem that the multi-process uses the shared memory in the related technology, the data change in the shared memory cannot be sensed in time, so that the state of the data in the shared memory can be known in time.
  • FIG. 1 is a schematic diagram of a data synchronization model in the related art
  • FIG. 2 is a flowchart 1 of a data update processing method according to an embodiment of the present invention.
  • FIG. 3 is a second flowchart of a data update processing method according to an embodiment of the present invention.
  • FIG. 4 is a block diagram 1 of a data update processing apparatus according to an embodiment of the present invention.
  • FIG. 5 is a block diagram 1 of a data update processing apparatus in accordance with a preferred embodiment of the present invention.
  • FIG. 6 is a block diagram 2 of a data update processing apparatus according to an embodiment of the present invention.
  • FIG. 7 is a block diagram 2 of a data update processing apparatus in accordance with a preferred embodiment of the present invention.
  • FIG. 8 is a block diagram 3 of a data update processing apparatus in accordance with a preferred embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a data synchronization model according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of data addition in data synchronization according to an embodiment of the present invention.
  • FIG. 11 is a schematic diagram of data modification in data synchronization according to an embodiment of the present invention.
  • FIG. 12 is a schematic diagram of data deletion in data synchronization according to an embodiment of the present invention.
  • FIG. 13 is a schematic diagram of overall synchronization in data synchronization according to an embodiment of the present invention.
  • FIG. 14 is a first schematic diagram of a source restart in data synchronization according to an embodiment of the present invention.
  • FIG. 15 is a second schematic diagram of a source restart in data synchronization according to an embodiment of the present invention.
  • 16 is a first schematic diagram of a data synchronization model deployment according to an embodiment of the present invention.
  • 17 is a second schematic diagram of a data synchronization model deployment according to an embodiment of the present invention.
  • FIG. 18 is a third schematic diagram of a data synchronization model deployment according to an embodiment of the present invention.
  • FIG. 19 is a fourth schematic diagram of a data synchronization model deployment according to an embodiment of the present invention.
  • 20 is a fifth diagram of a data synchronization model deployment in accordance with an embodiment of the present invention.
  • FIG. 2 is a flowchart 1 of a data update processing method according to an embodiment of the present invention. As shown in FIG. 2, the flow includes the following steps:
  • Step S202 updating data in the shared memory
  • Step S204 sending a completion message to the one or more threads that the update of the data in the shared memory is completed;
  • Step S206 the updated data in the shared memory is provided to the one or more threads for service processing according to the completion message.
  • the method before updating the data in the shared memory, the method further includes: sending an indication message to the one or more threads, wherein the indication message is used to indicate that the one or more threads are updated. status.
  • FIG. 3 is a second flowchart of a data update processing method according to an embodiment of the present invention. As shown in FIG. 3, the method includes:
  • Step S302 receiving a completion message for completing the update of the data in the shared memory
  • Step S304 accessing the data after the update in the shared memory is completed according to the completion message.
  • receiving before receiving the completion message of the data update completion in the shared memory, receiving is used to indicate that the data in the shared memory is in an updated state.
  • the indication message is established according to the indication message; after receiving the completion message for completing the update of the data in the shared memory, deleting the identifier, and then determining the updated data of the data bits in the shared memory.
  • At least one of the following may be included: receiving an indication of the keyword carrying the data if the data in the shared memory is updated to add data Message, creating null data corresponding to the keyword of the data, adding data to the shared memory After deleting the null data; when updating the data in the shared memory to modify or delete the data, receiving an indication message carrying the keyword of the data, and acquiring the pre-update in the shared memory according to the keyword of the data
  • the old data is backed up, and after the shared memory is modified or deleted, the old data is deleted; when the data in the shared memory is updated to one or more threads newly added or restarted, receiving the data carrying the data
  • the indication message of the keyword, according to the keyword of the data, the data is created in the overall synchronization phase, and all the created tags are deleted after receiving the overall synchronization completion message after all the data in the shared memory is created; in the shared memory In the case where the data update in the source process is restarted,
  • the embodiment of the present invention provides a data update processing device, which is used to implement the foregoing embodiments and preferred embodiments, and has not been described again.
  • the term "module” may implement a combination of software and/or hardware of a predetermined function.
  • the apparatus described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware, is also possible and contemplated.
  • FIG. 4 is a block diagram of a data update processing apparatus according to an embodiment of the present invention. As shown in FIG. 4, the method includes an update module 42, a first sending module 44, and a providing transmitting module 46. The following briefly describes each module.
  • An update module 42 configured to update data in the shared memory
  • the first sending module 44 is configured to send a completion message to the one or more threads that the update of the data in the shared memory is completed;
  • the sending module 46 is configured to provide the updated data in the shared memory to the one or more threads for service processing according to the completion message.
  • FIG. 5 is a block diagram 1 of a data update processing apparatus according to a preferred embodiment of the present invention. As shown in FIG. 5, the apparatus further includes:
  • the second sending module 52 is configured to send an indication message to the one or more threads, wherein the indication message is used to indicate that the one or more threads are in an updated state.
  • FIG. 6 is a block diagram 2 of a data update processing apparatus according to an embodiment of the present invention. As shown in FIG. 6, the method includes:
  • the first receiving module 62 is configured to receive a completion message for completing the update of the data in the shared memory
  • the access module 64 is configured to access the data after the update in the shared memory is completed according to the completion message.
  • FIG. 7 is a block diagram 2 of a data update processing apparatus according to a preferred embodiment of the present invention. As shown in FIG. 7, the apparatus further includes:
  • the second receiving module 72 is configured to receive an indication that the data in the shared memory is in an updated state Message
  • the establishing module 74 is configured to establish, according to the indication message, an identifier that the data is in an updated state
  • the delete module 76 is configured to delete the identity after receiving the completion message for the completion of the update of the data in the shared memory.
  • FIG. 8 is a block diagram 3 of a data update processing apparatus according to a preferred embodiment of the present invention. As shown in FIG. 8, the apparatus further includes at least one of the following:
  • the first processing module 82 is configured to: when the data in the shared memory is updated to add data, receive an indication message carrying the keyword of the data, and create null data corresponding to the keyword of the data, where After the shared memory is added, the empty data is deleted;
  • the second processing module 84 is configured to receive an indication message carrying the keyword of the data when the data in the shared memory is updated to modify or delete data, and obtain the update in the shared memory according to the keyword of the data.
  • the old data is backed up, and after the shared memory is modified or deleted, the old data is deleted;
  • the third processing module 86 is configured to, when the data in the shared memory is updated to be newly added or restarted by one or more threads, receive an indication message carrying the keyword of the data, and mark the keyword according to the data as The data has been created during the overall synchronization phase, and all created tags are deleted after receiving the overall synchronization completion message after all the data in the shared memory is created.
  • the fourth processing module 88 is configured to: create a blank data for prohibiting access to data from the shared memory when the data in the shared memory is updated to the source process, or to continue to access the shared memory The aging mark of the data.
  • the embodiment of the present invention is further described by taking one or more threads as a Reader as an example.
  • the optional embodiment enables related processes that need to access the shared memory to sense the events of adding, modifying, and deleting data in the shared memory in time, and control the access of the data in the shared memory according to the event.
  • the process can not access the data in the shared memory before the data addition event is perceived, and the data can be accessed only after the data addition event is perceived; before the data modification event is perceived, the process can only access the data before the modification, and the data is perceived.
  • the process can access the modified data; before the data deletion event is sensed, the process You can access the data in the shared memory, and after you perceive the data deletion event, you cannot access the data in the shared memory.
  • the process also controls the access of the process to the shared memory.
  • the method can participate in the process of adding, modifying, and deleting shared memory data, so that the process can perform related logic processing in time, and can obtain required data information during processing.
  • the optional embodiment provides a data synchronization method based on shared memory, and the data is sent in the shared memory.
  • the relevant process can be notified in time, and the coordination process can perform relevant logic processing in time, that is, the required data can be accessed during processing, and new data can be acquired for the new data addition; for the data modification, the modification can be obtained.
  • Pre- and modified data; for data deletion, data that is about to be deleted can be obtained. While reducing the memory overhead, it also satisfies the requirements of various application scenarios, and achieves the same effect as the method of synchronizing data between processes using messages.
  • Source Source the source of data generation, accepts Writer and Reader registration.
  • the writer Writer is responsible for writing the data generated by the Source to the shared memory.
  • Reader Reader a process (or thread) that needs to access shared memory data, such as protocol processes.
  • Source is the source of data generation. It can be a separate process in which a source of data is stored. Source accepts the registration of Writer and Reader, and maintains the registration information of Writer and Reader on each CPU in CPU units. There can be multiple Readers on a single CPU, but only one Writer can exist. When the source data in the Source is added, modified, or deleted, the data is synchronized to the Reader through the shared memory mode, so that the Reader can perceive the data addition, modification, and deletion events.
  • the Writer is the process (or thread) responsible for writing to the shared memory. When the source data is added, modified, or deleted, the data changes are written to the shared memory. Reader is a process that needs to access shared memory data and has read-only access to shared memory.
  • LOD Local Old Database
  • LND Local Null Database
  • FIG. 9 is a schematic diagram of a data synchronization model according to an embodiment of the present invention. As shown in FIG. 9, when data is added, modified, or deleted in the Source, each Reader is first notified to perform preprocessing. After all Reader preprocessing is completed, the Writer is notified to update the sharing. The data in the memory, after the Writer operation is completed, the Source notifies each Reader that the update is completed, and the Reader performs the corresponding business logic processing.
  • FIG. 10 is a schematic diagram of data addition in data synchronization according to an embodiment of the present invention.
  • the source sends a keyword of the data to the Reader through a message, and notifies the Reader to create “empty data” corresponding to the keyword in the LND.
  • the Source notifies the Writer to create new data in the shared memory, after the completion of the Source Then notify Reader to complete the creation, Reader does the new data creation logic processing, and deletes the "empty data" corresponding to the keyword, indicating that the data corresponding to the keyword has been created, and the subsequent Reader This data can be accessed directly from shared memory.
  • FIG. 11 is a schematic diagram of data modification in data synchronization according to an embodiment of the present invention.
  • the source sends a keyword of the data to the Reader through a message, and the Reader queries the old data before the modification in the shared memory by using a keyword. ", and back up the "old data” to the LOD local to the Reader process to indicate that the data in the shared memory is in an unstable state and is changing (Reader can only query the LOD when there is "old data” in the LOD)
  • the "old data” the corresponding data in the shared memory is not visible).
  • the Source notifies the Writer to modify the data in the shared memory, and then notifies the Reader that the data modification is completed.
  • the Reader performs the data modification logic processing (at this time, the "old data” in the LOD and the modified data in the shared memory can be accessed,) And delete the "old data” backed up in the LOD, indicating that the data corresponding to the keyword has been modified, and is currently in a stable state, and the subsequent Reader can directly access the data from the shared memory.
  • FIG. 12 is a schematic diagram of data deletion in data synchronization according to an embodiment of the present invention.
  • the process of data backup performed by Reader is similar to the backup process performed when data is modified.
  • Source sends the data key to Reader through the message.
  • Reader queries the data from the shared memory by keyword and backs up the data to the local LOD of the Reader process to indicate that the data in the shared memory is unstable. delete.
  • the Source notifies the Writer to delete the data in the shared memory, and then notifies the Reader that the deletion is completed.
  • the Reader performs the data deletion logic processing (in this case, the data information to be deleted is queried), and the backup data in the LOD is deleted, indicating the key.
  • the data corresponding to the word has been deleted. Subsequent Reader will not query the data corresponding to the keyword in the shared memory.
  • FIG. 13 is a schematic diagram of overall synchronization in data synchronization according to an embodiment of the present invention. As shown in FIG. 13, for a case where data already exists in the shared memory and a new Reader is added, the Reader has not perceived the creation of the corresponding data. There is no new data creation logic processing, and the Reader is not allowed to access the data in the shared memory at this time. The data that already exists in the shared memory needs to be synchronized to the Reader once, and the Reader perceives the data creation event before accessing the data in the shared memory.
  • the synchronization status is marked as the overall synchronization phase, and the Source directly sends the existing data key to the Reader, so that the Reader perceives the creation event.
  • Reader creates a corresponding record locally, with the "created" tag.
  • Reader can query the data in shared memory, otherwise the data in shared memory is not visible to the Reader.
  • the Source notifies the Reader that all the data has been created, and notifies the Reader that the synchronization is complete.
  • the Reader will synchronize the status flag to change the synchronization phase and delete all the local "created” records.
  • the Source deletes the Reader from the registration list, and the data can continue to synchronize with other Readers.
  • the Reader gets up, it re-registers with the Source, and the Source synchronizes the data to the Reader according to the overall synchronization process.
  • Source can synchronize data to other Readers without affecting other Readers.
  • Source restart For the restart of the source process, the following two implementation modes can be used according to the scenario.
  • FIG. 14 is a schematic diagram 1 of a source restart in data synchronization according to an embodiment of the present invention.
  • the reader perceives that the Source exits, it traverses all the data in the shared memory, performs data deletion logic processing, and creates in the LND. Corresponding "empty data", subsequent access to the corresponding data from shared memory.
  • the Writer senses that the Source exits, it puts an "aging" flag on the data in the shared memory.
  • the Source process is restarted, the data is restored and a "data addition" synchronization process is performed to Reader and Writer.
  • the source sends the keyword of the data to the Reader through the message.
  • the Reader creates the "empty data” corresponding to the keyword in the LND.
  • the processing step is skipped.
  • the Source After all Reader has created “empty data”, the Source notifies the Writer to create data in the shared memory. If the corresponding data already exists in the shared memory, the data in the shared memory is directly updated, and the "aging" of the data is removed. mark. After the Writer finishes creating or updating the shared memory data, the Source notifies the Reader to complete the creation. The Reader performs the data creation logic processing and deletes the corresponding "empty data", indicating that the data corresponding to the keyword has been created, and the subsequent Reader can directly Access this data from shared memory.
  • the data in the Source is restored, and after the synchronization is completed, the Reader and the Writer are notified to perform "junk” data processing, the Reader deletes the "empty data” still existing in the LND, and the Writer deletes the data in the shared memory that still has the "aging" flag.
  • FIG. 15 is a second schematic diagram of a source restart in data synchronization according to an embodiment of the present invention.
  • the reader perceives that the source exits, it traverses all data in the shared memory, and locally creates a corresponding record, and puts on “aging”. Marked, you can continue to access data in shared memory.
  • the Writer senses that the Source exits, it puts an "aging" flag on the data in the shared memory.
  • the source process is restarted, the data is restored again, and the "data addition” or “data modification” synchronization process is performed to the Reader and the Writer.
  • the Source sends the keyword of the data to the Reader through the message.
  • the Source notifies the Writer to create data in the shared memory. At this time, if the corresponding data already exists in the shared memory, the data in the shared memory is directly updated, and the "aging" flag of the data is removed. After the Writer finishes creating or updating the shared memory data, the Source notifies the Reader to create or update.
  • Reader does the data creation logic processing and deletes the corresponding "empty data”; for the existence of "old data” In the case, Reader does the data modification logic and deletes the "old data”.
  • the Reader is first notified to perform "junk” data processing, and the Reader performs the delete logic processing on the data still having the "aged” mark record (at this time, the data in the shared memory can still be queried), and Delete the "aging” tag record.
  • Source notifies Writer to perform "junk” data processing, and deletes the data of "aged” mark in shared memory.
  • FIG. 16 is a first schematic diagram of a data synchronization model deployment according to an embodiment of the present invention.
  • a shared memory writer process (Writer) is independently set up, and is responsible for operating shared memory data. Multiple Readers can be in the same process or in different processes. The process in which Reader is located and the Writer process map to the same shared memory space.
  • FIG. 17 is a schematic diagram 2 of a data synchronization model deployment according to an embodiment of the present invention.
  • a Writer and a Source are in the same process, and a Writer is used as a thread in the Source process to operate the shared memory.
  • Multiple Readers can be in the same process or distributed in different processes. The process in which Reader is located and the Writer process are mapped to the same shared memory space.
  • FIG. 18 is a third schematic diagram of a data synchronization model deployment according to an embodiment of the present invention.
  • a Writer and a Source on an R-CPU are in the same process, and a separate Writer is deployed in the L-CPU.
  • the process provides data services for Reader on each CPU.
  • Two threads in process B enable shared memory at the same time, but only occupy a linear space. Source still sees two Readers.
  • FIG. 19 is a schematic diagram 4 of a data synchronization model deployment according to an embodiment of the present invention.
  • each CPU independently sets a shared memory write process (Writer), which is responsible for shared memory writes on respective CPUs. Operation, providing data services for Reader on their respective CPUs.
  • Writer shared memory write process
  • FIG. 20 is a schematic diagram 5 of a data synchronization model deployment according to an embodiment of the present invention.
  • different data may have different Sources, but a Writer is responsible for writing shared memory.
  • multiple Sources can be in different processes or in different threads of the same process.
  • multiple Sources can be on the same CPU or on different CPUs. The deployment mode for two sources in a centralized environment when they are in different processes.
  • computing devices which may be centralized on a single computing device or distributed over a network of computing devices. Alternatively, they may be implemented in program code executable by the computing device, such that They are stored in a storage device and are executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that herein, or they may be separately fabricated into individual integrated circuit modules, or Multiple modules or steps in the fabrication are implemented as a single integrated circuit module.
  • the invention is not limited to any specific combination of hardware and software.
  • the data in the shared memory is updated; the completion message of completing the update of the data in the shared memory is sent to one or more threads; and the shared memory is shared according to the completion message.
  • the updated data is provided to the one or more threads for service processing, and solves the problem that the multi-process uses the shared memory in the related technology, and the data change in the shared memory cannot be sensed in time, so that the shared memory can be known in time.
  • the status of the data is provided to the one or more threads for service processing, and solves the problem that the multi-process uses the shared memory in the related technology, and the data change in the shared memory cannot be sensed in time, so that the shared memory can be known in time.

Landscapes

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

Abstract

Disclosed are a data update processing method and apparatus. The method comprises: updating data in shared memory; sending a complete message indicating that update of the data in the shared memory is completed to one or more threads; and providing, according to the complete message, the updated data in the shared memory to the one or more threads to perform service processing. By means of the present invention, a problem in the related art that when multiple processes use shared memory, a data change in the shared memory cannot be perceived in time is resolved, so that a status of the data in the shared memory can be known in time.

Description

数据更新处理方法及装置Data update processing method and device 技术领域Technical field
本发明涉及通信领域,具体而言,涉及数据更新处理方法及装置。The present invention relates to the field of communications, and in particular, to a data update processing method and apparatus.
背景技术Background technique
随着Internet的发展,路由器的功能日益复杂,集中式的控制面处理已经不能满足运营商的需求,控制面的分布式、多进程的实现方式成为由器的一个发展趋势。IP的开放性、多样性、以及传统电信的各种业务都不断的迁移到IP承载上,导致IP各种新协议、新业务不断快速推出。为支持协议功能的裁剪、独立发布版本、独立升级,导致了多进程的实现方式,且进程划分的非常细,甚至每个协议都运行在独立的进程空间中。支持协议分布式运行,不同的协议进程可运行在不同的协议处理单元中。另外,采用多进程的实现方式,也解决了软件各组件故障相互影响的问题,避免随着软件规模扩大,开发功能的难度不断增加及版本稳定性降低,故障收敛慢的问题。With the development of the Internet, the functions of routers are increasingly complex, and centralized control plane processing can no longer meet the needs of operators. The distributed and multi-process implementation of control planes has become a development trend of the devices. The openness, diversity, and various services of traditional telecommunications have been continually migrated to IP bearers, resulting in the rapid launch of various new IP protocols and new services. In order to support the cutting of the protocol function, independent release version, and independent upgrade, the multi-process implementation is implemented, and the process is divided very finely, and even each protocol runs in a separate process space. Support protocol distributed operation, different protocol processes can run in different protocol processing units. In addition, the multi-process implementation method also solves the problem that the software components fail to interact with each other, avoiding the difficulty of developing functions and the stability of the version, and the slow convergence of the faults as the software scales up.
各协议运行在不同进程,但有些数据信息是各个进程都需要的,例如端口信息。在运行的协议进程越来越多的情况下,如果各进程都保存一份重复的数据,对内存资源是很大的浪费。在运营商对通信设备功能需求不断增多,性能要求不断提高的情况下,设备需要支持的端口类型、数量越来越多,系统的内存资源越来越紧缺(其对内存的消耗是按照端口数量和协议进程数量乘积的形式进行增长)。图1是相关技术中数据同步模型的示意图,如图1所示,在使用消息进行进程间数据同步的方式下,各个进程空间都申请内存保存了一份数据。Each protocol runs on a different process, but some data information is required by each process, such as port information. In the case of more and more protocol processes running, if each process saves a duplicate data, it is a waste of memory resources. As operators' requirements for communication devices continue to increase and performance requirements continue to increase, the types of ports that devices need to support are increasing. The memory resources of the system are becoming increasingly scarce (the memory consumption is based on the number of ports). Increase in the form of the product of the number of protocol processes). FIG. 1 is a schematic diagram of a data synchronization model in the related art. As shown in FIG. 1 , in a manner of using a message to perform inter-process data synchronization, each process space applies for a memory to store a piece of data.
如果各个进程使用共享内存的方式对数据进行共享访问,则可以极大的降低系统内存的消耗。但操作系统所支持的共享内存,仅提供进程对共享内存进行主动读、写。在共享内存中的数据变化时,相关进程无法及时的被动感知,只能在后续主动查询时得到变化后的数据,此时已无法知道具体哪些信息字段发生了变化,以及变化前的值是多少。这种方式难以满足一些场景的实现需要。例如,对端口进行IP配置,将IP信息写入共享内存后,路由协议进程需要及时感知到端口上IP的添加事件,对路由进行重新计算;将光纤插入PPP口,PPP端口的物理UP状态更新到共享内存后,PPP协议进程需要及时感知物理UP事件,和对端设备进行协商建链。如果各个协议都定时轮询检查数据的变化,定时周期太长,则及时性得不到保证;定时周期太短,则对系统性能是很大的消耗,影响设备对正常业务的处理能力。且通过轮询的方式,在数据修或删除之后才能发现,已获取不到修改前或删除前的数据。 If each process uses shared memory to share access to data, it can greatly reduce system memory consumption. However, the shared memory supported by the operating system only provides the process to actively read and write to the shared memory. When the data in the shared memory changes, the related process cannot be passively aware in time, and only the changed data can be obtained in the subsequent active query. At this time, it is impossible to know which specific information fields have changed, and what is the value before the change. . This method is difficult to meet the implementation needs of some scenarios. For example, after the IP address is configured on the port and the IP information is written to the shared memory, the routing protocol process needs to detect the IP add event on the port and recalculate the route. Insert the fiber into the PPP port and update the physical UP status of the PPP port. After the shared memory is used, the PPP process needs to be aware of the physical UP event and negotiate with the peer device to establish a link. If each protocol periodically polls and checks the change of data, if the timing period is too long, the timeliness cannot be guaranteed. If the timing period is too short, the system performance is greatly consumed, which affects the processing capability of the device for normal services. And through the polling method, after the data is repaired or deleted, it can be found that the data before or before the modification has not been obtained.
针对相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,目前尚未提出有效的解决方案。When the shared memory is used by multiple processes in the related art, the problem of data change in the shared memory cannot be sensed in time, and an effective solution has not been proposed yet.
发明内容Summary of the invention
本发明提供了数据更新处理方法及装置,以至少解决相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题。The present invention provides a data update processing method and apparatus, so as to at least solve the problem that the multi-process uses the shared memory in the related art, and cannot sense the data change in the shared memory in time.
根据本发明的一个实施例,提供了一种数据更新处理方法,包括:对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。According to an embodiment of the present invention, a data update processing method is provided, including: updating data in a shared memory; transmitting a completion message to the one or more threads that the update of the data in the shared memory is completed; The completion message provides the updated data in the shared memory to the one or more threads for service processing.
在本发明实施例中,在对共享内存中的所述数据进行更新之前还包括:向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。In the embodiment of the present invention, before updating the data in the shared memory, the method further includes: sending an indication message to the one or more threads, wherein the indication message is used to indicate the one or more threads The data is in an updated state.
根据本发明的另一实施例,提供了一种数据更新处理方法,包括:接收对共享内存中的数据更新完成的完成消息;根据所述完成消息访问共享内存中更新完成后的所述数据。According to another embodiment of the present invention, a data update processing method is provided, including: receiving a completion message for completing update of data in a shared memory; and accessing the data after completion of updating in the shared memory according to the completion message.
在本发明实施例中,在接收对共享内存中的数据更新完成的完成消息之前还包括:接收用于指示共享内存中的所述数据处于更新状态的指示消息;In the embodiment of the present invention, before receiving the completion message of the data update completion in the shared memory, the method further includes: receiving an indication message indicating that the data in the shared memory is in an update state;
根据所述指示消息建立所述数据处于更新状态的标识;And establishing, according to the indication message, an identifier that the data is in an updated state;
在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。The identification is deleted after receiving a completion message for the completion of the update of the data in the shared memory.
在本发明实施例中,在根据所述完成消息访问共享内存中更新完成后的所述数据之前,还包括以下至少之一:在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继 续访问所述共享内存中数据的老化标记。In the embodiment of the present invention, before the updating of the data in the shared memory according to the completion message, the method further includes at least one of the following: receiving the data when the data in the shared memory is updated to add data. An indication message of a keyword having the data, creating null data corresponding to the keyword of the data, deleting the null data after adding data to the shared memory, and updating the data in the shared memory to If the data is modified or deleted, the indication message carrying the keyword of the data is received, the old data before the update in the shared memory is obtained according to the keyword of the data, and the backup is performed, and the shared memory is modified or deleted. After the data is completed, deleting the old data; when updating the data in the shared memory to one or more threads newly joining or restarting, receiving an indication message carrying the keyword of the data, according to the data The keyword is marked as the whole synchronization phase. The data has been created. After all the data in the shared memory is created, the overall synchronization is completed. After the news, delete all the created mark; in the case of shared memory data update process for the Source restart, that creates an empty data from the shared memory access data; or, for the following marks on Continue to access the aging flag of the data in the shared memory.
根据本发明的另一实施例,提供了一种数据更新处理装置,包括:更新模块,设置为对共享内存中的数据进行更新;第一发送模块,设置为向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;提供发送模块,设置为根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。According to another embodiment of the present invention, there is provided a data update processing apparatus comprising: an update module configured to update data in a shared memory; and a first sending module configured to send a pair to one or more threads a completion message of the data update completion in the memory; providing a sending module, configured to provide the updated data in the shared memory to the one or more threads for service processing according to the completion message.
在本发明实施例中,所述装置还包括:第二发送模块,设置为向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。In an embodiment of the present invention, the apparatus further includes: a second sending module, configured to send an indication message to the one or more threads, wherein the indication message is used to indicate the one or more threads The data is in an updated state.
根据本发明的另一实施例,提供了一种数据更新处理装置,包括:第一接收模块,设置为接收对共享内存中的数据更新完成的完成消息;访问模块,设置为根据所述完成消息访问共享内存中更新完成后的所述数据。According to another embodiment of the present invention, there is provided a data update processing apparatus, comprising: a first receiving module configured to receive a completion message of completion of data update in a shared memory; and an access module configured to be based on the completion message Access the data in the shared memory after the update is complete.
在本发明实施例中,所述装置还包括:第二接收模块,设置为接收用于指示共享内存中的所述数据处于更新状态的指示消息;建立模块,设置为根据所述指示消息建立所述数据处于更新状态的标识;删除模块,设置为在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。In the embodiment of the present invention, the device further includes: a second receiving module, configured to receive an indication message for indicating that the data in the shared memory is in an updated state; and an establishing module, configured to establish, according to the indication message The identifier is in an update state; the deletion module is configured to delete the identifier after receiving the completion message for completing the update of the data in the shared memory.
在本发明实施例中,所述装置还包括以下至少之一:第一处理模块,设置为在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;第二处理模块,设置为在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;第三处理模块,设置为在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;第四处理模块,设置为在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继续访问所述共享内存中数据的老化标记。In an embodiment of the present invention, the apparatus further includes at least one of the following: a first processing module configured to receive an indication of a keyword carrying the data in a case where data in the shared memory is updated to add data a message, creating null data corresponding to the keyword of the data, deleting the null data after adding data to the shared memory is completed; and the second processing module is configured to update the data in the shared memory to be modified or When the data is deleted, the indication message carrying the keyword of the data is received, the old data before the update in the shared memory is acquired according to the keyword of the data, and the backup is performed, and the data is modified or deleted in the shared memory. After the old data is deleted, the third processing module is configured to receive an indication message carrying the keyword of the data when the data in the shared memory is updated to be newly added or restarted by one or more threads. The data is created according to the keyword tag of the data as the overall synchronization phase, and after all the data in the shared memory is created, After the volume synchronization completion message, all created tags are deleted; the fourth processing module is configured to create null data for prohibiting access to data from the shared memory when the data in the shared memory is updated to the Source process restart. Or, an aging flag on the tag to continue accessing the data in the shared memory.
通过本发明,采用对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。 By the present invention, updating data in the shared memory is used; sending a completion message to the one or more threads for updating the data in the shared memory; and updating the updated data in the memory according to the completion message Providing the one or more threads for service processing, and solving the problem that the multi-process uses the shared memory in the related technology, the data change in the shared memory cannot be sensed in time, so that the state of the data in the shared memory can be known in time.
附图说明DRAWINGS
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the invention, and are intended to be a part of the invention. In the drawing:
图1是相关技术中数据同步模型的示意图;1 is a schematic diagram of a data synchronization model in the related art;
图2是根据本发明实施例的数据更新处理方法的流程图一;2 is a flowchart 1 of a data update processing method according to an embodiment of the present invention;
图3是根据本发明实施例的数据更新处理方法的流程图二;3 is a second flowchart of a data update processing method according to an embodiment of the present invention;
图4是根据本发明实施例的数据更新处理装置的框图一;4 is a block diagram 1 of a data update processing apparatus according to an embodiment of the present invention;
图5是根据本发明优选实施例的数据更新处理装置的框图一;Figure 5 is a block diagram 1 of a data update processing apparatus in accordance with a preferred embodiment of the present invention;
图6是根据本发明实施例的数据更新处理装置的框图二;6 is a block diagram 2 of a data update processing apparatus according to an embodiment of the present invention;
图7是根据本发明优选实施例的数据更新处理装置的框图二;Figure 7 is a block diagram 2 of a data update processing apparatus in accordance with a preferred embodiment of the present invention;
图8是根据本发明优选实施例的数据更新处理装置的框图三;Figure 8 is a block diagram 3 of a data update processing apparatus in accordance with a preferred embodiment of the present invention;
图9是根据本发明实施例的数据同步模型的示意图;9 is a schematic diagram of a data synchronization model according to an embodiment of the present invention;
图10是根据本发明实施例的数据同步中数据添加的示意图;FIG. 10 is a schematic diagram of data addition in data synchronization according to an embodiment of the present invention; FIG.
图11是根据本发明实施例的数据同步中数据修改的示意图;11 is a schematic diagram of data modification in data synchronization according to an embodiment of the present invention;
图12是根据本发明实施例的数据同步中数据删除的示意图;FIG. 12 is a schematic diagram of data deletion in data synchronization according to an embodiment of the present invention; FIG.
图13是根据本发明实施例的数据同步中整体同步的示意图;FIG. 13 is a schematic diagram of overall synchronization in data synchronization according to an embodiment of the present invention; FIG.
图14是根据本发明实施例的数据同步中Source重启的示意图一;FIG. 14 is a first schematic diagram of a source restart in data synchronization according to an embodiment of the present invention; FIG.
图15是根据本发明实施例的数据同步中Source重启的示意图二;FIG. 15 is a second schematic diagram of a source restart in data synchronization according to an embodiment of the present invention; FIG.
图16是根据本发明实施例的数据同步模型部署的示意图一;16 is a first schematic diagram of a data synchronization model deployment according to an embodiment of the present invention;
图17是根据本发明实施例的数据同步模型部署的示意图二;17 is a second schematic diagram of a data synchronization model deployment according to an embodiment of the present invention;
图18是根据本发明实施例的数据同步模型部署的示意图三;18 is a third schematic diagram of a data synchronization model deployment according to an embodiment of the present invention;
图19是根据本发明实施例的数据同步模型部署的示意图四;19 is a fourth schematic diagram of a data synchronization model deployment according to an embodiment of the present invention;
图20是根据本发明实施例的数据同步模型部署的示意图五。20 is a fifth diagram of a data synchronization model deployment in accordance with an embodiment of the present invention.
具体实施方式 detailed description
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。The invention will be described in detail below with reference to the drawings in conjunction with the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict.
在本实施例中提供了一种数据更新处理方法,图2是根据本发明实施例的数据更新处理方法的流程图一,如图2所示,该流程包括如下步骤:In the embodiment, a data update processing method is provided. FIG. 2 is a flowchart 1 of a data update processing method according to an embodiment of the present invention. As shown in FIG. 2, the flow includes the following steps:
步骤S202,对共享内存中的数据进行更新;Step S202, updating data in the shared memory;
步骤S204,向一个或多个线程发送对共享内存中的该数据更新完成的完成消息;Step S204, sending a completion message to the one or more threads that the update of the data in the shared memory is completed;
步骤S206,根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理。Step S206, the updated data in the shared memory is provided to the one or more threads for service processing according to the completion message.
通过上述步骤,对共享内存中的数据进行更新,向一个或多个线程发送对共享内存中的该数据更新完成的完成消息,根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。Through the above steps, updating the data in the shared memory, sending a completion message to the one or more threads that the update of the data in the shared memory is completed, and providing the updated data in the shared memory to the one according to the completion message. Or multiple threads perform business processing, which solves the problem that the multi-process uses the shared memory in the related technology, and cannot sense the data change in the shared memory in time, so that the state of the data in the shared memory can be known in time.
在本发明实施例中,在对共享内存中的该数据进行更新之前还包括:向该一个或多个线程发送指示消息,其中,该指示消息用于指示该一个或多个线程该数据处于更新状态。In the embodiment of the present invention, before updating the data in the shared memory, the method further includes: sending an indication message to the one or more threads, wherein the indication message is used to indicate that the one or more threads are updated. status.
本发明实施例还提供了一种数据更新处理方法,图3是根据本发明实施例的数据更新处理方法的流程图二,如图3所示,包括:The embodiment of the present invention further provides a data update processing method. FIG. 3 is a second flowchart of a data update processing method according to an embodiment of the present invention. As shown in FIG. 3, the method includes:
步骤S302,接收对共享内存中的数据更新完成的完成消息;Step S302, receiving a completion message for completing the update of the data in the shared memory;
步骤S304,根据该完成消息访问共享内存中更新完成后的该数据。Step S304, accessing the data after the update in the shared memory is completed according to the completion message.
通过上述步骤,接收对共享内存中的数据更新完成的完成消息,根据该完成消息访问共享内存中更新完成后的该数据,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。Through the above steps, receiving the completion message of the update of the data in the shared memory, and accessing the data after the update is completed in the shared memory according to the completion message, which solves the problem that the multi-process uses the shared memory in the related technology, and cannot sense the shared memory in time. The problem of data changes, so that the status of the data in the shared memory can be known in time.
为了更好的获知共享内存中数据的状态,在一个可选的实施例中中,在接收对共享内存中的数据更新完成的完成消息之前,接收用于指示共享内存中的该数据处于更新状态的指示消息;根据该指示消息建立该数据处于更新状态的标识;在接收到对共享内存中的数据更新完成的完成消息之后,删除该标识,之后确定共享内存中的数据位更新后的数据。In order to better know the state of the data in the shared memory, in an optional embodiment, before receiving the completion message of the data update completion in the shared memory, receiving is used to indicate that the data in the shared memory is in an updated state. The indication message is established according to the indication message; after receiving the completion message for completing the update of the data in the shared memory, deleting the identifier, and then determining the updated data of the data bits in the shared memory.
在根据该完成消息访问共享内存中更新完成后的该数据之前,还可以包括以下至少之一:在对共享内存中的数据更新为添加数据的情况下,接收携带有该数据的关键字的指示消息,创建与该数据的关键字对应的空数据,在对该共享内存添加数据完成 后,删除该空数据;在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字获取共享内存中的更新前的旧数据并进行备份,在该共享内存修改或删除数据完成后,删除该旧数据;在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字标记为整体同步阶段该数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从该共享内存中访问数据的空数据;或者,标记上用于继续访问该共享内存中数据的老化标记。Before the data after the completion of the update in the shared memory is accessed according to the completion message, at least one of the following may be included: receiving an indication of the keyword carrying the data if the data in the shared memory is updated to add data Message, creating null data corresponding to the keyword of the data, adding data to the shared memory After deleting the null data; when updating the data in the shared memory to modify or delete the data, receiving an indication message carrying the keyword of the data, and acquiring the pre-update in the shared memory according to the keyword of the data The old data is backed up, and after the shared memory is modified or deleted, the old data is deleted; when the data in the shared memory is updated to one or more threads newly added or restarted, receiving the data carrying the data The indication message of the keyword, according to the keyword of the data, the data is created in the overall synchronization phase, and all the created tags are deleted after receiving the overall synchronization completion message after all the data in the shared memory is created; in the shared memory In the case where the data update in the source process is restarted, empty data for prohibiting access to data from the shared memory is created; or, an aging flag for continuing to access data in the shared memory is marked.
本发明实施例提供了一种数据更新处理装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。The embodiment of the present invention provides a data update processing device, which is used to implement the foregoing embodiments and preferred embodiments, and has not been described again. As used below, the term "module" may implement a combination of software and/or hardware of a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware, is also possible and contemplated.
图4是根据本发明实施例的数据更新处理装置的框图一,如图4所示,包括:更新模块42、第一发送模块44和提供发送模块46,下面对各个模块进行简要说明。4 is a block diagram of a data update processing apparatus according to an embodiment of the present invention. As shown in FIG. 4, the method includes an update module 42, a first sending module 44, and a providing transmitting module 46. The following briefly describes each module.
更新模块42,设置为对共享内存中的数据进行更新;An update module 42 configured to update data in the shared memory;
第一发送模块44,设置为向一个或多个线程发送对共享内存中的该数据更新完成的完成消息;The first sending module 44 is configured to send a completion message to the one or more threads that the update of the data in the shared memory is completed;
提供发送模块46,设置为根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理。The sending module 46 is configured to provide the updated data in the shared memory to the one or more threads for service processing according to the completion message.
图5是根据本发明优选实施例的数据更新处理装置的框图一,如图5所示,该装置还包括:FIG. 5 is a block diagram 1 of a data update processing apparatus according to a preferred embodiment of the present invention. As shown in FIG. 5, the apparatus further includes:
第二发送模块52,设置为向该一个或多个线程发送指示消息,其中,该指示消息用于指示该一个或多个线程该数据处于更新状态。The second sending module 52 is configured to send an indication message to the one or more threads, wherein the indication message is used to indicate that the one or more threads are in an updated state.
本发明实施例还提供了一种数据更新处理装置,图6是根据本发明实施例的数据更新处理装置的框图二,如图6所示,包括:The embodiment of the present invention further provides a data update processing apparatus. FIG. 6 is a block diagram 2 of a data update processing apparatus according to an embodiment of the present invention. As shown in FIG. 6, the method includes:
第一接收模块62,设置为接收对共享内存中的数据更新完成的完成消息;The first receiving module 62 is configured to receive a completion message for completing the update of the data in the shared memory;
访问模块64,设置为根据该完成消息访问共享内存中更新完成后的该数据。The access module 64 is configured to access the data after the update in the shared memory is completed according to the completion message.
图7是根据本发明优选实施例的数据更新处理装置的框图二,如图7所示,该装置还包括:FIG. 7 is a block diagram 2 of a data update processing apparatus according to a preferred embodiment of the present invention. As shown in FIG. 7, the apparatus further includes:
第二接收模块72,设置为接收用于指示共享内存中的该数据处于更新状态的指示 消息;The second receiving module 72 is configured to receive an indication that the data in the shared memory is in an updated state Message
建立模块74,设置为根据该指示消息建立该数据处于更新状态的标识;The establishing module 74 is configured to establish, according to the indication message, an identifier that the data is in an updated state;
删除模块76,设置为在接收到对共享内存中的数据更新完成的完成消息之后,删除该标识。The delete module 76 is configured to delete the identity after receiving the completion message for the completion of the update of the data in the shared memory.
图8是根据本发明优选实施例的数据更新处理装置的框图三,如图8所示,该装置还包括以下至少之一:FIG. 8 is a block diagram 3 of a data update processing apparatus according to a preferred embodiment of the present invention. As shown in FIG. 8, the apparatus further includes at least one of the following:
第一处理模块82,设置为在对共享内存中的数据更新为添加数据的情况下,接收携带有该数据的关键字的指示消息,创建与该数据的关键字对应的空数据,在对该共享内存添加数据完成后,删除该空数据;The first processing module 82 is configured to: when the data in the shared memory is updated to add data, receive an indication message carrying the keyword of the data, and create null data corresponding to the keyword of the data, where After the shared memory is added, the empty data is deleted;
第二处理模块84,设置为在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字获取共享内存中的更新前的旧数据并进行备份,在该共享内存修改或删除数据完成后,删除该旧数据;The second processing module 84 is configured to receive an indication message carrying the keyword of the data when the data in the shared memory is updated to modify or delete data, and obtain the update in the shared memory according to the keyword of the data. The old data is backed up, and after the shared memory is modified or deleted, the old data is deleted;
第三处理模块86,设置为在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字标记为整体同步阶段该数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;The third processing module 86 is configured to, when the data in the shared memory is updated to be newly added or restarted by one or more threads, receive an indication message carrying the keyword of the data, and mark the keyword according to the data as The data has been created during the overall synchronization phase, and all created tags are deleted after receiving the overall synchronization completion message after all the data in the shared memory is created.
第四处理模块88,设置为在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从该共享内存中访问数据的空数据;或者,标记上用于继续访问该共享内存中数据的老化标记。The fourth processing module 88 is configured to: create a blank data for prohibiting access to data from the shared memory when the data in the shared memory is updated to the source process, or to continue to access the shared memory The aging mark of the data.
下面以一个或多个线程为Reader为例对本发明实施例进行进一步说明。The embodiment of the present invention is further described by taking one or more threads as a Reader as an example.
本可选实施例使需要访问共享内存的相关进程可及时感知到共享内存中数据的添加、修改、删除操作事件,并依据事件控制进程对共享内存中数据的访问。在感知到数据添加事件前进程不能访问到共享内存中的数据,感知到数据添加事件后才能访问到数据;在感知到数据修改事件前,进程只能访问到修改前的数据,在感知到数据修改事件时,能同时访问到修改前和修改后的数据(可对比修改前、后的数据),在感知到修改事件后,进程可以访问到修改后的数据;在感知数据删除事件前,进程可以访问到共享内存中的数据,感知到数据删除事件后,不能访问到共享内存中的数据。对于进程重启的情况,同样依据事件来控制进程对共享内存的访问。该方法可以使进程参与到共享内存数据添加、修改、删除的过程中,使进程能及时进行相关逻辑处理,并在处理时能获取到所需的数据信息。The optional embodiment enables related processes that need to access the shared memory to sense the events of adding, modifying, and deleting data in the shared memory in time, and control the access of the data in the shared memory according to the event. The process can not access the data in the shared memory before the data addition event is perceived, and the data can be accessed only after the data addition event is perceived; before the data modification event is perceived, the process can only access the data before the modification, and the data is perceived. When the event is modified, the data before and after the modification can be accessed at the same time (the data before and after the modification can be compared), and after the modification event is perceived, the process can access the modified data; before the data deletion event is sensed, the process You can access the data in the shared memory, and after you perceive the data deletion event, you cannot access the data in the shared memory. For the case of a process restart, the process also controls the access of the process to the shared memory. The method can participate in the process of adding, modifying, and deleting shared memory data, so that the process can perform related logic processing in time, and can obtain required data information during processing.
本可选实施例提供了一种基于共享内存的数据同步方法,在共享内存中的数据发 生变化时,可及时通知到相关进程,并协调进程及时进行相关逻辑处理,即处理时能访问到所需的数据,对于新数据添加,可以获取到新数据;对于数据修改,能获取到修改前和修改后的数据;对于数据删除,能获取到即将删除的数据。在减少内存开销的同时,也满足各种应用场景的要求,达到与使用消息进行进程间数据同步方式同样的效果。The optional embodiment provides a data synchronization method based on shared memory, and the data is sent in the shared memory. When the change occurs, the relevant process can be notified in time, and the coordination process can perform relevant logic processing in time, that is, the required data can be accessed during processing, and new data can be acquired for the new data addition; for the data modification, the modification can be obtained. Pre- and modified data; for data deletion, data that is about to be deleted can be obtained. While reducing the memory overhead, it also satisfies the requirements of various application scenarios, and achieves the same effect as the method of synchronizing data between processes using messages.
下面基于共享内存的数据同步方法模型中涉及的三个角色进行说明。The following three roles based on the shared memory data synchronization method model are described below.
源Source,数据的产生源头,接受Writer和Reader注册。Source Source, the source of data generation, accepts Writer and Reader registration.
写者Writer,负责将Source产生的数据写入共享内存。The writer Writer is responsible for writing the data generated by the Source to the shared memory.
读者Reader,需要访问共享内存数据的进程(或线程),例如各协议进程。Reader Reader, a process (or thread) that needs to access shared memory data, such as protocol processes.
Source是数据的产生源头,可以是一个单独的进程,在该进程空间保存了一份源数据。Source接受Writer和Reader的注册,并以CPU为单位,维护各个CPU上的Writer和Reader的注册信息。一个CPU上可以存在多个Reader,但只能存在一个Writer。在Source中的源数据添加、修改、删除时通过共享内存方式向Reader同步数据,可使Reader感知到数据的添加、修改、删除事件。Writer是负责对共享内存进行写操作的进程(或线程),在收到Source的数据添加、修改、删除消息时,将数据变化写入共享内存。Reader是需要访问共享内存数据的进程,具有对共享内存的只读权限。例如,路由进程、PPP进程等各协议进程。另外,LOD(Local Old Database)是本地“旧数据”库,在共享内存数据修改提交前,在各Reader本地进程空间保存修改前的“旧数据”。LND(Local Null Database)是本地“空数据”库,在共享内存数据创建前,在各Reader本地进程空间创建相应数据的“空数据”,用于表示相应数据还没有创建。当某进程本地存在“空数据”时,即使共享内存中已经存在相应的数据,对该进程也不可见。Source is the source of data generation. It can be a separate process in which a source of data is stored. Source accepts the registration of Writer and Reader, and maintains the registration information of Writer and Reader on each CPU in CPU units. There can be multiple Readers on a single CPU, but only one Writer can exist. When the source data in the Source is added, modified, or deleted, the data is synchronized to the Reader through the shared memory mode, so that the Reader can perceive the data addition, modification, and deletion events. The Writer is the process (or thread) responsible for writing to the shared memory. When the source data is added, modified, or deleted, the data changes are written to the shared memory. Reader is a process that needs to access shared memory data and has read-only access to shared memory. For example, routing processes, PPP processes, and other protocol processes. In addition, LOD (Local Old Database) is a local "old data" library, and the "old data" before modification is saved in each Reader local process space before the shared memory data is modified. LND (Local Null Database) is a local "empty data" library. Before the shared memory data is created, the "empty data" of the corresponding data is created in each Reader local process space to indicate that the corresponding data has not been created yet. When there is "empty data" locally in a process, even if the corresponding data already exists in the shared memory, the process is not visible.
图9是根据本发明实施例的数据同步模型的示意图,如图9所示,Source中数据添加、修改、删除时,首先通知各个Reader进行预处理,所有Reader预处理完成后,通知Writer更新共享内存中的数据,Writer操作完成后,Source再通知各个Reader更新完成,Reader进行相应的业务逻辑处理。9 is a schematic diagram of a data synchronization model according to an embodiment of the present invention. As shown in FIG. 9, when data is added, modified, or deleted in the Source, each Reader is first notified to perform preprocessing. After all Reader preprocessing is completed, the Writer is notified to update the sharing. The data in the memory, after the Writer operation is completed, the Source notifies each Reader that the update is completed, and the Reader performs the corresponding business logic processing.
图10是根据本发明实施例的数据同步中数据添加的示意图,如图10所示,Source通过消息将数据的关键字发送给Reader,通知Reader在LND中创建该关键字对应的“空数据”,以表示该关键字对应的数据还没有创建(即使共享内存中已经有了,也不可见);所有Reader创建完“空数据”后,Source通知Writer在共享内存中创建新数据,完成后Source再通知Reader创建完成,Reader做新数据创建逻辑处理,并将该关键字对应的“空数据”删除,表示该关键字对应的数据已经创建完成,后续Reader 可以直接从共享内存中访问该数据。FIG. 10 is a schematic diagram of data addition in data synchronization according to an embodiment of the present invention. As shown in FIG. 10, the source sends a keyword of the data to the Reader through a message, and notifies the Reader to create “empty data” corresponding to the keyword in the LND. To indicate that the data corresponding to the keyword has not been created (even if it exists in the shared memory, it is not visible); after all Reader has created "empty data", the Source notifies the Writer to create new data in the shared memory, after the completion of the Source Then notify Reader to complete the creation, Reader does the new data creation logic processing, and deletes the "empty data" corresponding to the keyword, indicating that the data corresponding to the keyword has been created, and the subsequent Reader This data can be accessed directly from shared memory.
图11是根据本发明实施例的数据同步中数据修改的示意图,如图11所示,Source通过消息将数据的关键字发送给Reader,Reader通过关键字在共享内存中查询修改前的“旧数据”,并将“旧数据”备份到Reader进程本地的LOD中,以表示共享内存中的该数据处于不稳定状态,正发生变化(LOD中存在“旧数据”时,Reader只能查询到LOD中的“旧数据”,共享内存中的相应数据不可见)。Source通知Writer将共享内存中的数据修改完成后,再通知Reader数据修改完成,Reader做数据修改逻辑处理(此时能访问到LOD中的“旧数据”和共享内存中的修改后的数据,),并将LOD中备份的“旧数据”删除,表示该关键字对应的数据已经修改完成,目前处于稳定状态,后续Reader可以直接从共享内存中访问该数据。11 is a schematic diagram of data modification in data synchronization according to an embodiment of the present invention. As shown in FIG. 11, the source sends a keyword of the data to the Reader through a message, and the Reader queries the old data before the modification in the shared memory by using a keyword. ", and back up the "old data" to the LOD local to the Reader process to indicate that the data in the shared memory is in an unstable state and is changing (Reader can only query the LOD when there is "old data" in the LOD) The "old data", the corresponding data in the shared memory is not visible). The Source notifies the Writer to modify the data in the shared memory, and then notifies the Reader that the data modification is completed. The Reader performs the data modification logic processing (at this time, the "old data" in the LOD and the modified data in the shared memory can be accessed,) And delete the "old data" backed up in the LOD, indicating that the data corresponding to the keyword has been modified, and is currently in a stable state, and the subsequent Reader can directly access the data from the shared memory.
图12是根据本发明实施例的数据同步中数据删除的示意图,如图12所示,Reader进行数据备份的流程与数据修改时所做的备份流程类似。Source通过消息将数据的关键字发送给Reader,Reader通过关键字从共享内存中查询数据,并将数据备份到Reader进程本地的LOD中,以表示共享内存中的该数据处于不稳定状态,正进行删除。Source通知Writer将共享内存中的数据删除完成后,再通知Reader删除完成,Reader做数据删除逻辑处理(此时可以查询到即将删除的数据信息),并将LOD中的备份数据删除,表示该关键字对应的数据已经删除完成。后续Reader在共享内存中将查询不到该关键字对应的数据。FIG. 12 is a schematic diagram of data deletion in data synchronization according to an embodiment of the present invention. As shown in FIG. 12, the process of data backup performed by Reader is similar to the backup process performed when data is modified. Source sends the data key to Reader through the message. Reader queries the data from the shared memory by keyword and backs up the data to the local LOD of the Reader process to indicate that the data in the shared memory is unstable. delete. The Source notifies the Writer to delete the data in the shared memory, and then notifies the Reader that the deletion is completed. The Reader performs the data deletion logic processing (in this case, the data information to be deleted is queried), and the backup data in the LOD is deleted, indicating the key. The data corresponding to the word has been deleted. Subsequent Reader will not query the data corresponding to the keyword in the shared memory.
图13是根据本发明实施例的数据同步中整体同步的示意图,如图13所示,对于共享内存中已经存在数据,新的Reader后加入的情况,因该Reader还没有感知过相应数据的创建,没有进行过新数据创建逻辑处理,此时不允许该Reader访问到共享内存中的数据。需要将共享内存中已经存在的数据向Reader进行一次整体同步,Reader感知到数据创建事件后,才能访问到共享内存中的数据。13 is a schematic diagram of overall synchronization in data synchronization according to an embodiment of the present invention. As shown in FIG. 13, for a case where data already exists in the shared memory and a new Reader is added, the Reader has not perceived the creation of the corresponding data. There is no new data creation logic processing, and the Reader is not allowed to access the data in the shared memory at this time. The data that already exists in the shared memory needs to be synchronized to the Reader once, and the Reader perceives the data creation event before accessing the data in the shared memory.
对于新加入的Reader,将同步状态标记为整体同步阶段,Source直接将已经存在的数据关键字发送给Reader,使Reader感知创建事件。对于已经收到过创建事件的数据,Reader在本地创建相应的记录,打上“已创建”标记。对于具有“已创建”记录的数据,Reader可以在共享内存中查询到数据,否则共享内存中的数据对该Reader不可见。Source将所有的数据通知Reader创建完成后,通知Reader整体同步完成,Reader将同步状态标志修改变化同步阶段,并将本地所有的“已创建”记录删除。For the newly added Reader, the synchronization status is marked as the overall synchronization phase, and the Source directly sends the existing data key to the Reader, so that the Reader perceives the creation event. For data that has already received a creation event, Reader creates a corresponding record locally, with the "created" tag. For data with "created" records, Reader can query the data in shared memory, otherwise the data in shared memory is not visible to the Reader. The Source notifies the Reader that all the data has been created, and notifies the Reader that the synchronization is complete. The Reader will synchronize the status flag to change the synchronization phase and delete all the local "created" records.
Reader重启的情况下,Reader进程退出时,Source将该Reader从注册列表中删除,数据可继续向其他Reader同步。该Reader起来后,重新向Source注册,Source按照整体同步流程,向该Reader进行数据同步。某个Reader重启过程中,Source可以向其他Reader正常同步数据,对其他Reader无影响。 When the Reader restarts, when the Reader process exits, the Source deletes the Reader from the registration list, and the data can continue to synchronize with other Readers. After the Reader gets up, it re-registers with the Source, and the Source synchronizes the data to the Reader according to the overall synchronization process. During a Reader restart, Source can synchronize data to other Readers without affecting other Readers.
Source重启:对于Source进程重启的情况,可根据场景需要分别采用如下两种实现方式。Source restart: For the restart of the source process, the following two implementation modes can be used according to the scenario.
图14是根据本发明实施例的数据同步中Source重启的示意图一,如图14所示,Reader感知到Source退出时,遍历共享内存中的所有数据,进行数据删除逻辑处理,并在LND中创建相应的“空数据”,后续不能从共享内存中访问到相应数据。Writer感知到Source退出后,对共享内存中的数据打上“老化”标记。Source进程重新启动后,重新恢复数据,并向Reader和Writer进行“数据添加”同步流程。Source通过消息将数据的关键字发送给Reader,Reader在LND中创建该关键字对应的“空数据”,若此时LND中已经存在相应的“空数据”,则直接跳过该处理步骤。所有Reader创建完“空数据”后,Source通知Writer在共享内存中创建数据,此时若共享内存中已经存在相应数据,则直接对共享内存中的数据进行更新,并去除该数据的“老化”标记。Writer完成共享内存数据的创建或更新后,Source再通知Reader创建完成,Reader做数据创建逻辑处理,并将相应的“空数据”删除,表示该关键字对应的数据已经创建完成,后续Reader可以直接从共享内存中访问该数据。Source中数据恢复,并同步完成后,通知Reader和Writer进行“垃圾”数据处理,Reader删除LND中的仍然存在的“空数据”,Writer删除共享内存中仍然具有“老化”标记的数据。14 is a schematic diagram 1 of a source restart in data synchronization according to an embodiment of the present invention. As shown in FIG. 14, when the reader perceives that the Source exits, it traverses all the data in the shared memory, performs data deletion logic processing, and creates in the LND. Corresponding "empty data", subsequent access to the corresponding data from shared memory. After the Writer senses that the Source exits, it puts an "aging" flag on the data in the shared memory. After the Source process is restarted, the data is restored and a "data addition" synchronization process is performed to Reader and Writer. The source sends the keyword of the data to the Reader through the message. The Reader creates the "empty data" corresponding to the keyword in the LND. If the corresponding "empty data" already exists in the LND, the processing step is skipped. After all Reader has created "empty data", the Source notifies the Writer to create data in the shared memory. If the corresponding data already exists in the shared memory, the data in the shared memory is directly updated, and the "aging" of the data is removed. mark. After the Writer finishes creating or updating the shared memory data, the Source notifies the Reader to complete the creation. The Reader performs the data creation logic processing and deletes the corresponding "empty data", indicating that the data corresponding to the keyword has been created, and the subsequent Reader can directly Access this data from shared memory. The data in the Source is restored, and after the synchronization is completed, the Reader and the Writer are notified to perform "junk" data processing, the Reader deletes the "empty data" still existing in the LND, and the Writer deletes the data in the shared memory that still has the "aging" flag.
图15是根据本发明实施例的数据同步中Source重启的示意图二,如图15所示,Reader感知到Source退出后,遍历共享内存中的所有数据,在本地创建相应的记录,打上“老化”标记,仍然可继续访问共享内存中的数据。Writer感知到Source退出后,对共享内存中的数据打上“老化”标记。Source进程重新起来后,重新恢复数据,并向Reader和Writer进行“数据添加”或“数据修改”同步流程。Source通过消息将数据的关键字发送给Reader,此时若Reader已经存在具有“老化”标记的相应记录,则将共享内存中的“旧数据”备份到本地LOD,并将“老化”标记记录删除;否则Reader在LND中创建该关键字对应的“空数据”。所有Reader预处理完后,Source通知Writer在共享内存中创建数据,此时若共享内存中已经存在相应数据,则直接对共享内存中的数据进行更新,并去除该数据的“老化”标记。Writer完成共享内存数据的创建或更新后,Source通知Reader创建或更新完成,对于存在“空数据”的情况,Reader做数据创建逻辑处理,并将相应的“空数据”删除;对于存在“旧数据”的情况,Reader做数据修改逻辑处理,并将“旧数据”删除。Source中数据恢复,并同步完成后,先通知Reader进行“垃圾”数据处理,Reader对仍然具有“老化”标记记录的数据进行删除逻辑处理(此时仍然可以查询到共享内存中的数据),并删除“老化”标记记录。Reader对“垃圾”数据处理完后,Source再通知Writer进行“垃圾”数据处理,删除共享内存中仍然存在“老化”标记的数据。FIG. 15 is a second schematic diagram of a source restart in data synchronization according to an embodiment of the present invention. As shown in FIG. 15, after the reader perceives that the source exits, it traverses all data in the shared memory, and locally creates a corresponding record, and puts on “aging”. Marked, you can continue to access data in shared memory. After the Writer senses that the Source exits, it puts an "aging" flag on the data in the shared memory. After the source process is restarted, the data is restored again, and the "data addition" or "data modification" synchronization process is performed to the Reader and the Writer. The Source sends the keyword of the data to the Reader through the message. If the Reader already has the corresponding record with the "Aging" mark, the "Old Data" in the shared memory is backed up to the local LOD, and the "Aging" mark record is deleted. Otherwise, Reader creates the "empty data" corresponding to the keyword in the LND. After all Reader is preprocessed, the Source notifies the Writer to create data in the shared memory. At this time, if the corresponding data already exists in the shared memory, the data in the shared memory is directly updated, and the "aging" flag of the data is removed. After the Writer finishes creating or updating the shared memory data, the Source notifies the Reader to create or update. For the case of "empty data", Reader does the data creation logic processing and deletes the corresponding "empty data"; for the existence of "old data" In the case, Reader does the data modification logic and deletes the "old data". After the data is recovered in the source, and the synchronization is completed, the Reader is first notified to perform "junk" data processing, and the Reader performs the delete logic processing on the data still having the "aged" mark record (at this time, the data in the shared memory can still be queried), and Delete the "aging" tag record. After Reader processes the "junk" data, Source notifies Writer to perform "junk" data processing, and deletes the data of "aged" mark in shared memory.
在使用该方法进行数据同步时,相关进程可以感知到数据的添加、修改、删除事 件,并在感知到事件进行相应的逻辑处理时能获取到相应的数据信息。达到与使用消息进行进程间数据同步同样的效果。进程中的业务可不关心数据是通过何种方式进行同步,只需专注于自身的业务逻辑处理。在数据处于稳定状态时,只有Source进程和共享内存会申请内存保存数据,如图9所示,Reader本地进程空间不再申请内存保存数据,系统内存开销与进程数量不成正比例关系。相比使用消息进行进程间同步的方式,极大的节约了系统内存开销。When using this method for data synchronization, related processes can perceive the addition, modification, and deletion of data. And can obtain the corresponding data information when the corresponding logic processing is performed. Achieve the same effect as using data to synchronize data between processes. The business in the process does not care about how the data is synchronized, just focus on its own business logic processing. When the data is in a stable state, only the Source process and the shared memory will apply for memory to save data. As shown in Figure 9, the Reader local process space no longer applies for memory to save data, and the system memory overhead is not proportional to the number of processes. Compared to the way of using messages to synchronize between processes, the system memory overhead is greatly saved.
对照上述基于共享内存的数据同步模型中的三个角色,在实施部署时,只需要遵循Writer和Reader分布于同一个CPU的原则,部署时有较大的灵活性。在单CPU环境,只需设置一个Writer,在多CPU环境,可在每个CPU上分别设置一个Writer。对于三种角色,也可以按照实际需要,灵活设置。在集中式和分布式环境,可使用的不同部署方式有很多种,下面进行举例说明。In contrast to the three roles in the above-mentioned shared memory-based data synchronization model, when implementing the deployment, only the principle that the Writer and the Reader are distributed on the same CPU are required, and the deployment has greater flexibility. In a single CPU environment, you only need to set up a Writer. In a multi-CPU environment, you can set a Writer on each CPU. For the three roles, you can also flexibly set them according to actual needs. There are many different deployment methods that can be used in a centralized and distributed environment. The following is an example.
图16是根据本发明实施例的数据同步模型部署的示意图一,如图16所示,集中式环境下,独立设置一个共享内存写者进程(Writer),负责操作共享内存数据。多个Reader可处于同一个进程中,也可处于不同的进程中,Reader所处的进程和Writer进程映射到相同的共享内存空间。FIG. 16 is a first schematic diagram of a data synchronization model deployment according to an embodiment of the present invention. As shown in FIG. 16, in a centralized environment, a shared memory writer process (Writer) is independently set up, and is responsible for operating shared memory data. Multiple Readers can be in the same process or in different processes. The process in which Reader is located and the Writer process map to the same shared memory space.
图17是根据本发明实施例的数据同步模型部署的示意图二,如图17所示,集中式环境下,Writer和Source处于同一个进程中,Writer作为Source进程中的一个线程来负责操作共享内存。多个Reader可处于同一个进程中,也可分布在不同的进程中,Reader所处的进程和Writer进程映射到相同的共享内存空间。17 is a schematic diagram 2 of a data synchronization model deployment according to an embodiment of the present invention. As shown in FIG. 17, in a centralized environment, a Writer and a Source are in the same process, and a Writer is used as a thread in the Source process to operate the shared memory. . Multiple Readers can be in the same process or distributed in different processes. The process in which Reader is located and the Writer process are mapped to the same shared memory space.
图18是根据本发明实施例的数据同步模型部署的示意图三,如图18所示,分布式环境下,R-CPU上的Writer和Source处于同一个进程中,L-CPU中部署单独的Writer进程,分别为各自CPU上的Reader提供数据服务,进程B中有两个线程同时使能共享内存,但是只占一份线性空间,Source仍然看到两个Reader。FIG. 18 is a third schematic diagram of a data synchronization model deployment according to an embodiment of the present invention. As shown in FIG. 18, in a distributed environment, a Writer and a Source on an R-CPU are in the same process, and a separate Writer is deployed in the L-CPU. The process provides data services for Reader on each CPU. Two threads in process B enable shared memory at the same time, but only occupy a linear space. Source still sees two Readers.
图19是根据本发明实施例的数据同步模型部署的示意图四,如图19所示,分布式环境下,各个CPU都独立设置一个共享内存写进程(Writer),负责各自CPU上的共享内存写操作,为各自CPU上的Reader提供数据服务。FIG. 19 is a schematic diagram 4 of a data synchronization model deployment according to an embodiment of the present invention. As shown in FIG. 19, in a distributed environment, each CPU independently sets a shared memory write process (Writer), which is responsible for shared memory writes on respective CPUs. Operation, providing data services for Reader on their respective CPUs.
图20是根据本发明实施例的数据同步模型部署的示意图五,如图20所示,多个Source的情况,不同的数据可以有不同的Source,但统一由一个Writer负责写共享内存。在集中式环境,多个Source可以处于不同的进程,也可以处于同一进程的不同线程。在分布式环境,多个Source可以处于同一个CPU上,也可以处于不同的CPU上,可采用的部署方式更多。为集中式环境下的两个Source处于不同进程的时的部署方式。FIG. 20 is a schematic diagram 5 of a data synchronization model deployment according to an embodiment of the present invention. As shown in FIG. 20, in the case of multiple Sources, different data may have different Sources, but a Writer is responsible for writing shared memory. In a centralized environment, multiple Sources can be in different processes or in different threads of the same process. In a distributed environment, multiple Sources can be on the same CPU or on different CPUs. The deployment mode for two sources in a centralized environment when they are in different processes.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用 的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the above various modules or steps of the present invention can be used universally. Implemented by computing devices, which may be centralized on a single computing device or distributed over a network of computing devices. Alternatively, they may be implemented in program code executable by the computing device, such that They are stored in a storage device and are executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that herein, or they may be separately fabricated into individual integrated circuit modules, or Multiple modules or steps in the fabrication are implemented as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention.
工业实用性Industrial applicability
基于本发明实施例提供的上述技术方案,采用对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。 According to the foregoing technical solution provided by the embodiment of the present invention, the data in the shared memory is updated; the completion message of completing the update of the data in the shared memory is sent to one or more threads; and the shared memory is shared according to the completion message. The updated data is provided to the one or more threads for service processing, and solves the problem that the multi-process uses the shared memory in the related technology, and the data change in the shared memory cannot be sensed in time, so that the shared memory can be known in time. The status of the data.

Claims (10)

  1. 一种数据更新处理方法,包括:A data update processing method includes:
    对共享内存中的数据进行更新;Update data in shared memory;
    向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;Sending a completion message to the one or more threads that the update of the data in the shared memory is complete;
    根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。And updating the updated data in the shared memory to the one or more threads for service processing according to the completion message.
  2. 根据权利要求1所述的方法,其中,在对共享内存中的所述数据进行更新之前还包括:The method of claim 1 further comprising: prior to updating said data in the shared memory:
    向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。Sending an indication message to the one or more threads, wherein the indication message is used to indicate that the one or more threads are in an updated state.
  3. 一种数据更新处理方法,包括:A data update processing method includes:
    接收对共享内存中的数据更新完成的完成消息;Receiving a completion message that the update of the data in the shared memory is completed;
    根据所述完成消息访问共享内存中更新完成后的所述数据。The data after the completion of the update in the shared memory is accessed according to the completion message.
  4. 根据权利要求3所述的方法,其中,在接收对共享内存中的数据更新完成的完成消息之前还包括:The method of claim 3, further comprising: before receiving the completion message of the update of the data in the shared memory:
    接收用于指示共享内存中的所述数据处于更新状态的指示消息;Receiving an indication message indicating that the data in the shared memory is in an updated state;
    根据所述指示消息建立所述数据处于更新状态的标识;And establishing, according to the indication message, an identifier that the data is in an updated state;
    在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。The identification is deleted after receiving a completion message for the completion of the update of the data in the shared memory.
  5. 根据权利要求3所述的方法,其中,在根据所述完成消息访问共享内存中更新完成后的所述数据之前,还包括以下至少之一:The method according to claim 3, wherein at least one of the following is included before the updated data in the shared memory is accessed according to the completion message:
    在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;When updating the data in the shared memory to add data, receiving an indication message carrying the keyword of the data, creating null data corresponding to the keyword of the data, and adding data to the shared memory is completed. After deleting the empty data;
    在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;When the data in the shared memory is updated to modify or delete the data, the indication message carrying the keyword of the data is received, and the old data before the update in the shared memory is obtained according to the keyword of the data and is backed up. After the shared memory is modified or deleted, the old data is deleted;
    在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消 息后,删除所有已创建标记;In the case that the data in the shared memory is updated to one or more threads newly added or restarted, an indication message carrying the keyword carrying the data is received, and the data according to the data is marked as the data in the overall synchronization phase. Created, after the completion of all data in the shared memory is created, the overall synchronization is completed. After deleting the message, delete all created tags;
    在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继续访问所述共享内存中数据的老化标记。In the case where the data update in the shared memory is restarted by the Source process, empty data for prohibiting access to the data from the shared memory is created; or an aging flag for continuing access to the data in the shared memory is marked.
  6. 一种数据更新处理装置,包括:A data update processing device includes:
    更新模块,设置为对共享内存中的数据进行更新;Update module, set to update data in shared memory;
    第一发送模块,设置为向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;a first sending module, configured to send a completion message to the one or more threads that the update of the data in the shared memory is completed;
    提供发送模块,设置为根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。Providing a sending module, configured to provide the updated data in the shared memory to the one or more threads for service processing according to the completion message.
  7. 根据权利要求6所述的装置,其中,所述装置还包括:The apparatus of claim 6 wherein said apparatus further comprises:
    第二发送模块,设置为向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。And a second sending module, configured to send an indication message to the one or more threads, wherein the indication message is used to indicate that the one or more threads are in an updated state.
  8. 一种数据更新处理装置,包括:A data update processing device includes:
    第一接收模块,设置为接收对共享内存中的数据更新完成的完成消息;a first receiving module, configured to receive a completion message for completing data update in the shared memory;
    访问模块,设置为根据所述完成消息访问共享内存中更新完成后的所述数据。The access module is configured to access the data after the update in the shared memory is completed according to the completion message.
  9. 根据权利要求8所述的装置,其中,所述装置还包括:The apparatus of claim 8 wherein said apparatus further comprises:
    第二接收模块,设置为接收用于指示共享内存中的所述数据处于更新状态的指示消息;a second receiving module, configured to receive an indication message indicating that the data in the shared memory is in an updated state;
    建立模块,设置为根据所述指示消息建立所述数据处于更新状态的标识;Establishing a module, configured to establish, according to the indication message, an identifier that the data is in an updated state;
    删除模块,设置为在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。The delete module is set to delete the identifier after receiving a completion message for completing the update of the data in the shared memory.
  10. 根据权利要求8所述的装置,其中,所述装置还包括以下至少之一:The apparatus of claim 8 wherein said apparatus further comprises at least one of:
    第一处理模块,设置为在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;The first processing module is configured to: when the data in the shared memory is updated to add data, receive an indication message carrying the keyword of the data, and create null data corresponding to the keyword of the data, where After the shared memory is added, the null data is deleted;
    第二处理模块,设置为在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享 内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;a second processing module, configured to: when the data in the shared memory is updated to modify or delete data, receive an indication message carrying the keyword of the data, and obtain a share according to the keyword of the data. The old data before the update in the memory is backed up, and after the shared memory is modified or deleted, the old data is deleted;
    第三处理模块,设置为在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;a third processing module, configured to: when the data in the shared memory is updated to one or more threads newly added or restarted, receive an indication message carrying the keyword of the data, and mark the keyword according to the data The data has been created for the overall synchronization phase, and all created tags are deleted after receiving the overall synchronization completion message after all the data in the shared memory is created.
    第四处理模块,设置为在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继续访问所述共享内存中数据的老化标记。 a fourth processing module, configured to create null data for prohibiting access to data from the shared memory in a case where the data in the shared memory is updated to be restarted by the source process; or, the mark is used to continue accessing the share An aging token for in-memory data.
PCT/CN2015/087950 2014-11-26 2015-08-24 Data update processing method and apparatus WO2016082594A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410705473.1A CN105700962A (en) 2014-11-26 2014-11-26 Data update processing method and apparatus
CN201410705473.1 2014-11-26

Publications (1)

Publication Number Publication Date
WO2016082594A1 true WO2016082594A1 (en) 2016-06-02

Family

ID=56073550

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/087950 WO2016082594A1 (en) 2014-11-26 2015-08-24 Data update processing method and apparatus

Country Status (2)

Country Link
CN (1) CN105700962A (en)
WO (1) WO2016082594A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379952A (en) * 2020-12-09 2021-02-19 成都傲梅科技有限公司 Method for implementing cross-process callback
CN112559196A (en) * 2019-09-10 2021-03-26 航天科工惯性技术有限公司 Transmission method for interprocess communication data sharing
CN114490141A (en) * 2022-04-14 2022-05-13 中国电子科技集团公司第二十八研究所 High-concurrency IPC data interaction method based on shared memory

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109814891B (en) * 2017-11-16 2023-08-08 中兴通讯股份有限公司 Data updating method and device
CN109343979A (en) * 2018-09-28 2019-02-15 珠海沙盒网络科技有限公司 A kind of configuring management method and system
CN116401317B (en) * 2023-04-19 2023-11-17 中国环球租赁有限公司 Cache data synchronization method and device, electronic equipment and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101207515A (en) * 2007-12-12 2008-06-25 中兴通讯股份有限公司 Processing method, implementation method and synchronization method of multi-machine sharing internal memory
CN103064748A (en) * 2013-01-05 2013-04-24 浪潮电子信息产业股份有限公司 Method for processing communication among multiple processes in Linux system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005135382A (en) * 2003-08-19 2005-05-26 Toshiba Corp System and method for shared memory-based inter-process communication queue template having event-based notification
US8555292B2 (en) * 2008-06-27 2013-10-08 Microsoft Corporation Synchronizing communication over shared memory
US8103838B2 (en) * 2009-01-08 2012-01-24 Oracle America, Inc. System and method for transactional locking using reader-lists
CN102426536B (en) * 2011-10-26 2014-04-09 深圳市亚特尔科技有限公司 Multitask data communication implementation method and system
CN102385526A (en) * 2011-11-16 2012-03-21 深圳市大赢家网络有限公司 Method and device for sharing stock data among multiple processes
CN103150220B (en) * 2011-12-07 2016-08-31 腾讯科技(深圳)有限公司 Communication means between process and communication system
CN102541663A (en) * 2011-12-28 2012-07-04 创新科软件技术(深圳)有限公司 Method for ensuring multiple processes to use shared memories to carry out communication

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101207515A (en) * 2007-12-12 2008-06-25 中兴通讯股份有限公司 Processing method, implementation method and synchronization method of multi-machine sharing internal memory
CN103064748A (en) * 2013-01-05 2013-04-24 浪潮电子信息产业股份有限公司 Method for processing communication among multiple processes in Linux system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559196A (en) * 2019-09-10 2021-03-26 航天科工惯性技术有限公司 Transmission method for interprocess communication data sharing
CN112559196B (en) * 2019-09-10 2024-03-26 航天科工惯性技术有限公司 Transmission method for sharing communication data between processes
CN112379952A (en) * 2020-12-09 2021-02-19 成都傲梅科技有限公司 Method for implementing cross-process callback
CN112379952B (en) * 2020-12-09 2023-04-07 成都傲梅科技有限公司 Method for implementing cross-process callback
CN114490141A (en) * 2022-04-14 2022-05-13 中国电子科技集团公司第二十八研究所 High-concurrency IPC data interaction method based on shared memory
CN114490141B (en) * 2022-04-14 2022-07-05 中国电子科技集团公司第二十八研究所 High-concurrency IPC data interaction method based on shared memory

Also Published As

Publication number Publication date
CN105700962A (en) 2016-06-22

Similar Documents

Publication Publication Date Title
WO2016082594A1 (en) Data update processing method and apparatus
US11010358B2 (en) Data migration method and system
CN112069265B (en) Synchronization method of configuration data, business data system, computer system and medium
CN106878376B (en) Configuration management method and system
US9753954B2 (en) Data node fencing in a distributed file system
EP2180663B1 (en) Trickle sync protocol
CN106815218B (en) Database access method and device and database system
CN108319623B (en) Data redistribution method and device and database cluster
CN109547512B (en) NoSQL-based distributed Session management method and device
CN102333029B (en) Routing method in server cluster system
US9367261B2 (en) Computer system, data management method and data management program
CN112286905A (en) Data migration method and device, storage medium and electronic equipment
CN111143382A (en) Data processing method, system and computer readable storage medium
US20140156598A1 (en) Replication control using eventually consistent meta-data
KR101545626B1 (en) System for interoperation between dds and dbms
CN111343241B (en) Graph data updating method, device and system
CN105208060A (en) Service data synchronization method, service data synchronization device and service data synchronization system
CN112181049B (en) Cluster time synchronization method, device, system, equipment and readable storage medium
CN117435569A (en) Dynamic capacity expansion method, device, equipment, medium and program product for cache system
CN112052104A (en) Message queue management method based on multi-computer-room realization and electronic equipment
CN114500289B (en) Control plane recovery method, device, control node and storage medium
CN115189931A (en) Distributed key management method, device, equipment and storage medium
WO2021147926A1 (en) Methods and systems for hybrid edge replication
Vasconcelos et al. Dynamic and coordinated software reconfiguration in distributed data stream systems
CN112187916A (en) Cross-system data synchronization method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15864266

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15864266

Country of ref document: EP

Kind code of ref document: A1