Package org.syncany.operations.down
Class DatabaseReconciliator
- java.lang.Object
-
- org.syncany.operations.down.DatabaseReconciliator
-
public class DatabaseReconciliator extends java.lang.Object
The database reconciliator implements various parts of the sync down algorithm (see also:DownOperation
). Its main responsibility is to compare the local database to the other clients' delta databases. The final goal of the algorithms described in this class is to determine a winningMemoryDatabase
(or better: a winningDatabaseBranch
) of a client.All algorithm parts largely rely on the comparison of a client's database branch, i.e. its committed set of
DatabaseVersion
s. Instead of comparing the entire database versions of the different clients, however, the comparisons solely rely on theDatabaseVersionHeader
s. In particular, most of them only compare theVectorClock
. If the vector clocks are in conflict (= simultaneous), the local timestamp is used as a final decision (oldest wins).Algorithm:
- Input: Local branch, unknown remote branches
- Sort the databaseversions by vectorclocks, tiebreaking with timestamps.
- Walk through the sorted list and construct the winning branch.
- See Also:
DownOperation
,VectorClock
-
-
Constructor Summary
Constructors Constructor Description DatabaseReconciliator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DatabaseBranch
findLosersPruneBranch(DatabaseBranch losersBranch, DatabaseBranch winnersBranch)
java.util.Map.Entry<java.lang.String,DatabaseBranch>
findWinnerBranch(DatabaseBranches allBranches)
Implements the core synchronization algorithm as describedin the class description
.DatabaseBranch
findWinnersApplyBranch(DatabaseBranch losersBranch, DatabaseBranch winnersBranch)
-
-
-
Constructor Detail
-
DatabaseReconciliator
public DatabaseReconciliator()
-
-
Method Detail
-
findWinnerBranch
public java.util.Map.Entry<java.lang.String,DatabaseBranch> findWinnerBranch(DatabaseBranches allBranches) throws java.lang.Exception
Implements the core synchronization algorithm as describedin the class description
.- Parameters:
allBranches
- All branches of all machines (including local)- Returns:
- Returns the branch of the winning client
- Throws:
java.lang.Exception
-
findLosersPruneBranch
public DatabaseBranch findLosersPruneBranch(DatabaseBranch losersBranch, DatabaseBranch winnersBranch)
-
findWinnersApplyBranch
public DatabaseBranch findWinnersApplyBranch(DatabaseBranch losersBranch, DatabaseBranch winnersBranch)
-
-