Embodiments of the invention relate generally to data replication systems and, more particularly, relate to a system for synchronizing replicated databases in a mobile environment.
Mobile phones are increasingly used for executing mobile software applications. Many such applications require that the phone be able to access data from a remote server. Since connectivity to the remote server may not always be possible and since any connection may be limited, at least a portion of the data may be replicated to the mobile device. The problem of data replication on mobile devices has been studied quite extensively. In most cases, the research directed to data replication on mobile terminals has focused on nomadic cases where the mobile device is either connected to the remote server or is not connected to the remote server. In other words, traditional data replication systems utilize a two-state connectivity model, where the mobile device is either connected to the remote server such that the replicated database in the mobile terminal can be synchronized or not connected to the remote server such that the replicated database cannot be synchronized.
Such traditional two state replication systems ignore important capabilities of modern mobile phones. For example, in countries with well-developed infrastructure, a mobile phone is able to have an almost constant connection to a communication network. For example, a mobile phone in a developed area has almost constant access to a cellular communication system, such as General Packet Radio Services (GPRS) system. Typically, however, such a connection is limited in bandwidth and is expensive to use relative to other types of data connections. On the other hand, when the phone enters an area, such as a “hotspot,” where a wireless local area network (WLAN) provides access to the Internet, a large bandwidth may be available that is relatively inexpensive, if not free of charge.
Thus, it would be advantageous if a solution were developed that better utilized the different types of connections available to modern mobile phones in order to create a database replication system that is more efficient with respect to the cost and speed of synchronization. It would also be advantageous if such a solution was provided for improved data replication between any sites of a distributed database system using optimistic replication.
In one embodiment of the present invention, a computer program product is provided for providing data synchronization between replicated databases in a first device and a second device. The computer program product comprises at least one computer-readable storage medium having computer-readable program code portions stored therein. The computer-readable program code portions may include: a first executable portion for determining a priority level for a synchronization item; a second executable portion for determining a current state of the first device, wherein the current state comprises one of at least three possible states of the first device, the at least three possible states of the first device being at least partially based on a connection between the first device and the second device; and a third executable portion for communicating the synchronization item from the first device to the second device based at least partially on the state of the first device and the priority level of the synchronization item.
The second executable portion of the computer program product may be configured to determine the current state from among: a first connection state where the first device is not connected to the second device; a second connection state where the first device is connected to the second device using a first connection; and a third connection state where the first device is connected to the second device using a second connection that is different than the first connection.
The current state may be based at least partially on the type of the connection between the first and second devices, and the first connection may include a first type of connection that is generally slower and/or more expensive than a second type of connection that makes up the second connection. The current state of the device may be based at least partially on the transmission rate of the connection between the first and second devices, and the first connection may have a lower transmission rate than the second connection. The current state of the device may be based at least partially on the cost of the connection between the first and second devices, and the first connection may have a higher cost than the second connection.
The first connection may involve using a first communication interface of the first device for connecting to a cellular network and the second connection may involve using a second different communication interface for connecting to a wireless local area network. The priority level may be at least partially based on the size of the synchronization item.
The first executable portion of the computer program product may include an executable portion for determining a priority threshold and for determining a relationship of the priority level of the synchronization item to the priority threshold in order to classify the synchronization item as being of a first priority or a second priority. The third executable portion may then be configured to queue the synchronization item for communication using the first connection if the priority level indicates the first priority. The third executable portion may be further configured to queue the synchronization item for communication using the second connection if the priority level indicates the second priority. The first executable portion may be configured to determine the priority level for the synchronization item by basing the priority level at least partially on the size of the synchronization item and then adjusting the priority level based on externally originated commands. The priority threshold may be determined based on externally originated commands.
Where the first executable portion of the computer program product includes an executable portion for determining a priority threshold and for determining a relationship of the priority level of the synchronization item to the priority threshold in order to classify the synchronization item as being of a first priority or a second priority, the third executable portion may be configured so that the synchronization item is not communicated using the first connection if the priority level of the synchronization item indicates the first priority. The third executable portion may be further configured so that the synchronization item is communicated using the first connection if the priority level of the synchronization item indicates the second priority. The third executable portion may be configured to communicate metadata related to the synchronization item using the first connection if the priority level of the synchronization item indicates the first priority. The metadata may include an abbreviated version of the synchronization item. The third executable portion may be configured so that the synchronization item is queued to be sent using the second connection if the priority level of the synchronization item indicates the first priority.
The computer program product may also include a fourth executable portion for receiving input from an external entity, the input requesting communication of the synchronization item using the first connection, and for overriding the third executable portion such that the synchronization item is communicated using the first connection despite the fact that the priority level of the synchronization item indicated the first priority prior to receipt of the input.
The first device may be embodied as a mobile terminal and the second device may be embodied as a server, or the first device and the second device may each be embodied as a mobile terminal. In yet another embodiment, the first device and the second devices may each be embodied as a server.
In one embodiment, a method is provided for providing data synchronization between replicated databases in a first device and a second device. The method may include: determining a priority level for a synchronization item; determining a current state of the first device, wherein the current state comprises one of at least three possible states of the first device, the at least three possible states of the first device being at least partially based on a connection between the first device and the second device; and communicating the synchronization item from the first device to the second device based at least partially on the state of the first device and the priority level of the synchronization item.
In another embodiment of the present invention, an apparatus is provided. The apparatus may include: a memory for storing a replicated database and a synchronization item; at least one communication interface for establishing a connection with an electronic device and for communicating the synchronization item to the electronic device; and a processor operatively coupled to the memory and the communication interface. The processor may be configured to: determine a priority level for the synchronization item; determine a current state of the apparatus, wherein the current state comprises one of at least three possible states of the apparatus, the at least three possible states of the apparatus being at least partially based on the connection between the apparatus and the electronic device; and communicate the synchronization item from the memory to the electronic device based at least partially on the current state of the apparatus and the priority level of the synchronization item.
Having thus described the invention in general terms, reference will now be made to the accompanying drawings, which are not necessarily drawn to scale, and wherein:
The present invention now will be described more fully hereinafter with reference to the accompanying drawings, in which some, but not all embodiments of the inventions are shown. Indeed, these inventions may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will satisfy applicable legal requirements. Like numbers refer to like elements throughout.
The mobile terminal 10 includes a communication interface comprising an antenna 12 in operable communication with a transmitter 14 and a receiver 16. The mobile terminal 10 further includes a processor 20 or other processing element that provides signals to and receives signals from the transmitter 14 and receiver 16, respectively. The signals include signaling information in accordance with the air interface standard of the applicable cellular system, and also user speech and/or user generated data. In this regard, the mobile terminal 10 is capable of operating with one or more air interface standards, communication protocols, modulation types, and access types. By way of illustration, the mobile terminal 10 is capable of operating in accordance with any of a number of first, second, and/or third-generation communication protocols or the like. For example, the mobile terminal 10 may be capable of operating in accordance with second-generation (2G) wireless communication protocols IS-136 (TDMA), GSM, and IS-95 (CDMA) or third-generation wireless communication protocol Wideband Code Division Multiple Access (WCDMA).
The communication interface of the mobile terminal 10 may also include a second antenna 13, a second transmitter 15, and a second receiver 17. The processor 20 also provides signals to and receives signals from the second transmitter 15 and second receiver 17, respectively. The second antenna 13, transmitter 15, and receiver 17 may be used to communicate directly with other electronic devices, such as other compatible mobile terminals. The mobile terminal 10 may be configured to use the second antenna 13, transmitter 15, and receiver 17 to communicate with other electronic devices in accordance with techniques such as, for example, radio frequency (RF), Bluetooth (BT), infrared (IrDA) or any of a number of different wireless networking techniques, including wireless LAN (WLAN) techniques such as IEEE 802.11 (e.g., 802.11a, 802.11b, 802.11g, 802.11n, etc.), WiMAX techniques such as IEEE 802.16, and/or ultra wideband (UWB) techniques such as IEEE 802.15 or the like.
The mobile terminal 10 may further include a communication interface comprising a communication port 18 configured to be permanently or removably connected to a cable 19 that can be used to connect the mobile terminal 10 to other electronic devices. The processor 20 may provide signals to and receive signals from the communication port 18. The mobile terminal 10 may be configured to use the communication port 18 and the cable 19 to communicate with other electronic devices. The mobile terminal 10 and the cable 19 may be structured so that data and/or power may be communicated between the mobile terminal 10 and the other electronic device. For example, in one embodiment, the cable 19 comprises a Universal Serial Bus (USB) cable having data wires, a power wire, and a ground wire. Power received through the cable 19 may be used by the mobile terminal 10 to power various components of the device and/or charge a battery 34.
It is understood that the processor 20 includes circuitry required for implementing audio and logic functions of the mobile terminal 10. For example, the processor 20 may be comprised of a digital signal processor device, a microprocessor device, and various analog to digital converters, digital to analog converters, and other support circuits. Control and signal processing functions of the mobile terminal 10 are allocated between these devices according to their respective capabilities. The processor 20 thus may also include the functionality to convolutionally encode and interleave message and data prior to modulation and transmission. The processor 20 can additionally include an internal voice coder, and may include an internal data modem. Further, the processor 20 may include functionality to operate one or more software programs, which may be stored in memory. For example, the processor 20 may be capable of operating a connectivity program, such as a conventional Web browser. The connectivity program may then allow the mobile terminal 10 to transmit and receive Web content, such as location-based content, according to a Wireless Application Protocol (WAP), for example.
The mobile terminal 10 also comprises a user interface including an output device such as a conventional earphone or speaker 24, a ringer 22, a microphone 26, a display 28, and a user input interface, all of which are coupled to the processor 20. The user input interface, which allows the mobile terminal 10 to receive data, may include any of a number of devices allowing the mobile terminal 10 to receive data, such as a keypad 30, a touch display (not shown) or other input device. In embodiments including the keypad 30, the keypad 30 may include the conventional numeric (0-9) and related keys (#, *), and other keys used for operating the mobile terminal 10. Alternatively, the keypad 30 may include a conventional QWERTY keypad. The mobile terminal 10 further includes a battery 34, such as a vibrating battery pack, for powering various circuits that are required to operate the mobile terminal 10, as well as optionally providing mechanical vibration as a detectable output.
In one embodiment, the mobile terminal 10 includes a headset (not shown). The headset may comprise a speaker and/or a microphone that may be used in addition to or as an alternative to speaker 24 and microphone 26. The headset may be wired to the mobile terminal 10 or the headset may be configured to wirelessly communicate with the mobile terminal 10 through one of the mobile terminal's communication interfaces. In one embodiment, the mobile terminal may use Bluetooth® wireless technology to communicate with the wireless headset. Bluetoothφ is an open radio-frequency standard that enables cable-free voice and data communication between devices through short-range two-way radio (in the radio frequency range of 2.45 gigahertz).
In an exemplary embodiment, the mobile terminal 10 includes a camera 36 in communication with the processor 20. The camera 36 may be any means for capturing an image for storage, display or transmission. For example, the camera 36 may include a digital camera capable of forming a digital image file from a captured image. As such, the camera 36 includes all hardware, such as a lens or other optical device, and software necessary for creating a digital image file from a captured image. Alternatively, the camera 36 may include only the hardware needed to view an image, while a memory device of the mobile terminal 10 stores instructions for execution by the processor 20 in the form of software necessary to create a digital image file from a captured image. In an exemplary embodiment, the camera 36 may further include a processing element such as a co-processor which assists the processor 20 in processing image data and an encoder and/or decoder for compressing and/or decompressing image data. The encoder and/or decoder may encode and/or decode according to a JPEG or an MPEG standard format.
The mobile terminal 10 may further include a user identity module (UIM) 38. The UIM 38 is typically a memory device having a processor built in. The UIM 38 may include, for example, a subscriber identity module (SIM), a universal integrated circuit card (UICC), a universal subscriber identity module (USIM), a removable user identity module (R-UIM), etc. The UIM 38 typically stores information elements related to a mobile subscriber. In addition to the UIM 38, the mobile terminal 10 may be equipped with memory. For example, the mobile terminal 10 may include volatile memory 40, such as volatile Random Access Memory (RAM) including a cache area for the temporary storage of data. The mobile terminal 10 may also include other non-volatile memory 42, which can be embedded and/or may be removable. The non-volatile memory 42 can additionally or alternatively comprise an EEPROM, flash memory or the like, such as that available from the SanDisk Corporation of Sunnyvale, Calif., or Lexar Media Inc. of Fremont, Calif. The memories can store any of a number of pieces of information, and data, used by the mobile terminal 10 to implement the functions of the mobile terminal 10. For example, the memories can include an identifier, such as an international mobile equipment identification (IMEI) code, capable of uniquely identifying the mobile terminal 10.
Referring now to
The MSC 46 can be coupled to a data network, such as a local area network (LAN), a metropolitan area network (MAN), and/or a wide area network (WAN). The MSC 46 can be directly coupled to the data network. In one typical embodiment, however, the MSC 46 is coupled to a GTW 48, and the GTW 48 is coupled to a WAN, such as the Internet 50. In turn, devices such as processing elements (e.g., personal computers, server computers or the like) can be coupled to the mobile terminal 10 via the Internet 50. For example, as explained below, the processing elements can include one or more processing elements associated with a computing system 52 (two shown in
The BS 44 can also be coupled to a signaling GPRS (General Packet Radio Service) support node (SGSN) 56. As known to those skilled in the art, the SGSN 56 is typically capable of performing functions similar to the MSC 46 for packet switched services. The SGSN 56, like the MSC 46, can be coupled to a data network, such as the Internet 50. The SGSN 56 can be directly coupled to the data network. In a more typical embodiment, however, the SGSN 56 is coupled to a packet-switched core network, such as a GPRS core network 58. The packet-switched core network is then coupled to another GTW 48, such as a GTW GPRS support node (GGSN) 60, and the GGSN 60 is coupled to the Internet 50. In addition to the GGSN 60, the packet-switched core network can also be coupled to a GTW 48. Also, the GGSN 60 can be coupled to a messaging center. In this regard, the GGSN 60 and the SGSN 56, like the MSC 46, may be capable of controlling the forwarding of messages, such as MMS messages. The GGSN 60 and SGSN 56 may also be capable of controlling the forwarding of messages for the mobile terminal 10 to and from the messaging center.
In addition, by coupling the SGSN 56 to the GPRS core network 58 and the GGSN 60, devices such as a computing system 52 and/or origin server 54 may be coupled to the mobile terminal 10 via the Internet 50, SGSN 56 and GGSN 60. In this regard, devices such as the computing system 52 and/or origin server 54 may communicate with the mobile terminal 10 across the SGSN 56, GPRS core network 58 and the GGSN 60. By directly or indirectly connecting mobile terminals 10 and the other devices (e.g., computing system 52, origin server 54, etc.) to the Internet 50, the mobile terminals 10 may communicate with the other devices and with one another, such as according to the Hypertext Transfer Protocol (HTTP), to thereby carry out various functions of the mobile terminals 10.
Although not every element of every possible mobile network is shown and described herein, it should be appreciated that the mobile terminal 10 may be coupled to one or more of any of a number of different networks through the BS 44. In this regard, the network(s) can be capable of supporting communication in accordance with any one or more of a number of first-genaration (1G), second-generation (2G), 2.5G, third-generation (3G) and/or future mobile communication protocols or the like. For example, one or more of the network(s) can be capable of supporting communication in accordance with 2G wireless communication protocols IS-136 (TDMA), GSM, and IS-95 (CDMA). Also, for example, one or more of the network(s) can be capable of supporting communication in accordance with 2.5G wireless communication protocols GPRS, Enhanced Data GSM Environment (EDGE), or the like. Further, for example, one or more of the network(s) can be capable of supporting communication in accordance with 3G wireless communication protocols such as Universal Mobile Telephone System (UMTS) network employing Wideband Code Division Multiple Access (WCDMA) radio access technology. Some narrow-band AMPS (NAMPS), as well as TACS, network(s) may also benefit from embodiments of the present invention, as should dual or higher mode mobile stations (e.g., digital/analog or TDMA/CDMA/analog phones).
The mobile terminal 10 can further be coupled to one or more wireless access points (APs) 62. The APs 62 may comprise access points configured to communicate with the mobile terminal 10 in accordance with techniques such as, for example, radio frequency (RF), Bluetooth (BT), infrared (IrDA) or any of a number of different wireless networking techniques, including wireless LAN (WLAN) techniques such as IEEE 802.11 (e.g., 802.11a, 802.11b, 802.11g, 802.11n, etc.), WiMAX techniques such as IEEE 802.16, and/or ultra wideband (UWB) techniques such as IEEE 802.15 or the like. The APs 62 may be coupled to the Internet 50. Like with the MSC 46, the APs 62 can be directly coupled to the Internet 50. In one embodiment, however, the APs 62 are indirectly coupled to the Internet 50 via a GTW 48. Furthermore, in one embodiment, the BS 44 may be considered as another AP 62. As will be appreciated, by directly or indirectly connecting the mobile terminals 10 and the computing system 52, the origin server 54, and/or any of a number of other devices, to the Internet 50, the mobile terminals 10 can communicate with one another, the computing system, etc., to thereby carry out various functions of the mobile terminals 10, such as to transmit data, content or the like to, and/or receive content, data or the like from, the computing system 52. As used herein, the terms “data,” “content,” “information” and similar terms may be used interchangeably to refer to data capable of being transmitted, received and/or stored in accordance with embodiments of the present invention. Thus, use of any such terms should not be taken to limit the spirit and scope of the present invention.
Although not shown in
Referring now to
In the illustrated embodiment, a server 110 comprises a main database 115. The first mobile terminal 120 and a second mobile terminal 130 each have at least a portion of the main database 115 replicated in a first replicated database 125 and a second replicated database 135, respectively. In general, when changes (e.g., insertions, updates, and deletions) are made to a replicated database on one of the mobile terminals, synchronization items containing each change are communicated to the server 110 and other mobile terminals and electronic devices in the system such that the main database and the other replicated databases can be updated accordingly. Although
In the illustrated embodiment, the first mobile terminal 120 is equipped with a communication interface that allows the mobile terminal 120 to synchronize changes in the replicated database 125 with the databases in other electronic devices using at least two different types of data transmission systems. For example, the first mobile terminal 120 may be configured to communicate database information with another electronic device using either a first data transmission system or a second different data transmission system, depending on which data transmission system, if any, is available to the first mobile terminal 120. In one embodiment, the mobile terminal 120 uses a first communication interface of the mobile terminal to use the first data transmission system and a second communication interface of the mobile terminal to use the second data transmission system. In this regard, the first mobile terminal 120 may have at least three connectivity states: a first connectivity state when there is no data transmission system available that the first mobile terminal 120 is configured to utilize; a second connectivity state when the first mobile terminal 120 is connected to a first data transmission system; and a third connectivity state when the first mobile terminal 120 is connected to a second data transmission system. Embodiments of the present invention may communicate different synchronization items in different ways depending on the current connectivity state of the mobile terminal 120. Although the mobile terminals described herein generally are described as having three connectivity states, other embodiments of the mobile terminals may have more than three connectivity states and may connect to other devices using more than two different types of data transmission systems.
In the exemplary embodiment illustrated in
The second data transmission system in the illustrated embodiment of
In the illustrated embodiment, the first mobile terminal 120 may connect to other electronic devices, such as a second mobile terminal 130, in order to synchronize the first mobile terminal's database 125 with the second mobile terminal's database 135. As with communicating with the server 110, the first mobile terminal 120 may be configured to communicate with the second mobile terminal 130 using more than one data transmission system. For example, the mobile terminal may be configured to communicate to the second mobile terminal 130 via the communication network 150, which may include a cellular network using, for example, a GPRS or GSM system. The first mobile terminal 120 may also be configured to communicate with the second mobile terminal 130 using a second data connection 104. The second data connection 104 may be a wireline or a wireless connection and may comprise, for example, a Bluetooth® connection, a USB-type connection, an RF connection, and infrared connection, and the like. In one embodiment, the data connection 104 is the same type of connection as the data connection 106, and the first mobile terminal 120 may make the connections 104 and 106 using the same communication interface of the first mobile terminal 120. In some embodiments, the second mobile terminal 130 may also receive the changes made in the first mobile terminal's database by synchronizing the second mobile terminal's database 135 with the server's main database 115 after the first mobile terminal 120 synchronizes with the server 110.
Where the first mobile terminal 120 is configured to communicate with other electronic devices using at least two data transfer systems, one data transfer system is generally more desirable than the others for performing certain data transmission tasks. For example, in the system of
Therefore, embodiments of the present invention provide a system of synchronizing replicated databases in an intelligent way in order to utilize the advantages of the different types of connections that may be available to the electronic devices in the data replication system. In this regard, embodiments of the present invention provide for the transfer of synchronization items from a first electronic device to a second electronic device based on characteristics of the synchronization items and characteristics of the available connectivity states of the first electronic device. As described above, relevant characteristics of the connectivity states may include cost and data transmission rates. Other relevant characteristics of the connectivity states may include, for example, battery consumption, reliability, and the permanence of the connection.
In one embodiment, a priority level is determined for each synchronization item and the synchronization items are sorted by comparing the determined priority level for each synchronization item to a threshold priority level. The priority level and the priority threshold may be determined by the processor without user input or may be determined based on user input. Even where the priority level and the priority threshold are determined automatically by the mobile terminal's processor, the priority level and/or the priority threshold may be subsequently adjusted by user input, in accordance with one embodiment of the present invention.
In one embodiment, the priority level for each synchronization item is the size of the synchronization item and the priority threshold is a threshold size. In such an embodiment, for synchronization items where the size of a synchronization item is below the threshold size, the synchronization item is placed in the higher priority queue and, for synchronization items where the size of a synchronization item is above the threshold size, the synchronization item is placed in the lower priority queue. In other embodiments, integers are assigned to each synchronization item, the integers representing the priority level of the synchronization item or whether the synchronization item is a higher priority item or a lower priority item. For example, all high priority items may be assigned a zero and all low priority items may be assigned a one. In another example, each item may be assigned an integer based on its size, such as an integer from 1-10 with 1 representing a very small item and 10 representing a very large item. Items having an integer of 1-4 associated with them, for example, may be placed in the higher priority queue 230, while items with integers of 5-10 associated with them may be placed in a lower priority queue 220. The priority of an item, such as the integer value associated with an item, may be based at least partially on the size of the synchronization item and/or at least partially on user input.
In other embodiments, the priority level may be based on the type of synchronization item or the application that created or can use the synchronization item. In still other embodiments, the priority level may be specified by a user of the first mobile terminal or the second mobile terminal or may be voted on by a plurality of users. In some embodiments, the priority level is a property of a column in a database table.
Note that, when it is said herein, for example, that a first synchronization item has a “higher” priority than a second synchronization item, it does not mean that the integer or other value used as the priority level for the first synchronization item is necessarily greater than the integer or value used as the priority level for the second synchronization item. In some embodiments, the lower the integer used for the priority level, the higher the priority of synchronization item associated with the lower integer. For example, where the priority level is the size of the synchronization item, the smaller the size of a synchronization item, generally the higher the priority of the synchronization item.
In one embodiment of the present invention, synchronization items may be moved from the lower priority queue to the higher priority queue and vice versa on demand, as illustrated by block 240 in
The processor of the first mobile terminal 120 then determines the connectivity state of the first mobile terminal 120 and communicates synchronization items based on the connectivity state of the first mobile terminal 120 and the priority of the synchronization items. In this regard, the processor determines whether a data connection is available, as illustrated by block 320. If no data connection is available, then the mobile terminal is in a first connectivity state in which no synchronization items can be communicated. In such a state, the processor of the mobile terminal 120 waits until a data connection becomes available, as illustrated by block 330.
Where a data connection is available, the processor determines whether the available connection(s) includes a first data connection or a second “more desirable” data connection, as illustrated by block 340. For example, as described above, where the first mobile terminal 120 is configured to be able to communicate data to another electronic device using either a cellular network or a faster and less expensive WLAN, the faster and less expensive WLAN is generally the more desirable connection to use when it is available. If the second more desirable data connection is not available, then the first mobile terminal 120 sends the higher priority synchronization items to the other electronic device using the first data connection, as illustrated by block 350. However, where only the first connection is available, the first mobile terminal 120 does not communicate the lower priority synchronization items to the other electronic device, unless, as described above, the priority system is overridden for one or more synchronization items based on a demand from the mobile terminal user or from an external electronic device.
Although the mobile terminal 120 generally does not send the lower priority synchronization items using the first less desirable data connection, in one embodiment of the present invention, the mobile terminal 120 is configured to send metadata related to the lower priority synchronization items to the other electronic device using the first less desirable data connection, as also illustrated by block 350. For example, the metadata may simply include an indication that a database entry has been inserted, updated, or deleted. In another example, the metadata may include a description of the inserted data, the update, or the deletion. In yet another example, the metadata may include a compressed or an otherwise abbreviated version of the synchronization item. The idea behind sending metadata is to create a smaller object from the large synchronization item that can be transferred using the first less desirable connection without adding considerable extra cost. Then, at a later time when the second more desirable connection becomes available, the original synchronization item can be transferred to the other electronic device. In this regard, where metadata related to a lower priority synchronization item is communicated using the first less desirable data connection, the lower priority synchronization item is still generally queued for transmission via the second more desirable data connection when such a data connection becomes available. As is described below in relation to
In one embodiment, generic or application specific compressors/data extractors may be utilized for generating abbreviated versions of the synchronization item. For example, if a large image was added to the first mobile terminal's database 125, a generic image compressor component may be used to create a scaled-down version of the image. This scaled-down version may be sent to the other electronic device. Likewise, if the image includes annotation information or other metadata, such information may also be inserted in the scaled-down version. Where the synchronization item contains, for example, a large document where the format is dictated by a particular application, then the application may be used to provide an extractor that extracts the portions of the document so that the document portions may be transferred via a first less desirable connection. In this way, although the abbreviated representation of the document does not contain all the details of the large original field, it can still be interpreted by the application without any modifications to its logic. Application specific compressors and extractors may be embodied as software, such as software written in a plug-in like manner, provided in stored procedures, or provided in higher level languages than the synchronization script. Such compressors and extractors may be automatically called by the synchronization script. The creation of a smaller representation of the large synchronization data is sometimes referred to herein as the “deferral” of the data.
Referring again to
The second mobile terminal 130 receives the higher priority synchronization items as well as the metadata for the lower priority synchronization items and updates the replicated database 135 stored in the memory of the second mobile terminal 130, as illustrated by block 420. If the user of second mobile terminal 130, after viewing the metadata related to the lower priority synchronization items, decides that he or she would like the lower priority synchronization items communicated to the second mobile terminal 130 without waiting until the first mobile terminal 120 finds a more desirable data connection, then the user may communicate a request 435 to the first mobile terminal 120 for immediate transmission of a lower priority synchronization item, as represented by block 430. The first mobile terminal 120 may receive this request 435, as represented by block 440, and, in response to the request, send the requested lower priority synchronization item 455 to the recipient device, as represented by block 450. The second mobile terminal 130 receives the requested lower priority synchronization item and updates its database 135 accordingly.
In one embodiment of the system described in
Having thus described embodiments of the present invention in general terms, one embodiment of the present invention is described below with regards to one exemplary application of the system. In this regard, in one embodiment of the invention, the data replication system is configured to be used in the real estate industry by a real estate agency. The real estate agency may have a server with a database stored therein. The database may comprise listings of homes that are for sale. Each real estate agent that works for the real estate agency may have a mobile terminal, such as mobile terminal 120, in which the real estate agent can store at least a portion of the main database as a replicated database.
The communication needs of real estate agents are high since communicating with the customers is a key part of the work and since they are often on the move. Access to property and customer information is important for efficient real estate work and the need for access to such information often arises abruptly when a customer calls. As such it is important for the real estate agent to be able to access the data anytime and anywhere.
Supposing for example that a real estate agent is visiting a customer in order to collect data about the house the customer would like to sell. The customer data is already available in the real estate database, however, during the real estate agent's visit to the house, the real estate agent collects detailed data and takes digital photos of the house. This data should be updated to the database. Meanwhile, a marketing employee of the real estate agency is creating a brochure of houses that have recently come onto the market. The real estate system automates a lot of the brochure creation by collecting relevant data from the real estate database. The marketing employee, however, would like to include the property the real estate agent is currently visiting, although the database does not include any of the details and pictures needed for the brochure.
It is therefore important that the data collected by the real estate go to the database immediately so that it would be available for other agents and employees, such as the marketing employee. The real estate agent, however, only currently has access to a cellular connection. As such, using embodiments of the present invention, small data items may be sent over the cellular network, such as data items like the number of bedrooms and bathrooms, the kitchen floor material, or availability of storage space in the attic. Large data items such as high quality digital pictures, however, may easily take tens of minutes to transfer using cellular networks and would be expensive. As such, embodiments of the present invention automatically schedule such larger data items so that they will be sent the next time a fast connection is available. For example, all of the new data that the real estate agent entered into her replicated database except the digital pictures may be sent immediately while the photos are uploaded only when the real estate agent later visits a suitable hotspot, for example at the office, at home, at a coffee shop, or at some other location.
A further feature of embodiments of the present invention provides the marketing employee with an indication that the real estate agent has taken digital photos even if such photos are not yet included in the main real estate database. The system may provide this indication to the marketing employee by including such an indication or other metadata in the real estate database where the digital pictures would be located. This would allow the marketing employee to decide if he can afford to wait until the system is able to upload the photos from the real estate agent's mobile terminal at a suitable hotspot or if he needs the pictures so urgently that he would like to get them (or some of them) immediately over the cellular data connection.
Furthermore embodiments of the present invention may also enhance the dissemination of changes to a distributed database by utilizing the cheap and fast, near-field communication systems such as Bluetooth®. In his regard, the real estate agents may be further allowed to synchronize between each others' replicated databases using embodiments of the present invention. Synchronization items coming from one agent can be used to synchronize with other agents as well. Such form of message propagation is often referred to a epidemic communication.
The embodiments of the present invention described above and other embodiments may be implemented in a variety of ways. For example, in one embodiment, the data replication system is implemented using the open-source SQLite database engine. SQLite contains a single executable that makes up the relational database management system (RDBMS). Using this database engine or similar database engines, the database and SQL instructions can be passed in the command line. The synchronization between the replicated databases may be handled by a single Python script. The database may be accessed from the Python language via the PySQLite interface.
In one embodiment, the synchronization method uses operation-transfer, i.e., modifying SQL statements executed locally in the database are accumulated using SQL triggers in timely order and replayed at the target replicated database upon synchronization. Tables in the database may be divided into the main data tables (perhaps created and used by the other applications) and synchronization tables needed to transfer changes to the other replicated databases. In this regard, the tables in the local database may include publication tables,
The publication tables describe which columns and rows of which main data tables should be kept synchronized. For example the script may include:
In the above example, the rows of a main data table are selected by a where condition in the sync_publication table and columns are given in a separate sync_publication_column table. Each column may be marked separately for deferral (e.g., compression or abbreviation) using the sync_publication_column_deferral table and the method of deferral may also be given in this table. As described above, the method maps to a Python function that will be called by the synchronization script to create a smaller version of the possible large object. All columns that are part of the primary key would generally be published.
For every table that is offered in the publication, three synchronization tables are created representing the three basic SQL statements that can alter the rows in the tables: INSERT, UPDATE and DELETE. For every published table there are SQL triggers that are fired automatically when a table altering SQL statement is executed. These triggers will fill the synchronization tables with the following information: (1) in the case of an INSERT the values of the published columns are noted; (2) in the case of an UPDATE the new and old values of the published columns are noted; (3) in the case of DELETE the old values of the published columns are noted; and (4) in the case of an UPDATE and DELETE the stored old state may be used for conflict detection and management.
A modification of a single database row corresponds to one synchronization item. In one embodiment of the present invention, each synchronization item is uniquely identified by the following triplet: the ID of the replicated database (e.g., an ID unique to each electronic device that in the system that has a replicated database stored therein), the synchronization priority of the item, and the time of the modification. The ID is simply a name referred as peer. Each replicated database should have a unique name. As described above, the priority describes the importance of an item or some other feature of the synchronization item such as its size. For example large items are given larger numbers meaning lower priority. The time of modification may be a logical clock time that is increased every time a new synchronization item is inserted thus keeping the order of the altering instructions. The value of the clock may be handled by each peer separately.
Therefore, the synchronization items are referenced through a central sync_event table as follows:
The column table_name refers to the modified main data table and type refers to the nature of the modification (i.e., insert, update or delete). These two columns tell which synchronization table holds the particular synchronization item. The item is then located with the (peer, priority, clock) primary key triplet.
The sync_status table, shown below, is used to store the status of received synchronization items. Peers send synchronization items in synchronization packages where each item has the same priority level. Thus, a package may be identified by the (peer, priority) pair. The clock value of the latest synchronization item in a package is stored in the lastclock column.
Before the synchronization items are used they are generally reviewed to determine whether deferral may be needed for any field of the synchronization item. In this regard, the SQL triggers that generate the synchronization items may initially mark the synchronization items as private by setting the public field in the sync_event table to zero. The synchronization script may then go through each synchronization item, deferring any field of the item if needed. Once this step is completed, the synchronization script may then set the value of the public field to one so the synchronization items become available for synchronization.
Any large object that is marked for deferral in the publication may be processed, for example, using the two steps:
Synchronization is generally a one-way operation where one peer propagates its synchronization state to another peer. The former peer is often referred as the source and the latter one is the destination peer. Naturally, after the synchronization is finished the roles can be interchanged so both can become aware of each other's modifications.
The processed described below follows the logic of the Python script, in accordance with one embodiment of the present invention. First, the source may check for any private items and defer them as necessary. The next step includes determining the maximum priority of the synchronization, i.e. only synchronization packages that have the same or lower number (higher importance) of priority will be sent to the destination. The priority is usually determined by the available connection, i.e. slower connections allow only the highest priority packages, although, as described above, the priority can be overridden if necessary in some embodiments of the present invention.
The script will then iterate through the source's sync_status table and for every synchronization package it will compare the lastclock value with the value seen by the destination. If there is no matching row in the destination's table it is assumed that the peer has not yet seen any items from that particular package. The synchronization packages are then processed in decreasing order of priority. This guarantees that the deferred items are put into the database correctly when both the small representations of the large items and large items themselves are transferred. In this case the large items have a lower priority thus it correctly replaces the previously entered smaller representation of the large item.
The synchronization items in one synchronization package are handled in the increasing order of clock value. Each synchronization item is transformed back to an SQL statement which is executed on the destination's database. During this process the SQL triggers of the destination's database are turned off so that the triggers do not generate any unnecessary synchronization info. The row of the synchronization item and its reference from the sync_event table is copied directly the synchronization tables of the destination.
When each synchronization package is processed the synchronization is completed. The script will enable the SQL triggers in the destination. The destination will then be able to propagate the received items to other peers. The synchronization items received by the destination device may not be the complete item set of the source device as this also depends on the selected synchronization priority. However, if all the items are transferred to the destination device, the destination will have the same knowledge of the deferred items as well.
In the above described exemplary embodiment, no new data should be entered into either database during the synchronization. On the source side, this ensures that the source's lastclock values will include only public items. On the destination side, the triggers are turned off during synchronization so any newly inserted data would not been seen by the synchronization process. For distributed primary key management embodiments of the system assign different intervals of keys to different peers. The distribution and auto incrementation of these primary keys may be handled by the synchronization SQL triggers acting on row insertion.
Although the above description generally describes a situation where a mobile terminal is synchronizing items with one database in another electronic device, in other embodiments, the mobile terminal may be configured to synchronize the same items with multiple databases or different items with different databases. As such, separate higher and lower priority queues may be maintained for each different database with which the mobile terminal is to synchronize. In one embodiment, queues may include another field describing the database to which the item is to be synchronized.
The functions described above with respect to the various embodiments of the present invention may be carried out in many ways. For example, any suitable means for carrying out each of the functions described above may be employed to carry out embodiments of the invention. According to one aspect of the present invention, all or a portion of the system of the present invention generally operates under control of a computer program product. The computer program product for performing the various processes and operations of embodiments of the present invention includes a computer-readable storage medium, such as a non-volatile storage medium, and computer-readable program code portions, such as a series of computer instructions, embodied in the computer-readable storage medium. For example, in one embodiment, the respective processors of the various electronic devices generally execute a database synchronization application in order to perform the various functions described above with reference to the various electronic devices, such as those functions shown in conjunction with
In this regard,
It will also be understood that each block or step of a described herein, and combinations of blocks or steps, can be implemented by special purpose hardware-based computer systems which perform the specified functions or steps, or combinations of special purpose hardware and computer instructions.
Many modifications and other embodiments of the inventions set forth herein will come to mind to one skilled in the art to which these inventions pertain having the benefit of the teachings presented in the foregoing descriptions and the associated drawings. Therefore, it is to be understood that the inventions are not to be limited to the specific embodiments disclosed and that modifications and other embodiments are intended to be included within the scope of the appended claims. Although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.