diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2012-08-23 14:25:55 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2012-08-31 14:00:46 +0200 |
commit | dff2be3c9aaf9913ec520b03c0369b0c9e5611ac (patch) | |
tree | 276569cf5b79eeb9c4da5072d427b797c3f9f25c /src/syncevo/LocalTransportAgent.cpp | |
parent | 2f25b65cbc4a5756b3f36074fec412d7aa19a759 (diff) |
engine: local cache sync mode
This patch introduces support for true one-way syncing ("caching"):
the local datastore is meant to be an exact copy of the data on the
remote side. The assumption is that no modifications are ever made
locally outside of syncing. This is different from one-way sync modes,
which allows local changes and only temporarily disables sending them
to the remote side.
Another goal of the new mode is to avoid data writes as much as
possible.
This new mode only works on the server side of a sync, where the
engine has enough control over the data flow.
Most of the changes are in libsynthesis. SyncEvolution only needs to
enable the new mode, which is done via an extension of the "sync"
property:
- "local-cache-incremental" will do an incremental sync (if possible)
or a slow sync (otherwise). This is usually the right mode to use,
and thus has "local-cache" as alias.
- "local-cache-slow" will always do a slow sync. Useful for
debugging or after (accidentally) making changes on the server side.
An incremental sync will ignore such changes because they are not
meant to happen and thus leave client and sync out-of-sync!
Both modes are recorded in the sync report of the local side. The
target side is the client and records the normal "two-way" or "slow"
sync modes.
With the current SyncEvolution contact field list, first, middle and
last name are used to find matches during any kind of slow sync. The
organization field is ignored for matching during the initial slow
sync and used in all following ones. That's okay, the difference won't
matter in practice because the initial slow sync in PBAP caching will
be done with no local data. The test achieve the same result in both
cases by keeping the organization set in the reduced data set.
It's also okay to include the property in the comparison, because it
might help to distinguish between "John Doe" in different companies.
It might be worthwhile to add more fields as match criteria, for
example the birthday. Currently they are excluded, probably because
they are not trusted to be supported by SyncML peers. In caching mode
the situation is different, because all our data came from the peer.
The downside is that in cases where matching has to be done all the
time because change detection is not supported (PBAP), including the
birthday as criteria will cause unnecessary contact removed/added
events (and thus disk IO) when a contact was originally created
without birthday locally and then a birthday gets added on the phone.
Testing is done as part of the D-Bus testing framework, because usually
this functionality will be used as part of the D-Bus server and writing
tests in Python is easier.
A new test class "TestLocalCache" contains the new tests. They include
tests for removing extra items during a slow sync (testItemRemoval),
adding new client items under various conditions (testItemAdd*) and
updating/removing an item during incremental syncing
(testItemUpdate/Delete*). Doing these changes during a slow sync could
also be tested (not currently covered).
The tests for removing properties (testPropertyRemoval*) cover
removing almost all contact properties during an initial slow sync, a
second slow sync (which is treated differently in libsynthesis, see
merge=always and merge=slowsync), and an incremental sync.
Diffstat (limited to 'src/syncevo/LocalTransportAgent.cpp')
-rw-r--r-- | src/syncevo/LocalTransportAgent.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/syncevo/LocalTransportAgent.cpp b/src/syncevo/LocalTransportAgent.cpp index 2bf040ea..b1c19d5e 100644 --- a/src/syncevo/LocalTransportAgent.cpp +++ b/src/syncevo/LocalTransportAgent.cpp @@ -781,6 +781,17 @@ class LocalTransportAgentChild : public TransportAgent, private LoggerBase mode = SYNC_ONE_WAY_FROM_REMOTE; } else if (mode == SYNC_ONE_WAY_FROM_REMOTE) { mode = SYNC_ONE_WAY_FROM_LOCAL; + } else if (mode == SYNC_LOCAL_CACHE_SLOW) { + // Remote side is running in caching mode and + // asking for refresh. Send all our data. + mode = SYNC_SLOW; + } else if (mode == SYNC_LOCAL_CACHE_INCREMENTAL) { + // Remote side is running in caching mode and + // asking for an update. Use two-way mode although + // nothing is going to come back (simpler that way + // than using one-way, which has special code + // paths in libsynthesis). + mode = SYNC_TWO_WAY; } targetSource.setSync(PrettyPrintSyncMode(mode, true), true); targetSource.setURI(sourceName, true); |