Package org.syncany.plugins.transfer.files

Examples of org.syncany.plugins.transfer.files.DatabaseRemoteFile


    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) {
        DatabaseVersionHeader header = remoteDatabaseVersion.getHeader();
        remoteClientBranch.add(header);
      }
View Full Code Here


        boolean isOwnDatabaseVersionHeader = config.getMachineName().equals(databaseVersionHeader.getClient());
       
        if (isOwnDatabaseVersionHeader) {
          String remoteFileToPruneClientName = config.getMachineName();
          long remoteFileToPruneVersion = databaseVersionHeader.getVectorClock().getClock(config.getMachineName());
          DatabaseRemoteFile remoteFileToPrune = new DatabaseRemoteFile(remoteFileToPruneClientName, remoteFileToPruneVersion);

          logger.log(Level.INFO, "    * Deleting own remote database file " + remoteFileToPrune + " ...");
          transferManager.delete(remoteFileToPrune);             
        }
        else {
View Full Code Here

    localDatabase.removeUnreferencedDatabaseEntities();
    localDatabase.persistPurgeDatabaseVersion(purgeDatabaseVersion);   

    // Remote: serialize purge database version to file and upload
    DatabaseRemoteFile newPurgeRemoteFile = findNewPurgeRemoteFile(purgeDatabaseVersion.getHeader());
    File tempLocalPurgeDatabaseFile = writePurgeFile(purgeDatabaseVersion, newPurgeRemoteFile);

    addPurgeFileToTransaction(tempLocalPurgeDatabaseFile, newPurgeRemoteFile);
    remoteDeleteUnusedMultiChunks(unusedMultiChunks);
View Full Code Here

    return localPurgeDatabaseFile;
  }

  private DatabaseRemoteFile findNewPurgeRemoteFile(DatabaseVersionHeader purgeDatabaseVersionHeader) throws StorageException {
    Long localMachineVersion = purgeDatabaseVersionHeader.getVectorClock().getClock(config.getMachineName());
    return new DatabaseRemoteFile(config.getMachineName(), localMachineVersion);
  }
View Full Code Here

      // 1. Determine files to delete remotely
      List<DatabaseRemoteFile> toDeleteDatabaseFiles = new ArrayList<DatabaseRemoteFile>(clientDatabaseFiles);

      // 2. Write merge file
      DatabaseRemoteFile lastRemoteMergeDatabaseFile = toDeleteDatabaseFiles.get(toDeleteDatabaseFiles.size() - 1);
      File lastLocalMergeDatabaseFile = config.getCache().getDatabaseFile(lastRemoteMergeDatabaseFile.getName());

      logger.log(Level.INFO, "   + Writing new merge file (from {0}, to {1}) to {2} ...", new Object[] {
          toDeleteDatabaseFiles.get(0).getClientVersion(), lastRemoteMergeDatabaseFile.getClientVersion(), lastLocalMergeDatabaseFile });

      long lastLocalClientVersion = lastRemoteMergeDatabaseFile.getClientVersion();
      Iterator<DatabaseVersion> lastNDatabaseVersions = localDatabase.getDatabaseVersionsTo(client, lastLocalClientVersion);

      DatabaseXmlSerializer databaseDAO = new DatabaseXmlSerializer(config.getTransformer());
      databaseDAO.save(lastNDatabaseVersions, lastLocalMergeDatabaseFile);
View Full Code Here

        "up"
      }).start();
    }
   
    for (int i=1; i<=20; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File databaseFileInRepo = new File(connectionSettings.get("path")+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+databaseFileInRepo, databaseFileInRepo.exists());
    }
       
    TestCliUtil.deleteTestLocalConfigAndData(clientA);   
View Full Code Here

    assertTrue(cliOut[4].contains("22 database files merged"));
    assertTrue(cliOut[5].contains("1 file histories shortened"));
    assertTrue(cliOut[6].contains("Cleanup successful"));

    for (int i=1; i<=21; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File databaseFileInRepo = new File(connectionSettings.get("path")+"/databases/"+expectedDatabaseRemoteFile.getName());

      assertFalse("Database file SHOULD NOT exist: "+databaseFileInRepo, databaseFileInRepo.exists());
    }
   
    for (int i=22; i<=22; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File databaseFileInRepo = new File(connectionSettings.get("path")+"/databases/"+expectedDatabaseRemoteFile.getName());

      assertTrue("Database file SHOULD exist: "+databaseFileInRepo, databaseFileInRepo.exists());
    }
   
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
View Full Code Here

TOP

Related Classes of org.syncany.plugins.transfer.files.DatabaseRemoteFile

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.