WO2016082594A1 - 数据更新处理方法及装置 - Google Patents

数据更新处理方法及装置 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
English (en)
French (fr)
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/zh

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

本发明公开了数据更新处理方法及装置,其中,该方法包括:对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的该数据更新完成的完成消息;根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理,通过本发明,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。

Description

数据更新处理方法及装置 技术领域
本发明涉及通信领域,具体而言,涉及数据更新处理方法及装置。
背景技术
随着Internet的发展,路由器的功能日益复杂,集中式的控制面处理已经不能满足运营商的需求,控制面的分布式、多进程的实现方式成为由器的一个发展趋势。IP的开放性、多样性、以及传统电信的各种业务都不断的迁移到IP承载上,导致IP各种新协议、新业务不断快速推出。为支持协议功能的裁剪、独立发布版本、独立升级,导致了多进程的实现方式,且进程划分的非常细,甚至每个协议都运行在独立的进程空间中。支持协议分布式运行,不同的协议进程可运行在不同的协议处理单元中。另外,采用多进程的实现方式,也解决了软件各组件故障相互影响的问题,避免随着软件规模扩大,开发功能的难度不断增加及版本稳定性降低,故障收敛慢的问题。
各协议运行在不同进程,但有些数据信息是各个进程都需要的,例如端口信息。在运行的协议进程越来越多的情况下,如果各进程都保存一份重复的数据,对内存资源是很大的浪费。在运营商对通信设备功能需求不断增多,性能要求不断提高的情况下,设备需要支持的端口类型、数量越来越多,***的内存资源越来越紧缺(其对内存的消耗是按照端口数量和协议进程数量乘积的形式进行增长)。图1是相关技术中数据同步模型的示意图,如图1所示,在使用消息进行进程间数据同步的方式下,各个进程空间都申请内存保存了一份数据。
如果各个进程使用共享内存的方式对数据进行共享访问,则可以极大的降低***内存的消耗。但操作***所支持的共享内存,仅提供进程对共享内存进行主动读、写。在共享内存中的数据变化时,相关进程无法及时的被动感知,只能在后续主动查询时得到变化后的数据,此时已无法知道具体哪些信息字段发生了变化,以及变化前的值是多少。这种方式难以满足一些场景的实现需要。例如,对端口进行IP配置,将IP信息写入共享内存后,路由协议进程需要及时感知到端口上IP的添加事件,对路由进行重新计算;将光纤***PPP口,PPP端口的物理UP状态更新到共享内存后,PPP协议进程需要及时感知物理UP事件,和对端设备进行协商建链。如果各个协议都定时轮询检查数据的变化,定时周期太长,则及时性得不到保证;定时周期太短,则对***性能是很大的消耗,影响设备对正常业务的处理能力。且通过轮询的方式,在数据修或删除之后才能发现,已获取不到修改前或删除前的数据。
针对相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,目前尚未提出有效的解决方案。
发明内容
本发明提供了数据更新处理方法及装置,以至少解决相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题。
根据本发明的一个实施例,提供了一种数据更新处理方法,包括:对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。
在本发明实施例中,在对共享内存中的所述数据进行更新之前还包括:向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。
根据本发明的另一实施例,提供了一种数据更新处理方法,包括:接收对共享内存中的数据更新完成的完成消息;根据所述完成消息访问共享内存中更新完成后的所述数据。
在本发明实施例中,在接收对共享内存中的数据更新完成的完成消息之前还包括:接收用于指示共享内存中的所述数据处于更新状态的指示消息;
根据所述指示消息建立所述数据处于更新状态的标识;
在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。
在本发明实施例中,在根据所述完成消息访问共享内存中更新完成后的所述数据之前,还包括以下至少之一:在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继 续访问所述共享内存中数据的老化标记。
根据本发明的另一实施例,提供了一种数据更新处理装置,包括:更新模块,设置为对共享内存中的数据进行更新;第一发送模块,设置为向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;提供发送模块,设置为根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。
在本发明实施例中,所述装置还包括:第二发送模块,设置为向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。
根据本发明的另一实施例,提供了一种数据更新处理装置,包括:第一接收模块,设置为接收对共享内存中的数据更新完成的完成消息;访问模块,设置为根据所述完成消息访问共享内存中更新完成后的所述数据。
在本发明实施例中,所述装置还包括:第二接收模块,设置为接收用于指示共享内存中的所述数据处于更新状态的指示消息;建立模块,设置为根据所述指示消息建立所述数据处于更新状态的标识;删除模块,设置为在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。
在本发明实施例中,所述装置还包括以下至少之一:第一处理模块,设置为在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;第二处理模块,设置为在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;第三处理模块,设置为在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;第四处理模块,设置为在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继续访问所述共享内存中数据的老化标记。
通过本发明,采用对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1是相关技术中数据同步模型的示意图;
图2是根据本发明实施例的数据更新处理方法的流程图一;
图3是根据本发明实施例的数据更新处理方法的流程图二;
图4是根据本发明实施例的数据更新处理装置的框图一;
图5是根据本发明优选实施例的数据更新处理装置的框图一;
图6是根据本发明实施例的数据更新处理装置的框图二;
图7是根据本发明优选实施例的数据更新处理装置的框图二;
图8是根据本发明优选实施例的数据更新处理装置的框图三;
图9是根据本发明实施例的数据同步模型的示意图;
图10是根据本发明实施例的数据同步中数据添加的示意图;
图11是根据本发明实施例的数据同步中数据修改的示意图;
图12是根据本发明实施例的数据同步中数据删除的示意图;
图13是根据本发明实施例的数据同步中整体同步的示意图;
图14是根据本发明实施例的数据同步中Source重启的示意图一;
图15是根据本发明实施例的数据同步中Source重启的示意图二;
图16是根据本发明实施例的数据同步模型部署的示意图一;
图17是根据本发明实施例的数据同步模型部署的示意图二;
图18是根据本发明实施例的数据同步模型部署的示意图三;
图19是根据本发明实施例的数据同步模型部署的示意图四;
图20是根据本发明实施例的数据同步模型部署的示意图五。
具体实施方式
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。
在本实施例中提供了一种数据更新处理方法,图2是根据本发明实施例的数据更新处理方法的流程图一,如图2所示,该流程包括如下步骤:
步骤S202,对共享内存中的数据进行更新;
步骤S204,向一个或多个线程发送对共享内存中的该数据更新完成的完成消息;
步骤S206,根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理。
通过上述步骤,对共享内存中的数据进行更新,向一个或多个线程发送对共享内存中的该数据更新完成的完成消息,根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。
在本发明实施例中,在对共享内存中的该数据进行更新之前还包括:向该一个或多个线程发送指示消息,其中,该指示消息用于指示该一个或多个线程该数据处于更新状态。
本发明实施例还提供了一种数据更新处理方法,图3是根据本发明实施例的数据更新处理方法的流程图二,如图3所示,包括:
步骤S302,接收对共享内存中的数据更新完成的完成消息;
步骤S304,根据该完成消息访问共享内存中更新完成后的该数据。
通过上述步骤,接收对共享内存中的数据更新完成的完成消息,根据该完成消息访问共享内存中更新完成后的该数据,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。
为了更好的获知共享内存中数据的状态,在一个可选的实施例中中,在接收对共享内存中的数据更新完成的完成消息之前,接收用于指示共享内存中的该数据处于更新状态的指示消息;根据该指示消息建立该数据处于更新状态的标识;在接收到对共享内存中的数据更新完成的完成消息之后,删除该标识,之后确定共享内存中的数据位更新后的数据。
在根据该完成消息访问共享内存中更新完成后的该数据之前,还可以包括以下至少之一:在对共享内存中的数据更新为添加数据的情况下,接收携带有该数据的关键字的指示消息,创建与该数据的关键字对应的空数据,在对该共享内存添加数据完成 后,删除该空数据;在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字获取共享内存中的更新前的旧数据并进行备份,在该共享内存修改或删除数据完成后,删除该旧数据;在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字标记为整体同步阶段该数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从该共享内存中访问数据的空数据;或者,标记上用于继续访问该共享内存中数据的老化标记。
本发明实施例提供了一种数据更新处理装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。
图4是根据本发明实施例的数据更新处理装置的框图一,如图4所示,包括:更新模块42、第一发送模块44和提供发送模块46,下面对各个模块进行简要说明。
更新模块42,设置为对共享内存中的数据进行更新;
第一发送模块44,设置为向一个或多个线程发送对共享内存中的该数据更新完成的完成消息;
提供发送模块46,设置为根据该完成消息将共享内存中更新后的该数据提供给该一个或多个线程进行业务处理。
图5是根据本发明优选实施例的数据更新处理装置的框图一,如图5所示,该装置还包括:
第二发送模块52,设置为向该一个或多个线程发送指示消息,其中,该指示消息用于指示该一个或多个线程该数据处于更新状态。
本发明实施例还提供了一种数据更新处理装置,图6是根据本发明实施例的数据更新处理装置的框图二,如图6所示,包括:
第一接收模块62,设置为接收对共享内存中的数据更新完成的完成消息;
访问模块64,设置为根据该完成消息访问共享内存中更新完成后的该数据。
图7是根据本发明优选实施例的数据更新处理装置的框图二,如图7所示,该装置还包括:
第二接收模块72,设置为接收用于指示共享内存中的该数据处于更新状态的指示 消息;
建立模块74,设置为根据该指示消息建立该数据处于更新状态的标识;
删除模块76,设置为在接收到对共享内存中的数据更新完成的完成消息之后,删除该标识。
图8是根据本发明优选实施例的数据更新处理装置的框图三,如图8所示,该装置还包括以下至少之一:
第一处理模块82,设置为在对共享内存中的数据更新为添加数据的情况下,接收携带有该数据的关键字的指示消息,创建与该数据的关键字对应的空数据,在对该共享内存添加数据完成后,删除该空数据;
第二处理模块84,设置为在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字获取共享内存中的更新前的旧数据并进行备份,在该共享内存修改或删除数据完成后,删除该旧数据;
第三处理模块86,设置为在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有该数据的关键字的指示消息,根据该数据的关键字标记为整体同步阶段该数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;
第四处理模块88,设置为在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从该共享内存中访问数据的空数据;或者,标记上用于继续访问该共享内存中数据的老化标记。
下面以一个或多个线程为Reader为例对本发明实施例进行进一步说明。
本可选实施例使需要访问共享内存的相关进程可及时感知到共享内存中数据的添加、修改、删除操作事件,并依据事件控制进程对共享内存中数据的访问。在感知到数据添加事件前进程不能访问到共享内存中的数据,感知到数据添加事件后才能访问到数据;在感知到数据修改事件前,进程只能访问到修改前的数据,在感知到数据修改事件时,能同时访问到修改前和修改后的数据(可对比修改前、后的数据),在感知到修改事件后,进程可以访问到修改后的数据;在感知数据删除事件前,进程可以访问到共享内存中的数据,感知到数据删除事件后,不能访问到共享内存中的数据。对于进程重启的情况,同样依据事件来控制进程对共享内存的访问。该方法可以使进程参与到共享内存数据添加、修改、删除的过程中,使进程能及时进行相关逻辑处理,并在处理时能获取到所需的数据信息。
本可选实施例提供了一种基于共享内存的数据同步方法,在共享内存中的数据发 生变化时,可及时通知到相关进程,并协调进程及时进行相关逻辑处理,即处理时能访问到所需的数据,对于新数据添加,可以获取到新数据;对于数据修改,能获取到修改前和修改后的数据;对于数据删除,能获取到即将删除的数据。在减少内存开销的同时,也满足各种应用场景的要求,达到与使用消息进行进程间数据同步方式同样的效果。
下面基于共享内存的数据同步方法模型中涉及的三个角色进行说明。
源Source,数据的产生源头,接受Writer和Reader注册。
写者Writer,负责将Source产生的数据写入共享内存。
读者Reader,需要访问共享内存数据的进程(或线程),例如各协议进程。
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本地进程空间创建相应数据的“空数据”,用于表示相应数据还没有创建。当某进程本地存在“空数据”时,即使共享内存中已经存在相应的数据,对该进程也不可见。
图9是根据本发明实施例的数据同步模型的示意图,如图9所示,Source中数据添加、修改、删除时,首先通知各个Reader进行预处理,所有Reader预处理完成后,通知Writer更新共享内存中的数据,Writer操作完成后,Source再通知各个Reader更新完成,Reader进行相应的业务逻辑处理。
图10是根据本发明实施例的数据同步中数据添加的示意图,如图10所示,Source通过消息将数据的关键字发送给Reader,通知Reader在LND中创建该关键字对应的“空数据”,以表示该关键字对应的数据还没有创建(即使共享内存中已经有了,也不可见);所有Reader创建完“空数据”后,Source通知Writer在共享内存中创建新数据,完成后Source再通知Reader创建完成,Reader做新数据创建逻辑处理,并将该关键字对应的“空数据”删除,表示该关键字对应的数据已经创建完成,后续Reader 可以直接从共享内存中访问该数据。
图11是根据本发明实施例的数据同步中数据修改的示意图,如图11所示,Source通过消息将数据的关键字发送给Reader,Reader通过关键字在共享内存中查询修改前的“旧数据”,并将“旧数据”备份到Reader进程本地的LOD中,以表示共享内存中的该数据处于不稳定状态,正发生变化(LOD中存在“旧数据”时,Reader只能查询到LOD中的“旧数据”,共享内存中的相应数据不可见)。Source通知Writer将共享内存中的数据修改完成后,再通知Reader数据修改完成,Reader做数据修改逻辑处理(此时能访问到LOD中的“旧数据”和共享内存中的修改后的数据,),并将LOD中备份的“旧数据”删除,表示该关键字对应的数据已经修改完成,目前处于稳定状态,后续Reader可以直接从共享内存中访问该数据。
图12是根据本发明实施例的数据同步中数据删除的示意图,如图12所示,Reader进行数据备份的流程与数据修改时所做的备份流程类似。Source通过消息将数据的关键字发送给Reader,Reader通过关键字从共享内存中查询数据,并将数据备份到Reader进程本地的LOD中,以表示共享内存中的该数据处于不稳定状态,正进行删除。Source通知Writer将共享内存中的数据删除完成后,再通知Reader删除完成,Reader做数据删除逻辑处理(此时可以查询到即将删除的数据信息),并将LOD中的备份数据删除,表示该关键字对应的数据已经删除完成。后续Reader在共享内存中将查询不到该关键字对应的数据。
图13是根据本发明实施例的数据同步中整体同步的示意图,如图13所示,对于共享内存中已经存在数据,新的Reader后加入的情况,因该Reader还没有感知过相应数据的创建,没有进行过新数据创建逻辑处理,此时不允许该Reader访问到共享内存中的数据。需要将共享内存中已经存在的数据向Reader进行一次整体同步,Reader感知到数据创建事件后,才能访问到共享内存中的数据。
对于新加入的Reader,将同步状态标记为整体同步阶段,Source直接将已经存在的数据关键字发送给Reader,使Reader感知创建事件。对于已经收到过创建事件的数据,Reader在本地创建相应的记录,打上“已创建”标记。对于具有“已创建”记录的数据,Reader可以在共享内存中查询到数据,否则共享内存中的数据对该Reader不可见。Source将所有的数据通知Reader创建完成后,通知Reader整体同步完成,Reader将同步状态标志修改变化同步阶段,并将本地所有的“已创建”记录删除。
Reader重启的情况下,Reader进程退出时,Source将该Reader从注册列表中删除,数据可继续向其他Reader同步。该Reader起来后,重新向Source注册,Source按照整体同步流程,向该Reader进行数据同步。某个Reader重启过程中,Source可以向其他Reader正常同步数据,对其他Reader无影响。
Source重启:对于Source进程重启的情况,可根据场景需要分别采用如下两种实现方式。
图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删除共享内存中仍然具有“老化”标记的数据。
图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进行“垃圾”数据处理,删除共享内存中仍然存在“老化”标记的数据。
在使用该方法进行数据同步时,相关进程可以感知到数据的添加、修改、删除事 件,并在感知到事件进行相应的逻辑处理时能获取到相应的数据信息。达到与使用消息进行进程间数据同步同样的效果。进程中的业务可不关心数据是通过何种方式进行同步,只需专注于自身的业务逻辑处理。在数据处于稳定状态时,只有Source进程和共享内存会申请内存保存数据,如图9所示,Reader本地进程空间不再申请内存保存数据,***内存开销与进程数量不成正比例关系。相比使用消息进行进程间同步的方式,极大的节约了***内存开销。
对照上述基于共享内存的数据同步模型中的三个角色,在实施部署时,只需要遵循Writer和Reader分布于同一个CPU的原则,部署时有较大的灵活性。在单CPU环境,只需设置一个Writer,在多CPU环境,可在每个CPU上分别设置一个Writer。对于三种角色,也可以按照实际需要,灵活设置。在集中式和分布式环境,可使用的不同部署方式有很多种,下面进行举例说明。
图16是根据本发明实施例的数据同步模型部署的示意图一,如图16所示,集中式环境下,独立设置一个共享内存写者进程(Writer),负责操作共享内存数据。多个Reader可处于同一个进程中,也可处于不同的进程中,Reader所处的进程和Writer进程映射到相同的共享内存空间。
图17是根据本发明实施例的数据同步模型部署的示意图二,如图17所示,集中式环境下,Writer和Source处于同一个进程中,Writer作为Source进程中的一个线程来负责操作共享内存。多个Reader可处于同一个进程中,也可分布在不同的进程中,Reader所处的进程和Writer进程映射到相同的共享内存空间。
图18是根据本发明实施例的数据同步模型部署的示意图三,如图18所示,分布式环境下,R-CPU上的Writer和Source处于同一个进程中,L-CPU中部署单独的Writer进程,分别为各自CPU上的Reader提供数据服务,进程B中有两个线程同时使能共享内存,但是只占一份线性空间,Source仍然看到两个Reader。
图19是根据本发明实施例的数据同步模型部署的示意图四,如图19所示,分布式环境下,各个CPU都独立设置一个共享内存写进程(Writer),负责各自CPU上的共享内存写操作,为各自CPU上的Reader提供数据服务。
图20是根据本发明实施例的数据同步模型部署的示意图五,如图20所示,多个Source的情况,不同的数据可以有不同的Source,但统一由一个Writer负责写共享内存。在集中式环境,多个Source可以处于不同的进程,也可以处于同一进程的不同线程。在分布式环境,多个Source可以处于同一个CPU上,也可以处于不同的CPU上,可采用的部署方式更多。为集中式环境下的两个Source处于不同进程的时的部署方式。
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用 的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。
工业实用性
基于本发明实施例提供的上述技术方案,采用对共享内存中的数据进行更新;向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理,解决了相关技术中多进程使用共享内存时,无法及时感知共享内存中数据变化的问题,从而能够及时获知共享内存中数据的状态。

Claims (10)

  1. 一种数据更新处理方法,包括:
    对共享内存中的数据进行更新;
    向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;
    根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。
  2. 根据权利要求1所述的方法,其中,在对共享内存中的所述数据进行更新之前还包括:
    向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。
  3. 一种数据更新处理方法,包括:
    接收对共享内存中的数据更新完成的完成消息;
    根据所述完成消息访问共享内存中更新完成后的所述数据。
  4. 根据权利要求3所述的方法,其中,在接收对共享内存中的数据更新完成的完成消息之前还包括:
    接收用于指示共享内存中的所述数据处于更新状态的指示消息;
    根据所述指示消息建立所述数据处于更新状态的标识;
    在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。
  5. 根据权利要求3所述的方法,其中,在根据所述完成消息访问共享内存中更新完成后的所述数据之前,还包括以下至少之一:
    在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;
    在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;
    在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消 息后,删除所有已创建标记;
    在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继续访问所述共享内存中数据的老化标记。
  6. 一种数据更新处理装置,包括:
    更新模块,设置为对共享内存中的数据进行更新;
    第一发送模块,设置为向一个或多个线程发送对共享内存中的所述数据更新完成的完成消息;
    提供发送模块,设置为根据所述完成消息将共享内存中更新后的所述数据提供给所述一个或多个线程进行业务处理。
  7. 根据权利要求6所述的装置,其中,所述装置还包括:
    第二发送模块,设置为向所述一个或多个线程发送指示消息,其中,所述指示消息用于指示所述一个或多个线程所述数据处于更新状态。
  8. 一种数据更新处理装置,包括:
    第一接收模块,设置为接收对共享内存中的数据更新完成的完成消息;
    访问模块,设置为根据所述完成消息访问共享内存中更新完成后的所述数据。
  9. 根据权利要求8所述的装置,其中,所述装置还包括:
    第二接收模块,设置为接收用于指示共享内存中的所述数据处于更新状态的指示消息;
    建立模块,设置为根据所述指示消息建立所述数据处于更新状态的标识;
    删除模块,设置为在接收到对共享内存中的数据更新完成的完成消息之后,删除所述标识。
  10. 根据权利要求8所述的装置,其中,所述装置还包括以下至少之一:
    第一处理模块,设置为在对共享内存中的数据更新为添加数据的情况下,接收携带有所述数据的关键字的指示消息,创建与所述数据的关键字对应的空数据,在对所述共享内存添加数据完成后,删除所述空数据;
    第二处理模块,设置为在对共享内存中的数据更新为修改或删除数据的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字获取共享 内存中的更新前的旧数据并进行备份,在所述共享内存修改或删除数据完成后,删除所述旧数据;
    第三处理模块,设置为在对共享内存中的数据更新为一个或多个线程新加入或重启的情况下,接收携带有所述数据的关键字的指示消息,根据所述数据的关键字标记为整体同步阶段所述数据已创建,在接收到共享内存中的所有数据创建完成后整体同步完成消息后,删除所有已创建标记;
    第四处理模块,设置为在对共享内存中的数据更新为Source进程重启的情况下,创建用于禁止从所述共享内存中访问数据的空数据;或者,标记上用于继续访问所述共享内存中数据的老化标记。
PCT/CN2015/087950 2014-11-26 2015-08-24 数据更新处理方法及装置 WO2016082594A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410705473.1A CN105700962A (zh) 2014-11-26 2014-11-26 数据更新处理方法及装置
CN201410705473.1 2014-11-26

Publications (1)

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

Family

ID=56073550

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/087950 WO2016082594A1 (zh) 2014-11-26 2015-08-24 数据更新处理方法及装置

Country Status (2)

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

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379952A (zh) * 2020-12-09 2021-02-19 成都傲梅科技有限公司 一种跨进程回调的实现方法
CN112559196A (zh) * 2019-09-10 2021-03-26 航天科工惯性技术有限公司 一种进程间通讯数据共享的传输方法
CN114490141A (zh) * 2022-04-14 2022-05-13 中国电子科技集团公司第二十八研究所 一种基于共享内存的高并发ipc数据交互方法

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109814891B (zh) * 2017-11-16 2023-08-08 中兴通讯股份有限公司 一种数据更新方法及装置
CN109343979A (zh) * 2018-09-28 2019-02-15 珠海沙盒网络科技有限公司 一种配置管理方法及***
CN116401317B (zh) * 2023-04-19 2023-11-17 中国环球租赁有限公司 一种缓存数据同步方法、装置、电子设备及介质

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101207515A (zh) * 2007-12-12 2008-06-25 中兴通讯股份有限公司 一种多机共享内存的处理方法、实现方法和同步方法
CN103064748A (zh) * 2013-01-05 2013-04-24 浪潮电子信息产业股份有限公司 一种Linux下处理多进程间通讯的方法

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7308688B2 (en) * 2003-08-19 2007-12-11 Kabushiki Kaisha Toshiba System and method for shared memory based IPC 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 (zh) * 2011-10-26 2014-04-09 深圳市亚特尔科技有限公司 一种多任务间数据通信的实现方法及***
CN102385526A (zh) * 2011-11-16 2012-03-21 深圳市大赢家网络有限公司 在多进程之间共享股票数据的方法及装置
CN103150220B (zh) * 2011-12-07 2016-08-31 腾讯科技(深圳)有限公司 进程间的通信方法和通信***
CN102541663A (zh) * 2011-12-28 2012-07-04 创新科软件技术(深圳)有限公司 一种多进程使用共享内存进行通信的方法

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101207515A (zh) * 2007-12-12 2008-06-25 中兴通讯股份有限公司 一种多机共享内存的处理方法、实现方法和同步方法
CN103064748A (zh) * 2013-01-05 2013-04-24 浪潮电子信息产业股份有限公司 一种Linux下处理多进程间通讯的方法

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559196A (zh) * 2019-09-10 2021-03-26 航天科工惯性技术有限公司 一种进程间通讯数据共享的传输方法
CN112559196B (zh) * 2019-09-10 2024-03-26 航天科工惯性技术有限公司 一种进程间通讯数据共享的传输方法
CN112379952A (zh) * 2020-12-09 2021-02-19 成都傲梅科技有限公司 一种跨进程回调的实现方法
CN112379952B (zh) * 2020-12-09 2023-04-07 成都傲梅科技有限公司 一种跨进程回调的实现方法
CN114490141A (zh) * 2022-04-14 2022-05-13 中国电子科技集团公司第二十八研究所 一种基于共享内存的高并发ipc数据交互方法
CN114490141B (zh) * 2022-04-14 2022-07-05 中国电子科技集团公司第二十八研究所 一种基于共享内存的高并发ipc数据交互方法

Also Published As

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

Similar Documents

Publication Publication Date Title
WO2016082594A1 (zh) 数据更新处理方法及装置
US11010358B2 (en) Data migration method and system
CN106878376B (zh) 一种配置管理方法与***
CN112069265B (zh) 配置数据的同步方法、业务数据***、计算机***和介质
US9753954B2 (en) Data node fencing in a distributed file system
CN106815218B (zh) 数据库访问方法、装置和数据库***
CN111143382B (zh) 数据处理方法、***和计算机可读存储介质
CN109547512B (zh) 一种基于NoSQL的分布式Session管理的方法及装置
CN113396407A (zh) 用于利用区块链技术扩充数据库应用的***和方法
CN102333029B (zh) 一种服务器集群***中的路由方法
CN108319623B (zh) 一种数据重分布方法、装置及数据库集群
CN112286905A (zh) 数据迁移方法及装置、存储介质、电子设备
US9367261B2 (en) Computer system, data management method and data management program
US20100082732A1 (en) Trickle Sync Protocol
CN110069346B (zh) 多进程间资源共享方法、装置、电子设备
US20140156598A1 (en) Replication control using eventually consistent meta-data
KR101545626B1 (ko) Dds-db 연동 시스템
CN105208060A (zh) 业务数据同步方法、装置及***
CN112181049B (zh) 集群时间同步方法、装置、***、设备及可读存储介质
CN112052104A (zh) 基于多机房实现的消息队列的管理方法及电子设备
CN114500289B (zh) 控制平面恢复方法、装置、控制节点及存储介质
CN115189931A (zh) 一种分布式密钥管理方法、装置、设备、存储介质
WO2021147926A1 (en) Methods and systems for hybrid edge replication
Vasconcelos et al. Dynamic and coordinated software reconfiguration in distributed data stream systems
CN111949731A (zh) 数据同步方法、装置、电子设备及存储介质

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