TECHNICAL FIELD
This application relates to methods for data synchronization.
BACKGROUND
People use various devices to manage information. For example, a person may use a desktop computer to manage a calendar, maintain an address book, and keep a to-do list. The person may also use a laptop computer, a tablet computer, or a smart phone to manage the same information. To be most useful, each device should have the latest version of the information. This can be accomplished by synchronizing the information between the different devices.
People may also share information with others. For example, students may share class notes, and a teacher may publish class assignments on a web site. People can get the latest updates by synchronizing each device.
Data synchronization generally involves detection and identification of changes on each device, together with conflict resolution. Various techniques exist for achieving these aspects of data synchronization, including (1) comparing data records item by item, (2) logging changes made at each device, exchanging logs, and applying changes from each device's log to the other device, and (3) comparing the versions of each data record and choosing the newest version.
To illustrate the prior art technique of synchronizing by comparing data records item by item, FIG. 1a shows a system comprising two exemplary peer devices; local device 110L and remote device 110R. Local device 110L includes a local data store 120L and remote device 110R contains remote data store 120R. FIG. 1b is an example of a local dataset 130L residing in local data store 120L and containing three exemplary data records. Remote dataset 130R is a copy of local dataset 130L residing in remote data store 120R. FIG. 1c shows datasets 140L and 140R after some changes have occurred to datasets 130L and 130R respectively. Record A has changed in local dataset 140L, record B has changed in both datasets 140L and 140R, and record C has been deleted in local dataset 140L. FIG. 1d shows datasets 150L and 150R after data stores 120L and 120R are synchronized. Record A is copied to remote dataset 150R, any conflicts in the changes in record B are resolved and the result is copied to datasets 150L and 150R, and record C is copied back to local dataset 150L. It is readily apparent that item by item record comparison suffers from a number of disadvantages; it gets slower as a dataset grows larger, it depends on the two devices sharing a common clock to find out which record is newer, and it does not handle deletion because it is not possible to tell whether a record has been added to one dataset or deleted from the other dataset after the last synchronization.
To illustrate the prior art technique of synchronizing data using a change log, FIG. 2a shows two exemplary change logs. Change log 210L summarizes the changes to local dataset 130L, and change log 210R summarizes the changes to remote dataset 130R. Change log 210L shows that data records A and B have been updated in local dataset 130L, record C has been deleted, and record D has been added. Change log 210R shows that record B has been updated in remote dataset 130R. FIG. 2b shows datasets 220L and 220R after data stores 120L and 120R are synchronized. Record A is copied to remote dataset 220R, any conflicts in the changes in record B are resolved and the result is copied to datasets 220L and 220R, record C is deleted from remote dataset 220R, and record D is copied to remote dataset 220R. Although the change log technique overcomes the record comparison and deletion disadvantages of the item by item comparison technique, it suffers from two new disadvantages; namely, additional storage for the change log and not knowing when to prune the change log if there are more than two peer devices being synchronized at different times. If a peer device is abandoned, the change log may never be pruned.
To illustrate the prior art technique of synchronizing data by comparing versions of each data record, FIG. 3a is an example of a local dataset 310L residing in local data store 120L and containing three exemplary data records. Remote dataset 310R is a copy of local dataset 310L residing in remote data store 120R. Each record is marked by a “version vector”, a pair of version numbers, {L1,R1}, corresponding to record versions in the data stores of devices 110L and 110R. FIG. 3b shows datasets 320L and 320R after some changes have occurred to datasets 310L and 310R respectively. Record A has changed in local dataset 320L, record B has changed in both datasets 320L and 320R, and record C has been deleted in local dataset 320L. FIG. 3c shows datasets 330L and 330R after data stores 120L and 120R are synchronized. Record A is copied to remote dataset 330R, any conflicts in the changes in record B are resolved and the result is copied to dataset 330L and 330R, and record C is deleted from remote dataset 330R. Although the version comparison technique overcomes the disadvantages of record comparison and deletion as well as the overhead of a change log, each time a new peer device is introduced the version vector of each data record grows because it must store the version for the new device. Even when a device is abandoned, the version vector retains the version number of the abandoned device.
Additionally, none of the techniques described above handles an interrupted synchronization intrinsically. A synchronization operation between two devices may be interrupted for a variety of reasons. For example, the user may manually abort the synchronization operation to perform an urgent task, one of the devices may lose power unexpectedly, or the devices may move outside wireless range and lose connectivity. In general, an interrupted synchronization means restarting the synchronization from scratch, or requires additional information about the synchronization state for later restart.
Prior developments have not taught or suggested any solutions to overcome all of the limitations described above, and thus, solutions to overcome these limitations have long eluded those skilled in the art.
SUMMARY
The claimed invention is directed to methods, computer readable media, and systems for synchronizing shared data stored on multiple devices between or among the devices. Among the many different possibilities contemplated, a maximum sync anchor change number and a sync action change number can be utilized to fix a composite change clock number to support partial synchronization transactions.
It is further contemplated that the composite change clock number can be used to set the sync anchor change number after a synchronization transaction and that a sync action entry can be sorted by a sync action change number. It is further contemplated that a bi-directional sync action queue or a one-way sync action queue can be created. It is further contemplated that a sync action entry includes a greatest change number calculated between an entry in a local sync list and a remote sync list for a data record being synchronized
It is further contemplated that a sync processor synchronizes two data stores. If the sync processor determines that one or both data stores have been modified since the last synchronization, it creates a sync action queue for synchronizing one or both data stores. Each entry in the sync action queue contains instructions for creating, modifying, or deleting a data record in a data store. After sorting the sync action queue in ascending order from the oldest change to the newest, the sync processor sets a composite change clock number for each queue entry. The composite change clock number provides the starting point for the next synchronization of the two data stores irrespective of whether the synchronization process is interrupted or completes normally. After the sync processor performs each sync action, it records the composite change clock number in a sync anchor table.
It is further contemplated that if each data store contains a list of sorted records, an optional action in the sync action queue synchronizes the lists so that the records in each data store are presented in the same order.
ADVANTAGES
Accordingly, it has been discovered that the composite change clock can provide several advantages in various embodiments, such as:
One or more embodiments permit unlimited copying and synchronizing of information among multiple peer devices.
One or more embodiments are efficient in terms of storage space and have minimal storage overhead to accommodate devices with limited memory regardless of the number of peer devices and allows for a more dynamic synchronization requiring less stored or tracked information because a change number is only required to track changes to local information and it is not necessary to store information about the local information as well as the remote information. The composite change clock also allows for a sync anchor to be stored locally and only recording the synchronizations that the specific machine has been involved in.
One or more embodiments minimize the duration of synchronization so that the likelihood of interruption is reduced and synchronization can be initiated frequently on devices with limited processing power.
One or more embodiments eliminate a need for a common system clock shared by multiple peer devices and can function with multiple independent clocks implemented on different systems without coordinating the multiple clocks.
One or more embodiments succeed even when syncing is interrupted before the data stores have been fully synchronized. The synchronization process may be resumed without a need to repair or redo any of the work prior to the interruption. The synchronization process may also be resumed without tracking the actions that were not completed when previously interrupted.
One or more embodiments synchronize the data even if the data store on one device is immutable. An exemplary immutable device may be a CD-ROM or DVD. Another exemplary device may be a shared read-only data store residing in a cloud storage device.
One or more embodiments allow peer devices to be abandoned at any time without leaving residual data behind pertaining to the abandoned device.
BRIEF DESCRIPTION OF THE DRAWINGS
The invention is illustrated in the figures of the accompanying drawings which are meant to be exemplary and not limiting, in which like reference numerals are intended to refer to like components, and in which:
FIG. 1
a shows a prior art system comprising two exemplary peer devices.
FIG. 1
b illustrates a prior art synchronization technique using an example of local and remote datasets to compare data records item by item.
FIG. 1
c shows local and remote datasets of FIG. 1b after some changes.
FIG. 1
d shows local and remote datasets of FIG. 1c after synchronization.
FIG. 2
a illustrates a prior art synchronization technique using change logs.
FIG. 2
b shows local and remote datasets of FIG. 1b after applying the change logs of FIG. 2a.
FIG. 3
a illustrates a prior art synchronization technique using an example comparing versions of data records in local and remote datasets.
FIG. 3
b shows local and remote datasets of FIG. 3a after some changes.
FIG. 3
c shows local and remote datasets of FIG. 3b after synchronization.
FIG. 4 illustrates one embodiment of a system for synchronizing data between devices.
FIG. 5 is a block diagram illustrating two exemplary peer devices connected by a network in one embodiment.
FIG. 6
a is an example of a local dataset in one embodiment.
FIG. 6
b is an example of a local record list in one embodiment
FIG. 6
c is an example of a sync anchor table in one embodiment
FIG. 7
a is an example of a local dataset in one embodiment that has been modified since the last synchronization.
FIG. 7
b is an example of a local record list in one embodiment that has been modified since the last synchronization.
FIG. 7
c is an example of a remote dataset in one embodiment that has been modified since the last synchronization.
FIG. 7
d is an example of a remote record list in one embodiment that has been modified since the last synchronization.
FIG. 8
a is an example of a sync list for a local data store in one embodiment.
FIG. 8
b is an example of a sync list for a remote data store in one embodiment.
FIG. 9 is an example of a sync action queue in one embodiment
FIG. 10 is a flow chart illustrating one embodiment of a process for synchronizing two data stores.
FIG. 11 is a flow chart illustrating one embodiment of the process for creating a sync action queue.
FIG. 12 is a flow chart illustrating one embodiment of the process for creating a bi-directional sync action queue.
FIG. 13 is a flow chart illustrating one embodiment of the process for creating a one-way local-to-remote sync action queue.
FIG. 14 is a flow chart illustrating one embodiment of the process for creating a one-way remote-to-local sync action queue.
FIG. 15 is a flow chart illustrating one embodiment of the process for setting a composite change clock number for each sync action entry in a sync action queue.
FIG. 16 is a flow chart illustrating one embodiment of the optional process for setting an insert hint for each sync action entry in a sync action queue.
FIG. 17 is a flow chart illustrating one embodiment of the optional process for appending a record list sync action entry to a sync action queue.
FIG. 18 is a flow chart illustrating one embodiment of the process for performing a sync action.
FIG. 19 is an example of a block diagram for a computer system suitable for implementing embodiments of the present invention.
DETAILED DESCRIPTION
In the following description of the preferred embodiments, reference is made to the accompanying drawings that form a part hereof, and in which are shown by way of illustration, preferred embodiments in which the invention may be practiced. It is to be understood that other embodiments may be utilized and changes may be made without departing from the scope of the present invention.
The following preferred embodiments are described in sufficient detail to enable those skilled in the art to make and use the invention and provide numerous specific details to give a thorough understanding of the invention; however, it will be apparent that the invention may be practiced without these specific details. In order to avoid obscuring the present invention, some well-known circuits, system configurations, and process steps are not disclosed in detail.
As used herein, the term change number is defined as a scalar value for tracking changes in one replica of a single data record and differs from a version vector in that a version vector tracks changes in multiple replicas of a single data record on a distributed system.
Embodiments of the invention allow shared data stored on multiple devices to be synchronized between or among the devices. One embodiment of a system 400 for synchronizing data between devices is illustrated in FIG. 4. For purposes of illustration FIG. 4 shows the system 400 comprising four devices; device L 410L, device R 410R, device S 410S, and device T 410T; however, the system 400 may include any number of devices. Each device includes data storage capabilities for storing data shared between each other. The system 400 further comprises a shared network 420 allowing device L 410L, device R 410R, device S 410S, and device T 410T to communicate with each other. The system 400 further comprises an ad-hoc wireless network 430 connecting device L 410L and device T 410T, and an ad-hoc network 440 connecting device L 410L and device R 410R. Ad-hoc networks are commonly used when data needs to be shared between two devices but there is no shared network available such as the Internet or a local area network (LAN).
FIG. 5 is a block diagram illustrating two exemplary peer devices 410L and 410R connected by a network 420 in one embodiment. Device L 410L includes a change number clock 510, sync processor 520, network interface 530, and at least one local data store 540L residing in a non-transitory computer-readable storage medium. Device R 410R includes a change number clock 510, sync processor 520, network interface 530, and at least one remote data store 540R residing in a non-transitory computer-readable storage medium. Device L 410L is designated as a local peer device and device R 410R is designated as a remote peer device. For descriptive clarity, reference numbers with an L suffix refer to parts of the local peer device and reference numbers with an R suffix refer to parts of the remote peer device. The local peer device is the device that initiates synchronization of data between data stores 540L and 540R.
Change number clock 510 generates a new change number 615 of FIG. 6a each time a data record 602 of FIG. 6a is added, modified, or deleted in a data store. In the present embodiment, change numbers 615 always increase in value and are never reused. It is also contemplated that change numbers may increase in magnitude but decrease in value, or may follow a preset pattern when identifying changes to the data record 602. The numbering scheme for generating the change numbers 615 on the device L 410L and device R 410R do not need to be the same. Further, the change numbers 615 for corresponding data records 602 on both the device L 410L and device R 410R can be the same and are not required to be unique or monotonically created. Sync processor 520 synchronizes the data between data stores 540L and 540R. Change number clock 510 and sync processor 520 may be implemented in a variety of ways including special purpose hardware, firmware, or application software.
Local data store 540L includes a local storage device identifier 550L, a data store identifier 545, a local change clock number (LCCN 560L), a local dataset 570L comprising data records 602 that will be shared with remote dataset 570R, an optional local record list 580L, and a local sync anchor table 590L. Local storage device identifier 550L is an identifier that is unique to the non-transitory computer-readable storage medium that stores local data store 540L. Data store identifier 545 is a universally unique number, often implemented as a 128-bit random number. Because devices 410L and 410R may each include more than one data store 540, data store identifier 545 identifies which two data stores 540 need to be synchronized. LCCN 560L is the change number 615 or record list change number 630 of FIG. 6b of the most recent change in the data stored in local dataset 570L or local record list 580L, respectively. Whenever a user changes data or as a result of synchronization, LCCN 560L is updated to the greatest change number 615 in local dataset 570L or record list change number 630 in local record list 580L. Optional local record list 580L provides a way of maintaining the data records 602 in local dataset 570L if they need to be presented in sorted order. Local sync anchor table 590L contains zero or more sync anchors 604 of FIG. 6c. A sync anchor 604 of FIG. 6c records the composite change clock number 940 of FIG. 9 corresponding to the most recent sync action 950 of FIG. 9 applied to a data store 540. Remote data store 540R includes similar parts, but with suffix R instead.
The data requirements described with regard to FIG. 6a through FIG. 9 as well as the data requirements for the flow charts of FIG. 10 through FIG. 18 can be fixed on or saved within non-transitory computer-readable media. These data requirements cannot be accessed or modified without the use and implementation of hardware and changes in data values can represent physical, non-transitory transformations of hardware records in the form of bits.
FIG. 6
a is an example of a local dataset 570L in one embodiment. Local dataset 570L includes six exemplary data records 602, each of which is identified by a universally unique identifier (UUID 610), often implemented as a 128-bit random number. Each data record 602 in local dataset 570L also includes a change number 615, a date 620 that the data record 602 was last created or modified, and data 625. As each data record 602 is added or modified, change number clock 510 of FIG. 5 provides a new change number 615 for the data record 602. The device R 410R and the device L 410L can include respective change number clock 510 that independently set the change number 615 of the data records 602 residing thereon. The change number clock 510 on the device R 410R and device L 410L do not need to be coordinated but can operate to set the change numbers 615 of the local and remote data records 602 completely independently. The last-modified date 620 is only used for conflict resolution if the same data record 602 has been changed in both datasets 570L and 570R of FIG. 5 since the last synchronization. For purposes of illustration, the UUID 610 of each exemplary data record 602 is identified with an alphabetical letter rather than a universally unique random number.
FIG. 6
b is an example of a local record list 580L in one embodiment. Local record list 580L includes six UUIDs 610 that correspond to the exemplary data records 602 in local dataset 570L of FIG. 6a. Local record list 580L also includes a record list change number 630 and the last modified record list date 635 that the record list 580 was last modified. The last-modified record list date 635 is only used for conflict resolution if record lists 580L and 580R of FIG. 5 have both been changed since the last synchronization.
FIG. 6
c is an example of a local sync anchor table 590L comprising zero or more sync anchors 604 in one embodiment. Each sync anchor 604 in local sync anchor table 590L includes sync anchor change number 660 for the most recent synchronization between local data store 540L of FIG. 5 and remote data store 540R of FIG. 5 on a non-transitory computer-readable storage medium identified by storage device identifier 650. Each sync anchor 604 in local sync anchor table 590L also includes remote device name 640 and the date of the last synchronization as a last sync date 645 for informational purposes only.
After local data store 540L is synchronized with remote data store 540R, the data records 602 in remote dataset 570R of FIG. 5 and remote record list 580R of FIG. 5 will have matching change numbers 615 and 630 respectively, and sync anchor change number 660 will be set to the composite change clock number 940 of FIG. 9 in local data store 540L. The sync anchor 604 is only recorded in the sync anchor table 590 of the device that initiates the synchronization.
FIG. 7
a is an example of a local dataset 570L in one embodiment that has been modified since the last synchronization. Exemplary data records 602 B and D have been modified and have different change numbers 615 and last-modified dates 620, exemplary data record 602 E has been deleted, and exemplary data record 602 G has been added.
FIG. 7
b is an example of a local record list 580L in one embodiment that has been modified since the last synchronization. Exemplary data record 602 E has been deleted and exemplary data record 602 G has been added. Record list change number 630 and last-modified record list date 635 of the local record list 580L has changed.
FIG. 7
c is an example of a remote dataset 570R in one embodiment that has been modified since the last synchronization. Exemplary data records 602 C and D have been modified and have different change numbers 615 and last-modified dates 620, and exemplary data record 602 F has been deleted.
FIG. 7
d is an example of a remote record list 580R in one embodiment that has been modified since the last synchronization. Exemplary data record 602 F has been deleted. Record list change number 630 and last-modified record list date 635 of the remote record list 580R has changed.
FIG. 8
a is an example of a local sync list 800L for a local data store 540L in one embodiment. The local sync list 800L is created by the sync processor 520 of FIG. 5 in step 1110 of FIG. 11 and contains a list of entries 810 corresponding to the data records 602 of FIG. 7a in the local dataset 570L of FIG. 7a from the local data store 540L of FIG. 5. Each entry 810 includes a UUID 610, a change number 615, and a last-modified date 620. Local sync list 800L may also include an entry 820 for the local record list 580L of FIG. 7b with a record list change number 630 and last-modified record date 635 if the local record list 580L exists. The exemplary entries 810 and 820 in FIG. 8a reflect the exemplary data records 602 in local dataset 570L and local record list 580L.
FIG. 8
b is an example of a remote sync list 800R for a remote data store 540R in one embodiment. The remote sync list 800R is created by the sync processor 520 of FIG. 5 in step 1115 of FIG. 11 and contains a list of entries 810 corresponding to the data records 602 of FIG. 7c in the remote dataset 570R of FIG. 7c from the remote data store 540R of FIG. 5. Each entry 810 includes a UUID 610, a change number 615, and a last-modified date 620. Remote sync list 800R may also include an entry 820 for a remote record list 580R of FIG. 7d with a record list change number 630 and last-modified record date 635 if the remote record list 580R exists. The exemplary entries 810 and 820 in FIG. 8b reflect the exemplary data records 602 in remote dataset 570R and remote record list 580R.
FIG. 9 is an example of a sync action queue 900 in one embodiment. The sync processor 520 of FIG. 5 combines information from sync lists 800L and 800R to create a sync action queue 900 in step 1030 of FIG. 10. The sync action queue 900 contains instructions to synchronize local dataset 570L of FIG. 5 and local record list 580L of FIG. 5 with remote dataset 570R of FIG. 5 and remote record list 580R of FIG. 5, respectively. Each sync action entry 960 contains a UUID 610, a sync action change number (SACN 920), an insertion hint 930 for data records 602 of FIG. 6 that need to be inserted into a data store 540 of FIG. 5, a composite change clock number (CCCN 940), and a sync action 950. SACN 920 is the greatest change number 615 of FIG. 6 between an entry 810 in local sync list 800L of FIG. 8a and remote sync list 800R of FIG. 8b for the data record 602 being synchronized. The SACN 920 can also be the greatest record list change number 630 of FIG. 6 between an entry 820 in local sync list 800L and remote sync list 800R for the record list 580 of FIG. 5 being synchronized. The sync action entries 960 are sorted into ascending order of SACN 920 before the CCCN 940 is set in step 1155 of FIG. 11. The CCCN 940 is used in step 1050 of FIG. 10 to update sync anchor change number 660 of FIG. 6c in local sync anchor table 590L of FIG. 5 after each sync action is performed. Insertion hint 930 is the UUID 610 of the data record 602 that should come just before the data record 602 being inserted if the data records 602 need to be presented in sorted order. For example, exemplary data record 602 G in FIG. 9 should be inserted in remote data store 540R just after data record 602 E.
The following ten sync actions 950 may be used to synchronize two data stores.
1. Sync action PULL-INSERT copies a data record 602 from remote dataset 570R and inserts it in local dataset 570L.
2. Sync action PUSH-INSERT copies a data record 602 from local dataset 570L and inserts it in remote dataset 570R.
3. Sync action PULL-REPLACE copies a data record 602 from remote dataset 570R and replaces the data record 602 with the matching UUID 610 in local dataset 570L.
4. Sync action PUSH-REPLACE copies a data record 602 from local dataset 570L and replaces the data record 602 with the matching UUID 610 in remote dataset 570R.
5. Sync action PULL-RESOLVE copies a data record 602 from remote dataset 570R and replaces the data record 602 with matching UUID 610 in local dataset 570L after applying conflict resolution.
6. Sync action PUSH-RESOLVE copies a data record 602 from local dataset 570L and replaces the data record 602 with matching UUID 610 in remote dataset 570R after applying conflict resolution.
7. Sync action LOCAL-DISPOSE removes a data record 602 from local dataset 570L.
8. Sync action REMOTE-DISPOSE removes a data record 602 from remote dataset 570R.
9. Sync action PULL-LIST copies remote record list 580R to local data store 540L and replaces local record list 580L.
10. Sync action PUSH-LIST copies local record list 580L to remote data store 540R and replaces remote record list 580R.
OPERATION
Having described the data requirements for synchronizing a data store between two devices, we now describe the process for synchronizing the data stores. The process steps for synchronizing the data stores, in the flow charts described with regard to FIG. 10 through FIG. 18, can be implemented in hardware, software, firmware, or any combination thereof. Furthermore, the step boundaries commonly vary and functions are implemented together, as well as separately in different embodiments. The synchronization process comprises three stages. The first stage checks to see if the data stores need to be synchronized. If the data stores need to be synchronized, the second stage creates a sync action queue 900 with actions for synchronizing the data stores, and the third stage performs the actions in the sync action queue 900. We use two exemplary devices, device L 410L and device R 410R of FIG. 4, to illustrate each stage in one embodiment of the synchronization process. It is understood that sync processor 520 associated with each exemplary device performs each step of the process.
FIG. 10 is a flow chart illustrating one embodiment of a process for synchronizing two data stores. The first state of the synchronization process begins at step 1010 when sync processor 520 of FIG. 5 of device L 410L requests that device R 410R returns remote change clock number (RCCN 560R) of FIG. 5, and sync anchor change number 660 of FIG. 6 for local storage device identifier 550L of FIG. 5 stored in remote sync anchor table 590R of FIG. 5. If device R 410R of FIG. 4 has never synchronized remote data store 540R of FIG. 5 with local data store 540L of FIG. 5, the sync anchor change number 660 for local storage device identifier 550L will not be present in remote sync anchor table 590R and the returned value will be zero. In step 1015 the sync processor 520 calculates the maximum change clock number (MAXCN 1016) as the greater of the LCCN 560L and RCCN 560R of FIG. 5. In step 1020 the sync processor 520 calculates the maximum sync anchor change number (SYCN 1022) as the greater of the sync anchor change numbers 660 read from sync anchor tables 590L and 590R of FIG. 5. If device L 410L of FIG. 4 has never synchronized local data store 540L with remote data store 540R, the sync anchor change number 660 for remote storage device identifier 550R of FIG. 5 will not be present in local sync anchor table 590L and the sync anchor change number 660 in local sync anchor table 590L will be zero. In step 1025 if MAXCN 1016 is greater than SYCN 1022 the data has changed in one or both data stores 540L and 540R since they were last synchronized. In step 1025, if MAXCN 1016 is less than or equal to SYCN 1022, the data stores are already synchronized and the synchronization process ends.
If data stores 540L and 540R need to be synchronized as determined in the first stage, the second stage of the synchronization process begins in step 1030 where the sync processor 520 creates a sync action queue (see FIG. 11) exemplified by sync action queue 900 of FIG. 9. The sync action queue 900 contains zero or more sync action entries 960 of FIG. 9 for synchronizing the local data store with the remote data store.
After creating the sync action queue 900 in the second stage of the synchronization process, the third stage of the process begins in step 1035 when the sync processor 520 gets the next sync action entry 960 from sync action queue 900. If there are no more sync action entries 960 in the sync action queue 900, the synchronization process ends. When the sync processor 520 gets the next sync action entry 960 from sync action queue 900 it performs the sync action 950 in step 1040 (see FIG. 18). If the result of the sync action 950 is successful in step 1045, the sync processor 520 saves CCCN 940 as sync anchor change number 660 in local sync anchor table 590L for remote storage device identifier 550R in step 1050. If the sync action 950 is not successful the synchronization process ends. After step 1050 the sync processor 520 repeats step 1035. If the user interrupts the process of synchronization or there is a loss of connectivity between the two synchronizing devices, the sync processor 520 removes the remaining sync action entries 960 from sync action queue 900 and the synchronization process ends.
Process to Create a Sync Action Queue
FIG. 11 is a flow chart illustrating one embodiment of the process for creating a sync action queue 900 of FIG. 9 in step 1030 of FIG. 10. In step 1110 sync processor 520 of FIG. 5 of device L 410L of FIG. 4 queries local data store 540L of FIG. 5 including local dataset 570L of FIG. 5 and optional local record list 580L of FIG. 5, and creates a synchronization list exemplified by local sync list 800L of FIG. 8a. In step 1115 the sync processor 520 of the local device requests that device R 410R of FIG. 4 queries remote data store 540R of FIG. 5 including remote dataset 570R and optional remote record list 580R of FIG. 5, and create and return a synchronization list exemplified by remote sync list 800R of FIG. 8b.
In step 1120, sync processor 520 of device L 410L determines whether the user has requested bi-directional synchronization so that changes in local data store 540L are applied to remote data store 540R and changes in remote data store 540R are applied to local data store 540L. If the user has not requested bi-directional synchronization, in step 1125 the sync processor 520 determines whether the user has requested one-way local-to-remote synchronization so that changes in local data store 540L are applied to remote data store 540R, but changes in remote data store 540R are not applied to local data store 540L. If the user has not requested one-way local-to-remote synchronization, in step 1130 the sync processor 520 determines whether the user has requested one-way remote-to-local synchronization so that changes in remote data store 540R are applied to local data store 540L, but changes in local data store 540L are not applied to remote data store 540R. If the user has not requested one-way remote-to-local synchronization, no sync action entries 960 of FIG. 9 are added to the sync action queue 900 and the synchronization process ends after step 1035 in FIG. 10.
If the user has requested bi-directional synchronization, in step 1135 the sync processor 520 creates a bi-directional sync action queue 900 (see FIG. 12). If the user has requested one-way local-to-remote synchronization, in step 1140 the sync processor 520 creates a one-way local-to-remote sync action queue 900 (see FIG. 13). If the user has requested one-way remote-to-local synchronization, in step 1145 the sync processor 520 creates a one-way remote-to-local sync action queue 900 (see FIG. 14). After creating the sync action queue 900, the sync processor 520 sorts the sync action queue 900 by ascending order of SACN 920 of FIG. 9 in step 1150, and sets CCCN 940 of FIG. 9 for each sync action entry 960 in step 1155 (see FIG. 15). In step 1160 the sync processor 520 may set an optional insertion hint 930 of FIG. 9 for each new data record 602 of FIG. 6 inserted in dataset 570L or 570R of FIG. 5 if they are presented in sorted order (see FIG. 16). In step 1165 the sync action entry 960 for the optional record list 580 of FIG. 5 is appended to the sync action queue 900 (see FIG. 17).
Process to Create a Bi-Directional Sync Action Queue
FIG. 12 is a flow chart illustrating one embodiment of the process for creating a bi-directional sync action queue 900 of FIG. 9 in step 1135 of FIG. 11. The change numbers 615 of FIG. 8 for each entry 810 with matching UUID 610 of FIG. 8 in local and remote sync lists 800L of FIGS. 8a and 800R of FIG. 8b, respectively, are compared with the SYCN 1022. Depending on the result of the comparison, a sync action entry 960 of FIG. 9 may be appended to the sync action queue 900 to insert, copy, or delete a data record 602 of FIG. 6a in either the local dataset 570L of FIG. 6a or remote dataset 570R of FIG. 5.
In step 1202 sync processor 520 of FIG. 5 of device L 410L of FIG. 4 gets the next entry 810 from local sync list 800L and finds the entry 810 with matching UUID 610 in the remote sync list 800R in step 1204. If a matching entry 810 is found in step 1206, local record change number (LRCN 1205) and remote record change number (RRCN 1207) are compared with the SYCN 1022 in step 1216. The LRCN 1205 is the change number 615 of the data record 602 of the matching entry 810 in the local sync list 800L while the RRCN 1207 is the change number 615 of the data record 602 of the matching entry 810 in the remote sync list 800R.
If LRCN 1205 is less than or equal to SYCN 1022 and RRCN 1207 is greater than SYCN 1022 in step 1218, a sync action entry 960 having a PULL-REPLACE sync action 950 is appended to the sync action queue 900 in step 1220 because the data record 602 in remote dataset 570R has changed since the last synchronization, but the data record 602 in local dataset 570L has not. Example data record 602 C satisfies this condition when change number 615 ‘3’ in the local dataset 570L in FIG. 7a and change number 615 ‘8’ in the remote dataset 570R in FIG. 7c are compared to the SYCN 1022 which is ‘7’ after the previous synchronization of local dataset 570L of FIG. 6a and local record list 580L of FIG. 6b.
If RRCN 1207 is less than or equal to SYCN 1022 and LRCN 1205 is greater than SYCN 1022 in step 1222 a sync action entry 960 having a PUSH-REPLACE sync action 950 is appended to the sync action queue 900 in step 1224 because the data record 602 in local dataset 570L has changed since the last synchronization, but the data record 602 in remote dataset 570R has not. Example data record 602 B satisfies this condition in FIGS. 7a and 7c.
If LRCN 1205 and RRCN 1207 are both greater than SYCN 1022 in step 1226, the data record 602 has changed in both datasets 570L and 570R since last synchronization. Example data record 602 D satisfies this condition in FIGS. 7a and 7c. If the last-modified date of the data record 602 of a local dataset 570L is less than the last-modified date of the data record 602 of a remote dataset 570R in step 1228, the data record 602 of the remote dataset 570R is newer and a sync action entry 960 having a PULL-RESOLVE sync action 950 is appended to the sync action queue 900 in step 1230 so that the data record 602 of the remote dataset 570R will be copied to the local dataset 570L where the conflict will be resolved in a manner not pertinent to this embodiment of the synchronization process. If the last-modified date of the data record 602 of a local dataset 570L is not less than the last-modified date of the data record 602 of a remote dataset 570R in step 1228, the data record 602 of the local dataset 570L is newer and a sync action entry 960 having a PUSH-RESOLVE sync action 950 is appended to the sync action queue 900 in step 1232 so that the data record 602 of the local dataset 570L will be copied to the remote dataset 570R where the conflict will be resolved in a manner not pertinent to this embodiment of the synchronization process.
After steps 1220, 1224, 1230, and 1232, SACN 920 of FIG. 9 in the sync action entry 960 is set to the greater of the LRCN 1205 and the RRCN 1207 in step 1234. SACN 920 will be used to set the CCCN 940 of FIG. 9 in step 1155 of FIG. 11.
After step 1234 the entry 810 matched in step 1206 is removed from remote sync list 800R in step 1236. The entry 810 is also removed after step 1226 if LRCN 1205 and RRCN 1207 are both less than or equal to SYCN 1022 because neither the data record 602 of the remote dataset 570R nor its matching data record 602 of the local dataset 570L have changed since the last synchronization. It is necessary to remove the entry 810 from the remote sync list 800R so that any entries 810 in the remote sync list 800R will be examined after all of the entries 810 in the local sync list 800L have been returned in step 1202. After step 1236, step 1202 is repeated.
If a matching entry 810 is not found in the remote sync list 800R in step 1206 and LRCN 1205 is less than or equal to SYCN 1022 in step 1208 the data record 602 has been removed from remote dataset 570R since the last synchronization and a sync action entry 960 having a LOCAL-DISPOSE sync action 950 is appended to the sync action queue 900 in step 1212 to remove the data record 602 from local dataset 570L. Example data record 602 F satisfies this condition in FIG. 7a. If LRCN 1205 is greater than SYCN 1022 the data record 602 has been added to local dataset 570L since the last synchronization and a sync action entry 960 having a PUSH-INSERT sync action 950 is appended to the sync action queue 900 in step 1210 so that the data record 602 of the local dataset 570L will be copied to the remote dataset 570R. Example data record 602 G satisfies this condition in FIG. 7a. After steps 1210 and 1212, SACN 920 in the sync action entry 960 is set to the LRCN 1205 in step 1214. After step 1214, step 1202 is repeated.
After all of the entries 810 in the local sync list 800L have been returned in step 1202, the sync processor 520 gets the next entry 810 from the remote sync list 800R in step 1238. If RRCN 1207 is less than or equal to SYCN 1022 in step 1240 the data record 602 has been removed from local dataset 570L since the last synchronization and a sync action entry 960 having a REMOTE-DISPOSE sync action 950 is appended to the sync action queue 900 in step 1242 to remove the data record 602 from the remote dataset 570R. Example data record 602 E satisfies this condition in FIG. 7c. If RRCN 1207 is greater than SYCN 1022 the data record 602 has been added to remote dataset 570R since the last synchronization and a sync action entry 960 having a PULL-INSERT sync action 950 is appended to the sync action queue 900 in step 1244 so that the data record 602 of the remote dataset 570R will be copied to the local dataset 570L. After steps 1242 and 1244, SACN 920 in the sync action entry 960 is set to the RRCN 1207 in step 1246. After step 1246, step 1238 is repeated.
After all of the entries 810 in the remote sync list 800R have been returned in step 1238, the process to create a bi-directional sync action queue 900 ends.
Process to Create a One-Way Local-to-Remote Sync Action Queue
FIG. 13 is a flow chart illustrating one embodiment of the process for creating a one-way local-to-remote sync action queue 900 of FIG. 9 in step 1140 of FIG. 11. The change numbers 615 of FIG. 6 for each data record 602 of FIG. 6 with matching UUID 610 of FIG. 6 in the local and remote sync lists 800 of FIG. 8 are compared with the SYCN 1022. Depending on the result of the comparison, a sync action entry 960 of FIG. 9 may be appended to the sync action queue 900 to insert, copy, or delete a data record 602 in remote dataset 570R of FIG. 5 to synchronize it with local dataset 570L of FIG. 5. The contents of local dataset 570L are not altered. Since the process for creating a one-way local-to-remote sync action queue 900 is very similar to the process for creating a bi-directional sync action queue 900, the same steps for modifying remote dataset 570R are used in FIG. 13.
Process to Create a One-Way Remote-to-Local Sync Action Queue
FIG. 14 is a flow chart illustrating one embodiment of the process for creating a one-way remote-to-local sync action queue 900 of FIG. 9 in step 1145 of FIG. 11. The change numbers 615 of FIG. 6 for each data record 602 of FIG. 6 with matching UUID 610 of FIG. 6 in the local and remote sync lists 800 of FIG. 8 are compared with the SYCN 1022. Depending on the result of the comparison, a sync action entry 960 of FIG. 9 may be appended to the sync action queue 900 to insert, copy, or delete a data record 602 in local dataset 570L of FIG. 6a to synchronize it with remote dataset 570R of FIG. 5. The contents of remote dataset 570R are not altered. Since the process for creating a one-way remote-to-local sync action queue 900 is very similar to the process for creating a bi-directional sync action queue 900, the same steps for modifying local dataset 570L are used in FIG. 14.
Process to Set the Composite Change Clock for Each Sync Action
FIG. 15 is a flow chart illustrating one embodiment of the process for setting CCCN 940 of FIG. 9 for each sync action entry 960 of FIG. 9. After each sync action 950 is performed, sync processor 520 of FIG. 5 of device L 410L of FIG. 4 updates sync anchor change number 660 of FIG. 6c in local sync anchor table 590L of FIG. 5 with the CCCN 940 in step 1050 of FIG. 10.
In step 1505 the sync processor 520 sets a change clock variable (CCV 1506) to the SYCN 1022 of FIG. 10 from the previous synchronization of local data store 540L of FIG. 5 with remote data store 540R of FIG. 5. In step 1510 a queue index (QI 1512) is set to the first position of the sync action queue 900 of FIG. 9. While the QI 1512 is less than or equal to the length of the sync action queue 900 in step 1515, set CCCN 940 for each sync action entry 960. If the QI 1512 is equal to the length of the sync action queue 900 in step 1520 or the next SACN 920 of FIG. 9 in the sync action queue 900 is greater than the current SACN 920 in step 1525, and if the current SACN 920 is greater than the SYCN 1022 in step 1530, set the CCV 1506 to the current SACN 920 in step 1540. If more than one sync action entry 960 has the same SACN 920, wait until the last sync action 960 with the same SACN 920 before setting the CCCN 940 to the SACN 920 stored in the CCV 1506 in step 1535. This ensures that the CCCN 940 only updates the sync anchor change number 660 in local sync anchor table 590L in step 1050 of FIG. 10 when all of the data records 602 of FIG. 6a with the same change number 615 of FIG. 6a have been synchronized, so that no data records 602 will be skipped during the next synchronization if the current synchronization process is interrupted. The sync action entries 960 for exemplary data records 602 B and C in FIG. 9 illustrate step 1525. Both data records 602 have a SACN 920 of ‘8’ but the CCCN 940 only changes to ‘8’ when data record 602 C is synchronized.
In step 1545 the sync processor 520 increments the QI 1512 so that it can examine the next sync action entry 960 in the sync action queue 900.
Process to Set Insertion Hints for New Records
FIG. 16 is a flow chart illustrating one embodiment of the optional process for setting an insertion hint 930 of FIG. 9 for each sync action entry 960 of FIG. 9 having a PULL-INSERT and PUSH-INSERT sync action 950 of FIG. 9 in a sync action queue 900 of FIG. 9 so that the sync processor 520 of FIG. 5 knows where to insert a data record 602 of FIG. 6 in a data store 540 of FIG. 5 that may be presented in sorted order. If the optional record list 580 of FIG. 5 is present in the data store 540, an insertion hint 930 may be used to insert a data record 602 at a particular position in the list.
Sync processor 520 of device L 410L of FIG. 4 starts the iteration through each sync action entry 960 in the sync action queue 900 by setting the QI 1512 of FIG. 15 to the first position of the sync action queue 900 in step 1605. If the QI 1512 is less than or equal the length of the sync action queue 900 in step 1610 test the sync action 950 at the QI 1512 position. If the sync action 950 is a PUSH-INSERT in step 1615, set the record list index (RLI 1622) in step 1620 to the position of the data record 602 in local record list 580L of FIG. 5 that matches the UUID 610 in the sync action entry 960. Iterate backwards through the local record list at step 1640 until the beginning of the list in step 1645, looking for a data record 602 with a change number 615 less than the change number 615 of the data record 602 in the sync action entry 960. Only data records 602 with smaller change numbers 615 are considered because they are already in the record list 580 even if they were inserted during the current synchronization process. If a data record 602 is found at step 1650, set the insertion hint 930 in the sync action entry 960 to the UUID 610 of the data record 602 at 1655 and increment the QI 1512 at 1635 to examine the next sync action entry 960 in the sync action queue 900.
If the sync action 950 is a PULL-INSERT in step 1625 set the RLI 1622 in step 1630 to the position of the data record 602 in remote record list 580R of FIG. 5. Perform the same steps as for a PUSH-INSERT but iterate backwards through the remote record list instead.
Process to Append a Record List Sync Action
FIG. 17 is a flow chart illustrating one embodiment of the optional process for appending a sync action entry 960 of FIG. 9 for a record list 580 of FIG. 5 to a sync action queue 900 of FIG. 9 in step 1165 of FIG. 11. The sync action entry 960 for the record list 580 is optional; it may be used when the dataset 570 of FIG. 5 is presented in sorted order.
In step 1702, sync processor 520 of FIG. 5 of device L 410L of FIG. 4 determines whether the user has requested bi-directional synchronization. If the user has not requested bi-directional synchronization, in step 1704 the sync processor 520 determines whether the user has requested one-way local-to-remote synchronization. If the user has not requested one-way local-to-remote synchronization, in step 1706 the sync processor 520 determines whether the user has requested one-way remote-to-local synchronization. If the user has not requested one-way remote-to-local synchronization, no sync action entry 960 for the record list 580 is appended to the sync action queue 900.
A local record list change number (LLCN 1715) and a remote record list change number (RLCN 1717) are compared with the SYCN 1022 in step 1716. The LLCN 1715 is the record list change number 630 of local record list 580L, while the RLCN 1717 is the record list change number 630 of FIG. 6 of remote record list 580R of FIG. 5. If LLCN 1715 is less than or equal to SYCN 1022 of FIG. 10 and RLCN 1717 is greater than SYCN 1022 in step 1718, a PULL-LIST sync action 950 is appended to the sync action queue 900 in step 1720 because the remote record list 580R has changed since the last synchronization but the local record list 580L has not. If RLCN 1717 is less than or equal to SYCN 1022 and LLCN 1715 is greater than SYCN 1022 in step 1724, a PUSH-LIST sync action 950 is appended to the sync action queue 900 in step 1726 because the local record list 580L of FIG. 5 has changed since the last synchronization but the remote record list 580R has not.
If LLCN 1715 and RLCN 1717 are both greater than SYCN 1022 in step 1722, both the local and remote record lists 580R have changed since last synchronization. If the last-modified date of the local record list 580L is greater than the last-modified record date 635 of FIG. 6b of the remote record list 580R in step 1728, the local record list 580L is newer and a PUSH-LIST sync action 950 is appended to the sync action queue 900 in step 1732 to copy the local record list 580L to remote data store 540R. If the last-modified record date 635 of the local record list 580L is less than or equal to the last-modified record date 635 of the remote record list 580R in step 1728, the remote record list 580R is newer and a PULL-LIST sync action 950 is appended to the sync action queue 900 in step 1730 to copy the remote record list 580R to local data store 540L.
In the case of one-way local-to-remote synchronization, if the LLCN 1715 is greater than the SYCN 1022 in step 1708, the local record list 580L has changed since the last synchronization and a PUSH-LIST sync action 950 is appended to the sync action queue 900 in step 1712.
In the case of one-way remote-to-local synchronization, if the RLCN 1717 is greater than the SYCN 1022 in step 1710, the remote record list 580R has changed since the last synchronization and a PULL-LIST sync action 950 is appended to the sync action queue 900 in step 1714.
After a PUSH-LIST or PULL-LIST sync action 950 is appended to the sync action queue 900, SACN 920 of FIG. 9 is set to the greater of the LLCN 1715 and RLCN 1717 in step 1734. In step 1736 CCCN 940 of FIG. 9 for the sync action 950 is set to the greater of the SACN 920 and largest value of CCCN 940 already in the sync action queue 900.
Process to Perform a Sync Action
FIG. 18 is a flow chart illustrating one embodiment of the process for performing a sync action 950 of FIG. 9. Sync processor 520 of FIG. 5 in device L 410L of FIG. 4 initiates each sync action 950, but may delegate part or all of the sync action 950 to the sync processor 520 in device R 410R of FIG. 4.
If the sync action 950 is PULL-INSERT in step 1802, the data record 602 of FIG. 6 with UUID 610 of FIG. 6 is copied from remote dataset 570R of FIG. 5 and inserted in local dataset 570L of FIG. 5 in step 1804. Insertion hint 930 of FIG. 9 may specify the location of the data record 602 in local record list 580L of FIG. 5. If the sync action 950 is PUSH-INSERT in step 1806, the data record 602 with UUID 610 is copied from local dataset 570L and inserted in remote dataset 570R in step 1808. Insertion hint 930 may specify the location of the data record 602 in the remote record list 580R of FIG. 5.
If the sync action 950 is PULL-REPLACE in step 1812, the data record 602 with UUID 610 is copied from the remote dataset 570R and replaces the data record 602 in the local dataset 570L in step 1814. If the sync action 950 is PUSH-REPLACE in step 1816, the record with UUID 610 is copied from the local dataset 570L and replaces the data record 602 in the remote dataset 570R in step 1818.
If the sync action 950 is PULL-RESOLVE in step 1822, the data record 602 with UUID 610 is copied from the remote dataset 570R and replaces the data record 602 in the local dataset 570L after conflict resolution in step 1824. If the sync action 950 is PUSH-RESOLVE in step 1826, the data record 602 with UUID 610 is copied from the local dataset 570L and replaces the data record 602 in the remote dataset 570R after conflict resolution in step 1828.
If the sync action 950 is LOCAL-DISPOSE in step 1832, the data record 602 with UUID 610 is disposed from the local dataset 570L in step 1834. If the sync action 950 is REMOTE-DISPOSE in step 1836, the data record 602 with UUID 610 is disposed from the remote dataset 570R in step 1838.
If the sync action 950 is PULL-LIST in step 1842, remote record list 580R is copied from remote data store 540R of FIG. 5 and replaces local record list 580L in local data store 540L of FIG. 5 in step 1844. If the sync action 950 is PUSH-LIST in step 1846, local record list 580L is copied from local data store 540L and replaces remote record list 580R in remote data store 540R in step 1848.
After the sync action 950 is performed, the sync processor 520 in local device 540L sets LCCN 560L of FIG. 5 to the SACN 920 of FIG. 9 in step 1855 if it is less than SACN 920 in step 1850. Similarly the sync processor 520 in remote device 540R sets RCCN 560R of FIG. 5 to the SACN 920 in step 1860 if it is less than SACN 920 in step 1865.
Computer System Embodiment
Embodiments of the present invention may be employed to facilitate the synchronization of data in any of a wide variety of computing contexts. For example, implementations are contemplated in which users may interact with a diverse network environment via any type of computer system ranging from an integrated circuit, a printed circuit board, or a small handheld computing device up to a huge super computer.
FIG. 19 is an example of a block diagram for a computer system 1900 suitable for implementing embodiments of the present invention. Attached to system bus 1905 are a wide variety of subsystems. Processor(s) 1910 (also referred to as central processing units, or CPUs) are coupled to one or more storage devices including memory 1915, fixed media 1920, and removable media 1925. Memory 1915 includes random access memory (RAM), read-only memory (ROM), and non-volatile flash memory. Fixed media 1920 includes hard disks. Removable media 1925 includes CD-ROMS, DVDs, and flash memory cards. CPU 1910 is also coupled to a variety of input/output devices such as display 1930, keyboard 1935, mouse 1940 and speakers 1945. The data stores 540 can include the memory 1915, the fixed media 1920, and the removable media 1925. In general, an input/output device may be any of: video displays, track balls, mice, keyboards, microphones, touch-sensitive displays, transducer card readers, magnetic or paper tape readers, tablets, styluses, voice or handwriting recognizers, biometrics readers, or other computers.
The computer system in FIG. 19 may be coupled to another computer or telecommunications network 1960 using network interface 1950. With such a network interface, it is contemplated that the CPU might receive information from the network 1960, or might output information to the network in the course of performing the above-described process steps. Furthermore, process embodiments of the present invention may execute solely upon CPU 1910 or may execute over a network in conjunction with a remote CPU that shares a portion of the processing.
The network 1960 may comprise a conventional wireless data communication system, for example, general packet radio service (GPRS), IEEE 802.11 (or WiFi), IEEE 802.16 (or WiMax), Bluetooth, or any other suitable wireless communication system. Alternatively, network 1960 may comprise a conventional wired data communication system, such as Ethernet, digital subscriber line (DSL), integrated services digital network (ISDN), or any other suitable wired communication system.
In addition, embodiments of the present invention further relate to computer storage products with a non-transitory computer-readable storage medium that can store data and computer code for performing various computer-implemented operations. Examples of computer-readable media include, but are not limited to: magnetic media such as hard disks; optical media such as CD-ROMs, DVDs, and holographic devices; non-volatile computer memory such as flash memory; and hardware devices that are specially configured to store and execute program code, such as application-specific integrated circuits (ASICs), programmable logic devices (PLDs) and ROM and RAM devices.
Embodiments of the subject matter and the functional operations described in this specification can be implemented in digital electronic circuitry, or in computer software, firmware, or hardware, including the structures disclosed in this specification and their structural equivalents, or in combinations of one or more of them. Embodiments of the subject matter described in this specification can be implemented as one or more computer program products encoded on a non-transitory computer-readable storage medium for execution by, or to control the operation of data processing apparatus.
Although the description above contains many specificities for purposes of clarity of understanding, these should not be construed as limiting the scope of the embodiments. The described embodiments should be taken as illustrative and not restrictive.