Package org.syncany.plugins.transfer.files

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


    ApplicationSqlDao applicationDao = new ApplicationSqlDao(databaseConnection);
    List<DatabaseRemoteFile> actualKnownDatabases = applicationDao.getKnownDatabases();

    // Test
    assertTrue(CollectionUtil.containsExactly(Arrays.asList(new DatabaseRemoteFile[] {
        new DatabaseRemoteFile("database-B-0000000001"),
        new DatabaseRemoteFile("database-B-0000000002"),
        new DatabaseRemoteFile("database-B-0000000003")
    }), actualKnownDatabases));

    // Tear down
    databaseConnection.close();
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
View Full Code Here


    // Run
    ApplicationSqlDao applicationDao = new ApplicationSqlDao(databaseConnection);

    List<DatabaseRemoteFile> expectedKnownDatabases = Arrays.asList(new DatabaseRemoteFile[] {
        new DatabaseRemoteFile("database-A-0000000001"),
        new DatabaseRemoteFile("database-V-0000000001"),
        new DatabaseRemoteFile("database-B-0000000001"),
        new DatabaseRemoteFile("database-A-0000000002")
    });

    applicationDao.writeKnownRemoteDatabases(expectedKnownDatabases);
    List<DatabaseRemoteFile> actualKnownDatabases = applicationDao.getKnownDatabases();
View Full Code Here

    // Prepare
    ApplicationSqlDao applicationDao = new ApplicationSqlDao(databaseConnection);

    List<DatabaseRemoteFile> expectedKnownDatabases = Arrays.asList(new DatabaseRemoteFile[] {
        new DatabaseRemoteFile("database-A-0000000001")
    });

    applicationDao.writeKnownRemoteDatabases(expectedKnownDatabases);

    // Run & Test
View Full Code Here

        new SyncanyRemoteFile[] { new SyncanyRemoteFile() });

    uploadDownloadListDelete(transferManager, tempFromDir, tempToDir, MasterRemoteFile.class, new MasterRemoteFile[] { new MasterRemoteFile() });

    uploadDownloadListDelete(transferManager, tempFromDir, tempToDir, DatabaseRemoteFile.class, new DatabaseRemoteFile[] {
        new DatabaseRemoteFile("database-A-0001"), new DatabaseRemoteFile("database-B-0002") });

    uploadDownloadListDelete(transferManager, tempFromDir, tempToDir, MultichunkRemoteFile.class, new MultichunkRemoteFile[] {
        new MultichunkRemoteFile("multichunk-84f7e2b31440aaef9b73de3cadcf4e449aeb55a1"),
        new MultichunkRemoteFile("multichunk-beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"),
        new MultichunkRemoteFile("multichunk-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") });
View Full Code Here

      clientA.createNewFile("file"+i, 1);
      clientA.up();   
    }
   
    for (int i=1; i<=15; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
    }

    // ROUND 2: 1x sync up (cleanup expected!)
    clientA.createNewFile("file16", 1);
    clientA.up();   
   
    clientA.cleanup(); // Force cleanup

    for (int i=1; i<=15; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
   
    for (int i=16; i<=16; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
    }
   
    // ROUND 3: many sync up (no cleanup expected here)   
    for (int i=17; i<=30; i++) {
      clientA.createNewFile("file"+i, 1);
      clientA.up();   
    }
   
    for (int i=1; i<=15; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
   
    for (int i=16; i<=30; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
    }   
   
    // ROUND 4: 1x sync up (cleanup expected!)
    clientA.createNewFile("file31", 1);
    clientA.up();   
   
    CleanupOperationOptions options = new CleanupOperationOptions();
   
    options.setForce(true);
   
    clientA.cleanup(options); // Force cleanup

    for (int i=1; i<=30; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    
    for (int i=31; i<=31; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
   
   
    // Tear down
View Full Code Here

    List<DatabaseRemoteFile> knownDatabases = new ArrayList<DatabaseRemoteFile>();
       
    try (PreparedStatement preparedStatement = getStatement("application.select.all.getKnownDatabases.sql")) {
      try (ResultSet resultSet = preparedStatement.executeQuery()) {   
        while (resultSet.next()) {
          knownDatabases.add(new DatabaseRemoteFile(resultSet.getString("database_name")));
        }
       
        return knownDatabases;
     
    }
View Full Code Here

   */
  public File getExactDatabaseVersionFile(DatabaseVersionHeader databaseVersionHeader) throws StorageException {
    String clientName = databaseVersionHeader.getClient();
    long clientFileClock = databaseVersionHeader.getVectorClock().getClock(clientName);
   
    DatabaseRemoteFile potentialDatabaseRemoteFileForRange = new DatabaseRemoteFile(clientName, clientFileClock);       
    return shortFilenameToFileMap.get(potentialDatabaseRemoteFileForRange.getName());
  }
View Full Code Here

   */
  public File getNextDatabaseVersionFile(DatabaseVersionHeader databaseVersionHeader) throws StorageException {
    String clientName = databaseVersionHeader.getClient();
    long clientFileClock = databaseVersionHeader.getVectorClock().getClock(clientName);
   
    DatabaseRemoteFile potentialDatabaseRemoteFileForRange = null;
    File databaseFileForRange = null;
   
    int maxRounds = 100000; // TODO [medium] This is ugly and potentially dangerous. Can this lead to incorrect results?
    boolean isLoadableDatabaseFile = false;
   
    while (!isLoadableDatabaseFile && maxRounds > 0) {
      potentialDatabaseRemoteFileForRange = new DatabaseRemoteFile(clientName, clientFileClock);
     
      databaseFileForRange = shortFilenameToFileMap.get(potentialDatabaseRemoteFileForRange.getName());
      isLoadableDatabaseFile = databaseFileForRange != null
     
      maxRounds--;
      clientFileClock++;
    }
View Full Code Here

    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());

    logger.log(Level.INFO, "Saving local delta database, version {0} to file {1} ... ", new Object[] { deltaDatabaseVersion.getHeader(),
        localDeltaDatabaseFile });

    saveDeltaDatabase(deltaDatabase, localDeltaDatabaseFile);
View Full Code Here

    TreeMap<File, DatabaseRemoteFile> unknownRemoteDatabasesInCache = new TreeMap<File, DatabaseRemoteFile>();
    int downloadFileIndex = 0;

    for (DatabaseRemoteFile remoteFile : unknownRemoteDatabases) {
      File unknownRemoteDatabaseFileInCache = config.getCache().getDatabaseFile(remoteFile.getName());
      DatabaseRemoteFile unknownDatabaseRemoteFile = new DatabaseRemoteFile(remoteFile.getName());
     
      logger.log(Level.INFO, "- Downloading {0} to local cache at {1}", new Object[] { remoteFile.getName(), unknownRemoteDatabaseFileInCache });
      eventBus.post(new DownDownloadFileSyncExternalEvent(config.getLocalDir().getAbsolutePath(), "database", ++downloadFileIndex, unknownRemoteDatabases.size()));
     
      transferManager.download(unknownDatabaseRemoteFile, unknownRemoteDatabaseFileInCache);
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.