Package org.syncany.plugins.transfer.to

Examples of org.syncany.plugins.transfer.to.TransactionTO


    assertEquals(2, tempFiles.length);
    assertTrue(tempFiles[0].length() > 500 * 1024 || tempFiles[1].length() > 500 * 1024); // The second multichunk should be >500 KB
    assertTrue(tempFiles[0].length() < 100 * 1024 || tempFiles[1].length() < 100 * 1024); // The database file should be <100 KB

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(3, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));

    // 2. Double check if list() does not return the multichunk
    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
    Map<String, MultichunkRemoteFile> multiChunkList = transferManager.list(MultichunkRemoteFile.class);
View Full Code Here


    assertEquals(2, tempFiles.length);
    assertTrue(tempFiles[0].length() > 500 * 1024 || tempFiles[1].length() > 500 * 1024); // The second multichunk should be >500 KB
    assertTrue(tempFiles[0].length() < 100 * 1024 || tempFiles[1].length() < 100 * 1024); // The database file should be <100 KB

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(3, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));

    // 2. Double check if list() does not return the multichunk
    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
    Map<String, MultichunkRemoteFile> multiChunkList = transferManager.list(MultichunkRemoteFile.class);
View Full Code Here

    assertEquals(0, new File(testConnection.getPath() + "/multichunks/").listFiles().length);
    assertEquals(1, new File(testConnection.getPath() + "/actions/").listFiles().length);
    assertEquals(1, new File(testConnection.getPath() + "/transactions/").listFiles().length);

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(2, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("database-"));

    // Tear down
    clientA.deleteTestData();
  }
View Full Code Here

    assertEquals(1, new File(testConnection.getPath() + "/transactions/").listFiles().length);

    assertEquals(1, new File(testConnection.getPath() + "/temporary/").listFiles().length);

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(2, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("database-"));

    // 2. Second try succeeds and must clean up the transactions
    clientA.up();

    assertEquals(1, new File(testConnection.getPath() + "/databases/").listFiles().length);
View Full Code Here

    assertEquals(1, tempFiles.length);
    assertTrue(tempFiles[0].length() > 500 * 1024); // 1 MC with 1 MB, 1 with 4 MB; must be larger than 500 KB

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(3, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));

    // 2. Second try succeeds and must clean up the transactions
    clientA.up();

    assertEquals(1, new File(testConnection.getPath() + "/databases/").listFiles().length);
View Full Code Here

   *        This file will be deleted as part of the rollback.
   */
  private void rollbackSingleTransaction(RemoteTransaction rollbackTransaction, TransactionTO cancelledTransaction,
      TransactionRemoteFile remoteCancelledTransaction) throws StorageException {

    TransactionTO cancelledOwnTransaction = cancelledTransaction;
    addRollbackActionsToTransaction(rollbackTransaction, cancelledOwnTransaction.getActions());

    // Get corresponding remote file of transaction and delete it.
    TransactionRemoteFile cancelledOwnTransactionFile = remoteCancelledTransaction;
    rollbackTransaction.delete(cancelledOwnTransactionFile);

    // Nicer debug output
    if (logger.isLoggable(Level.INFO)) {
      logger.log(Level.INFO, "Unfinished transaction " + cancelledOwnTransactionFile + ". Rollback necessary!");

      for (ActionTO action : cancelledOwnTransaction.getActions()) {
        logger.log(Level.INFO, "- Needs to be rolled back: " + action);
      }
    }
  }
View Full Code Here

        // Download transaction file
        download(transaction, transactionFile);

        Transformer transformer = config == null ? null : config.getTransformer();
        TransactionTO transactionTO = TransactionTO.load(transformer, transactionFile);

        // Extract final locations
        transactions.put(transactionTO, transaction);
        transactionFile.delete();
      }
View Full Code Here

  private LocalEventBus eventBus;

  public RemoteTransaction(Config config, TransferManager transferManager) {
    this.config = config;
    this.transferManager = transferManager;
    this.transactionTO = new TransactionTO(config.getMachineName());
    this.eventBus = LocalEventBus.getInstance();
  }
View Full Code Here

TOP

Related Classes of org.syncany.plugins.transfer.to.TransactionTO

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.