@Override public int execute(String[] operationArgs) throws Exception { WatchOperationOptions operationOptions = parseOptions(operationArgs); new WatchOperation(config, operationOptions).execute(); return 0; }
public void stop() { if (!stopRequested.get()) { stopRequested.set(true); if (syncRunning.get()) { logger.log(Level.INFO, "Stop requested, but sync process currently running. Waiting max. " + STOP_GRACE_PERIOD + "ms for sync to finish."); scheduleForceKill(); } else { logger.log(Level.INFO, "Stop requested, but sync is NOT running. Immediately stopping thread."); forceKillWatchThread(); } } else { logger.log(Level.INFO, "Stop requested AGAIN, but was requested before. IGNORING."); } }
public boolean isSyncRunning() { return watchOperation.isSyncRunning(); }
if (!watchOperation.isSyncRunning() && !watchOperation.isSyncRequested()) { watchOperation.pause(); watchOperation.resume();
public WatchRunner(Config config, WatchOperationOptions watchOperationOptions, PortTO portTO) throws ConfigException { this.config = config; this.portTO = portTO; this.watchOperation = new WatchOperation(config, watchOperationOptions); this.eventBus = LocalEventBus.getInstance(); this.eventBus.register(this); }
@Override public void run() { try { logger.log(Level.INFO, "STARTING watch at" + config.getLocalDir()); watchOperationResult = null; // Write port to portFile File portFile = config.getPortFile(); portFile.createNewFile(); portFile.deleteOnExit(); new Persister().write(portTO, portFile); // Start operation (blocks!) watchOperationResult = watchOperation.execute(); logger.log(Level.INFO, "STOPPED watch at " + config.getLocalDir()); } catch (Exception e) { logger.log(Level.SEVERE, "ERROR while running watch at " + config.getLocalDir(), e); } } }, "WR/" + config.getLocalDir().getName());
fireStartEvent(); try { boolean notifyChanges = false; notifyChanges(); syncRunning.set(false); fireEndEvent();
public void watch(WatchOperationOptions options) throws Exception { new WatchOperation(config, options).execute(); }