/** * This method uses the {@link DatabaseReconciliator} to compare the local database with the * downloaded remote databases, in order to determine a winner. The winner's database versions * will be applied locally. * * <p>For the comparison, the {@link DatabaseVersionHeader}s (mainly the {@link VectorClock}) of each * database version are compared. Using these vector clocks, the underlying algorithms determine * potential conflicts (between database versions, = simultaneous vector clocks), and resolve these * conflicts by comparing local timestamps. * * <p>The detailed algorithm is described in the {@link DatabaseReconciliator}. * * @param localBranch Local database branch (extracted from the local database) * @param allStitchedBranches The newly downloaded remote database version headers (= branches) * @return Returns the branch of the winner * @throws Exception If any kind of error occurs (...) */ private Map.Entry<String, DatabaseBranch> determineWinnerBranch(DatabaseBranches allStitchedBranches) throws Exception { logger.log(Level.INFO, "Determine winner using database reconciliator ..."); Entry<String, DatabaseBranch> winnersBranch = databaseReconciliator.findWinnerBranch(allStitchedBranches); if (winnersBranch != null) { return winnersBranch; } else { return new AbstractMap.SimpleEntry<String, DatabaseBranch>("", new DatabaseBranch()); } }