use of org.syncany.operations.down.DownOperation in project syncany by syncany.
the class OperationPerformanceTest method testOperationPerformance.
@Test
public void testOperationPerformance() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
Config configA = TestConfigUtil.createTestLocalConfig("A", testConnection);
Config configB = TestConfigUtil.createTestLocalConfig("B", testConnection);
// Add new files on A and upload it
TestFileUtil.createRandomFilesInDirectory(configA.getLocalDir(), 5000 * 1024, 3);
long timeSyncUpStart = System.currentTimeMillis();
new UpOperation(configA).execute();
long timeSyncUpEnd = System.currentTimeMillis();
long timeSyncUpTotal = timeSyncUpEnd - timeSyncUpStart;
if (timeSyncUpTotal > 3000) {
fail("Sync up took: " + timeSyncUpTotal + " ms");
}
logger.log(Level.INFO, "Sync up performance: " + timeSyncUpTotal + " ms");
// Sync down B
long timeSyncDownStart = System.currentTimeMillis();
new DownOperation(configB).execute();
long timeSyncDownEnd = System.currentTimeMillis();
long timeSyncDownTotal = timeSyncDownEnd - timeSyncDownStart;
if (timeSyncDownTotal > 3000) {
fail("Sync down took: " + timeSyncDownTotal + " ms");
}
logger.log(Level.INFO, "Sync down performance: " + timeSyncDownTotal + " ms");
// Cleanup
TestConfigUtil.deleteTestLocalConfigAndData(configA);
TestConfigUtil.deleteTestLocalConfigAndData(configB);
}
use of org.syncany.operations.down.DownOperation in project syncany by syncany.
the class DownCommand method execute.
@Override
public int execute(String[] operationArgs) throws Exception {
DownOperationOptions operationOptions = parseOptions(operationArgs);
DownOperationResult operationResult = new DownOperation(config, operationOptions).execute();
printResults(operationResult);
return 0;
}
use of org.syncany.operations.down.DownOperation in project syncany by syncany.
the class WatchOperation method runSync.
/**
* Runs one iteration of the main synchronization loop, containing a {@link DownOperation},
* an {@link UpOperation} and (if required), a {@link CleanupOperation}.
*/
private void runSync() throws Exception {
if (!syncRunning.get()) {
syncRunning.set(true);
syncRequested.set(false);
logger.log(Level.INFO, "RUNNING SYNC ...");
fireStartEvent();
try {
boolean notifyChanges = false;
// Run down
DownOperationResult downResult = new DownOperation(config, options.getDownOptions()).execute();
if (downResult.getResultCode() == DownResultCode.OK_WITH_REMOTE_CHANGES) {
// TODO [low] Do something?
}
// Run up
UpOperationResult upOperationResult = new UpOperation(config, options.getUpOptions()).execute();
if (upOperationResult.getResultCode() == UpResultCode.OK_CHANGES_UPLOADED && upOperationResult.getChangeSet().hasChanges()) {
upCount.incrementAndGet();
notifyChanges = true;
}
CleanupOperationResult cleanupOperationResult = new CleanupOperation(config, options.getCleanupOptions()).execute();
if (cleanupOperationResult.getResultCode() == CleanupResultCode.OK) {
notifyChanges = true;
}
// Fire change event if up and/or cleanup
if (notifyChanges) {
notifyChanges();
}
} finally {
logger.log(Level.INFO, "SYNC DONE.");
syncRunning.set(false);
fireEndEvent();
}
} else {
// Can't do a log message here, because this bit is called thousand
// of times when file system events occur.
syncRequested.set(true);
}
}
Aggregations