Package org.syncany.database

Examples of org.syncany.database.MemoryDatabase


    // Add dirty data (if existent)
    addDirtyData(deltaDatabaseVersion);

    // New delta database
    MemoryDatabase deltaDatabase = new MemoryDatabase();
    deltaDatabase.addDatabaseVersion(deltaDatabaseVersion);

    // Save delta database locally
    long newestLocalDatabaseVersion = deltaDatabaseVersion.getVectorClock().getClock(config.getMachineName());
    DatabaseRemoteFile remoteDeltaDatabaseFile = new DatabaseRemoteFile(config.getMachineName(), newestLocalDatabaseVersion);
    File localDeltaDatabaseFile = config.getCache().getDatabaseFile(remoteDeltaDatabaseFile.getName());
View Full Code Here


    // Read database files
    DatabaseBranches unknownRemoteBranches = new DatabaseBranches();

    for (Map.Entry<File, DatabaseRemoteFile> remoteDatabaseFileEntry : remoteDatabases.entrySet()) {
      MemoryDatabase remoteDatabase = new MemoryDatabase(); // Database cannot be reused, since these might be different clients

      File remoteDatabaseFileInCache = remoteDatabaseFileEntry.getKey();
      DatabaseRemoteFile remoteDatabaseFile = remoteDatabaseFileEntry.getValue();
     
      databaseSerializer.load(remoteDatabase, remoteDatabaseFileInCache, null, null, DatabaseReadType.HEADER_ONLY, null, null); // only load headers!
      List<DatabaseVersion> remoteDatabaseVersions = remoteDatabase.getDatabaseVersions();

      // Populate branches
      DatabaseBranch remoteClientBranch = unknownRemoteBranches.getBranch(remoteDatabaseFile.getClientName(), true);

      for (DatabaseVersion remoteDatabaseVersion : remoteDatabaseVersions) {
View Full Code Here

      logger.log(Level.WARNING, "  + Nothing to update. Nice!");
      result.setResultCode(DownResultCode.OK_NO_REMOTE_CHANGES);
    }
    else {     
      logger.log(Level.INFO, "Loading winners database (PURGE) ...");     
      MemoryDatabase winnersPurgeDatabase = readWinnersDatabase(winnersApplyBranch, databaseFileList, DatabaseVersionType.PURGE, null);
      Map<FileHistoryId, FileVersion> ignoredMostRecentPurgeVersions = extractMostRecentPurgeVersions(winnersPurgeDatabase.getFileHistories());
     
      logger.log(Level.INFO, "Loading winners database (DEFAULT) ...");     
      MemoryDatabase winnersDatabase = readWinnersDatabase(winnersApplyBranch, databaseFileList, DatabaseVersionType.DEFAULT, ignoredMostRecentPurgeVersions);
     
      if (options.isApplyChanges()) {
        new ApplyChangesOperation(config, localDatabase, transferManager, winnersDatabase, result).execute();
      }
      else {
View Full Code Here

   * @return Returns a loaded memory database containing all metadata from the winner's branch
   */
  private MemoryDatabase readWinnersDatabase(DatabaseBranch winnersApplyBranch, DatabaseFileList databaseFileList,
      DatabaseVersionType filterType, Map<FileHistoryId, FileVersion> ignoredMostRecentPurgeVersions) throws IOException, StorageException {

    MemoryDatabase winnerBranchDatabase = new MemoryDatabase();

    List<DatabaseVersionHeader> winnersApplyBranchList = winnersApplyBranch.getAll();
   
    String rangeClientName = null;
    VectorClock rangeVersionFrom = null;
View Full Code Here

       
        if (hasMuddyDatabaseVersionHeaders) {
          logger.log(Level.INFO, "DIRTY database version headers of "+ otherClientName + ":  " +otherMuddyDatabaseVersionHeaders);
 
          for (DatabaseVersionHeader muddyDatabaseVersionHeader : otherMuddyDatabaseVersionHeaders) {
            MemoryDatabase muddyMultiChunksDatabase = new MemoryDatabase();
           
            File localFileForMuddyDatabaseVersion = databaseFileList.getNextDatabaseVersionFile(muddyDatabaseVersionHeader);
            VectorClock fromVersion = muddyDatabaseVersionHeader.getVectorClock();
            VectorClock toVersion = muddyDatabaseVersionHeader.getVectorClock();
           
            logger.log(Level.INFO, "  - Loading " + muddyDatabaseVersionHeader + " from file " + localFileForMuddyDatabaseVersion);
            databaseSerializer.load(muddyMultiChunksDatabase, localFileForMuddyDatabaseVersion, fromVersion, toVersion, DatabaseReadType.FULL, DatabaseVersionType.DEFAULT, null);
           
            boolean hasMuddyMultiChunks = muddyMultiChunksDatabase.getMultiChunks().size() > 0;
           
            if (hasMuddyMultiChunks) {
              muddyMultiChunksPerDatabaseVersion.put(muddyDatabaseVersionHeader, muddyMultiChunksDatabase.getMultiChunks());
            }
          }
         
        }
      }
View Full Code Here

public class RestoreFileSystemAction extends FileCreatingFileSystemAction {
  private String relativeTargetPath;
 
  public RestoreFileSystemAction(Config config, FileVersion fileVersion, String relativeTargetPath) {
    super(config, new MemoryDatabase(), null, fileVersion);
    this.relativeTargetPath = relativeTargetPath;
  }
View Full Code Here

    return branch;
  }
 
  public static MemoryDatabase readDatabaseFileFromDisk(File databaseFile, Transformer transformer) throws IOException {
    MemoryDatabase db = new MemoryDatabase();
   
    DatabaseXmlSerializer dao = new DatabaseXmlSerializer(transformer);
    dao.load(db, databaseFile, null, null, DatabaseReadType.FULL, DatabaseVersionType.DEFAULT, null);
   
    return db;
View Full Code Here

TOP

Related Classes of org.syncany.database.MemoryDatabase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.