public WatcherOptionsForm( Watcher watcher ) { InitializeComponent( ); this.Text = watcher.File.Name; this.watcher = watcher; lblWatchingFile.Text = watcher.File.Name + " options"; LoadFromOptions( watcher.Options ); UpdateState( ); }
/** * @param ensembleProvider the ensemble provider * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use */ public CuratorZookeeperClient(IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, IRetryPolicy retryPolicy) : this(new DefaultZookeeperFactory(), ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false) { }
/** * * @param connectString list of servers to connect to * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use */ public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, IRetryPolicy retryPolicy) : this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false) { }
internal ConnectionState(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher parentWatcher, AtomicReference<TracerDriver> tracer, bool canBeReadOnly) { this.ensembleProvider = ensembleProvider; this.sessionTimeoutMs = sessionTimeoutMs; this.connectionTimeoutMs = connectionTimeoutMs; this.tracer = tracer; if (parentWatcher != null) { parentWatchers.AddLast(parentWatcher); } zooKeeper = new HandleHolder(zookeeperFactory, this, ensembleProvider, sessionTimeoutMs, canBeReadOnly); }
public MainViewModel() { try { App.Current.MainWindow.Closing += MainWindow_Closing; fileHelper = FileHelpers.Instance; fileHelper.MessageRaised += FileHelper_MessageRaised; watcher = Watcher.Instance(this); watcher.MessageRaised += Watcher_MessageRaised; watcher.Run(); } catch { #if DEBUG return; #endif throw new Exception("Could not start watcher"); } }
protected virtual void configure() { if (this.Status != SyncStatus.Init && this.Status != SyncStatus.Suspended) { throw new InvalidOperationException(); } this.remote_timer.Interval = SyncFolderInfo.PollInterval; if (watcher != null) { watcher.Dispose(); } watcher = new Watcher(SyncFolderInfo.LocalPath); watcher.ChangeEvent += OnFileActivity; Logger.Info("Repo " + SyncFolderInfo.DisplayName + " - Set poll interval to " + SyncFolderInfo.PollInterval + "ms"); remote_timer.Interval = SyncFolderInfo.PollInterval; if (this.Status == SyncStatus.Init) { if (this.SyncFolderInfo.IsSuspended) { Status = SyncStatus.Suspended; } else { Status = SyncStatus.Idle; } } }
internal void removeParentWatcher(Watcher watcher) { // TODO: this is workaround to remove element from queue in C# // Java version of queue has remove method ConcurrentQueue<Watcher> newQueue = new ConcurrentQueue<Watcher>(); foreach (Watcher parentWatcher in parentWatchers) { if (parentWatcher != watcher) { newQueue.Enqueue(parentWatcher); } } parentWatchers = newQueue; }
internal void addParentWatcher(Watcher watcher) { parentWatchers.Enqueue(watcher); }
public UpdateResponder() { converter = new MapConverter(); string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string jsondir = Path.Combine(appData, @"Natural Selection 2\Radiance"); Directory.CreateDirectory(jsondir); JsonPath = Path.Combine(jsondir, "level.json"); jsonWatcher = new Watcher(null, OnChangeJson); jsonWatcher.FileToWatch = JsonPath; jsonWatcher.OnChangePath += (string path) => { lock (ThreadLock) { OnEvent(String.Format("Monitoring {0}", path)); } }; levelWatcher = new Watcher(OnCreateLevel, OnChangeLevel); levelWatcher.OnChangePath += (string path) => { lock (ThreadLock) { OnEvent(String.Format("Monitoring {0}", path)); } }; OnErrorDelegate onError = (Exception e) => { lock (ThreadLock) { OnEvent(e.Message); if (Debugger.IsAttached) { throw e; } } }; jsonWatcher.OnError += onError; levelWatcher.OnError += onError; }
/** * @param zookeeperFactory factory for creating {@link ZooKeeper} instances * @param ensembleProvider the ensemble provider * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use * @param canBeReadOnly if true, allow ZooKeeper client to enter * read only mode in case of a network partition. See * {@link ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], boolean)} * for details */ public CuratorZookeeperClient(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, IRetryPolicy retryPolicy, bool canBeReadOnly) { if (ensembleProvider == null) { throw new ArgumentNullException(nameof(ensembleProvider), "ensembleProvider cannot be null"); } if (retryPolicy == null) { throw new ArgumentNullException(nameof(retryPolicy), "retryPolicy cannot be null"); } if (sessionTimeoutMs < connectionTimeoutMs) { log.Warn("session timeout [{0}] is less than connection timeout [{1}]", sessionTimeoutMs, connectionTimeoutMs); } this.connectionTimeoutMs = connectionTimeoutMs; state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly); setRetryPolicy(retryPolicy); }
internal void removeParentWatcher(Watcher watcher) { state.removeParentWatcher(watcher); }
internal void addParentWatcher(Watcher watcher) { state.addParentWatcher(watcher); }
internal virtual void removeParentWatcher(Watcher watcher) { //JAVA TO C# CONVERTER TODO TASK: There is no .NET LinkedList equivalent to the Java 'remove' method: parentWatchers.remove(watcher); }
internal virtual void addParentWatcher(Watcher watcher) { parentWatchers.AddLast(watcher); }
public async Task<int> Execute() { this._tasks = new List<ITask>(); _worker = new Task(Work); var srcPaths = this.Source.Split(';'); var destPaths = this.Destination.Split(';'); for (int i = 0; i < srcPaths.Length && i < destPaths.Length; i++) { Watcher watcher = new Watcher(this, srcPaths[i], destPaths[i]); watcher.Run(); } _worker.Start(); _resetEvent.WaitOne(); return 0; }
public IApplicationWatcher CreateApplicationWatcher (IApplication application) { called++; lastWatcher = new Watcher(); lastWatcher.Application = application; return lastWatcher; }
/// <param name="zookeeperFactory"> factory for creating <seealso cref="ZooKeeper" /> instances </param> /// <param name="ensembleProvider"> the ensemble provider </param> /// <param name="sessionTimeoutMs"> session timeout </param> /// <param name="connectionTimeoutMs"> connection timeout </param> /// <param name="watcher"> default watcher or null </param> /// <param name="retryPolicy"> the retry policy to use </param> /// <param name="canBeReadOnly"> /// if true, allow ZooKeeper client to enter /// read only mode in case of a network partition. See /// <seealso cref="ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], boolean)" /> /// for details /// </param> public CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy, bool canBeReadOnly) { if (sessionTimeoutMs < connectionTimeoutMs) { log.warn(string.Format("session timeout [{0:D}] is less than connection timeout [{1:D}]", sessionTimeoutMs, connectionTimeoutMs)); } retryPolicy = Preconditions.checkNotNull(retryPolicy, "retryPolicy cannot be null"); ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null"); this.connectionTimeoutMs = connectionTimeoutMs; state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly); setRetryPolicy(retryPolicy); }