@Override public void run() { try { WatchOperationOptions watchOperationOptions = new WatchOperationOptions(); watchOperationOptions.setAnnouncements(false); watchOperationOptions.setWatcher(false); watchOperationOptions.setInterval(interval); watch(watchOperationOptions); } catch (Exception e) { throw new RuntimeException(e); } } }, "watchOperationsThread");
private void startNotificationListener() { logger.log(Level.INFO, "Starting notification listener for " + config.getLocalDir() + " ..."); notificationListener = new NotificationListener(options.getAnnouncementsHost(), options.getAnnouncementsPort(), this); notificationListener.start(); notificationListener.subscribe(notificationChannel); }
@Override public WatchOperationOptions parseOptions(String[] operationArgs) throws Exception { WatchOperationOptions operationOptions = new WatchOperationOptions(); operationOptions.setInterval(options.valueOf(optionInterval)*1000); operationOptions.setAnnouncements(false); operationOptions.setAnnouncements(true); int announcementsPort = Integer.parseInt(matcher.group(ANNOUNCEMENTS_PATTERN_GROUP_PORT)); operationOptions.setAnnouncementsHost(announcementsHost); operationOptions.setAnnouncementsPort(announcementsPort); operationOptions.setSettleDelay(options.valueOf(optionSettleDelay)*1000); operationOptions.setWatcher(false);
public static DaemonConfigTO createAndWriteExampleDaemonConfig(File daemonConfigFile) throws ConfigException { File defaultFolder = new File(System.getProperty("user.home"), UserConfig.DEFAULT_FOLDER); FolderTO defaultFolderTO = new FolderTO(); defaultFolderTO.setPath(defaultFolder.getAbsolutePath()); defaultFolderTO.setWatchOptions(new WatchOperationOptions()); return createAndWriteDaemonConfig(daemonConfigFile, Arrays.asList(new FolderTO[] { defaultFolderTO })); }
watchThread = Thread.currentThread(); if (options.announcementsEnabled()) { startNotificationListener(); if (options.watcherEnabled()) { startRecursiveWatcher(); logger.log(Level.INFO, "Sync done, waiting {0} seconds ...", options.getInterval() / 1000); Thread.sleep(options.getInterval()); logger.log(Level.INFO, String.format("Sync FAILED, waiting %d seconds ...", options.getInterval() / 1000), e); Thread.sleep(options.getInterval()); if (options.announcementsEnabled()) { stopNotificationListener(); if (options.watcherEnabled()) { stopRecursiveWatcher();
DownOperationResult downResult = new DownOperation(config, options.getDownOptions()).execute(); UpOperationResult upOperationResult = new UpOperation(config, options.getUpOptions()).execute(); CleanupOperationResult cleanupOperationResult = new CleanupOperation(config, options.getCleanupOptions()).execute();
private void startWatchOperations(Map<File, FolderTO> newWatchedFolderTOs) throws ConfigException, ServiceAlreadyStartedException { for (Map.Entry<File, FolderTO> folderEntry : newWatchedFolderTOs.entrySet()) { File localDir = folderEntry.getKey(); try { Config watchConfig = ConfigHelper.loadConfig(localDir); if (watchConfig != null) { logger.log(Level.INFO, "- Starting watch operation at " + localDir + " ..."); WatchOperationOptions watchOptions = folderEntry.getValue().getWatchOptions(); if (watchOptions == null) { watchOptions = new WatchOperationOptions(); } WatchRunner watchRunner = new WatchRunner(watchConfig, watchOptions, daemonConfig.getPortTO()); watchRunner.start(); watchOperations.put(localDir, watchRunner); } else { logger.log(Level.INFO, "- CANNOT start watch, because no config found at " + localDir + " ..."); } } catch (Exception e) { logger.log(Level.SEVERE, " + Cannot start watch operation at " + localDir + ". IGNORING.", e); } } }