Package org.syncany.operations.watch

Examples of org.syncany.operations.watch.WatchOperationOptions


    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 }));
  }
View Full Code Here


        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();
 
View Full Code Here

  public Thread watchAsThread(final int interval) {
    return new Thread(new Runnable() {
      @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);
View Full Code Here

    return false;
  }
 
  @Override
  public int execute(String[] operationArgs) throws Exception {
    WatchOperationOptions operationOptions = parseOptions(operationArgs);
    client.watch(operationOptions);

    return 0;
  }
View Full Code Here

    return 0;
  }

  @Override
  public WatchOperationOptions parseOptions(String[] operationArgs) throws Exception {
    WatchOperationOptions operationOptions = new WatchOperationOptions();

    OptionParser parser = new OptionParser()
    OptionSpec<Integer> optionInterval = parser.acceptsAll(asList("i", "interval")).withRequiredArg().ofType(Integer.class);
    OptionSpec<Void> optionNoAnnouncements = parser.acceptsAll(asList("N", "no-announcements"));
    OptionSpec<String> optionAnnouncements = parser.acceptsAll(asList("a", "announce")).withRequiredArg();
    OptionSpec<Void> optionNoWatcher = parser.acceptsAll(asList("W", "no-watcher"));
    OptionSpec<Integer> optionSettleDelay = parser.acceptsAll(asList("s", "delay")).withRequiredArg().ofType(Integer.class);
   
    OptionSet options = parser.parse(operationArgs)
   
    // --interval
    if (options.has(optionInterval)) {
      operationOptions.setInterval(options.valueOf(optionInterval)*1000);
    }
   
    // Conflicting options: --no-announcements and --announce=<..>
    if (options.has(optionNoAnnouncements) && options.has(optionAnnouncements)) {
      throw new Exception("Options --no-announcements and --announce in conflict with one another.");
    }
   
    // --no-announcements
    if (options.has(optionNoAnnouncements)) {
      operationOptions.setAnnouncements(false);
    }
   
    // --announce=<host>:<port>
    if (options.has(optionAnnouncements)) {
      operationOptions.setAnnouncements(true);
     
      String announcementsStr = options.valueOf(optionAnnouncements);
      Matcher matcher = ANNOUNCEMENTS_PATTERN.matcher(announcementsStr);
     
      if (!matcher.matches()) {
        throw new Exception("Invalid argument for --announcements, expected pattern: "+ANNOUNCEMENTS_PATTERN.pattern());
      }
     
      String announcementsHost = matcher.group(ANNOUNCEMENTS_PATTERN_GROUP_HOST);
      int announcementsPort = Integer.parseInt(matcher.group(ANNOUNCEMENTS_PATTERN_GROUP_PORT));
     
      operationOptions.setAnnouncementsHost(announcementsHost);
      operationOptions.setAnnouncementsPort(announcementsPort);
    }
   
    // --delay=<sec>
    if (options.has(optionSettleDelay)) {
      operationOptions.setSettleDelay(options.valueOf(optionSettleDelay)*1000);
    }
   
    // --no-watcher
    if (options.has(optionNoWatcher)) {
      operationOptions.setWatcher(false);
    }
   
    return operationOptions;
  }
View Full Code Here

TOP

Related Classes of org.syncany.operations.watch.WatchOperationOptions

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.