コード例 #1
0
ファイル: ZooKeeperEventExecutor.cs プロジェクト: lcksy/Dot
 public void Add(ZooKeeperEvent @event)
 {
     if (_shutdown.Value == false)
     {
         try { _eventQueue.TryAdd(@event); }
         catch { }
     }
 }
コード例 #2
0
 private void FireNewSessionEvent()
 {
     foreach (var listener in _stateListeners)
     {
         Action <ZooKeeperEvent> handler = e => listener.OnNewSession();
         var description = string.Format("New session event send to {0}", listener);
         var @event      = new ZooKeeperEvent(description, handler);
         _eventExecutor.Add(@event);
     }
 }
コード例 #3
0
 private void FireStateChangedEvent(KeeperState state)
 {
     foreach (var listener in _stateListeners)
     {
         Action <ZooKeeperEvent> handler = e => listener.OnStateChanged(state);
         var description = string.Format("KeeperState changed to {0}, send to {1}", state, listener);
         var @event      = new ZooKeeperEvent(description, handler);
         _eventExecutor.Add(@event);
     }
 }
コード例 #4
0
        private void FireDataChangedEvent(string path, IEnumerable <IDataListener> listeners)
        {
            var bytes = _connection.Value.GetData(path, true, null);

            foreach (var listener in listeners)
            {
                Action <ZooKeeperEvent> handler = e =>
                {
                    Console.WriteLine(e.Description);
                    listener.OnDataChanged(path, bytes);
                };

                var description = string.Format("data of node {0} changed, send to {1}", path, listener);
                var @event      = new ZooKeeperEvent(description, handler);
                _eventExecutor.Add(@event);
            }
        }
コード例 #5
0
        private void FireChildrenChangedEvent(string dir, IEnumerable <IChildListener> listeners)
        {
            var children = _connection.Value.GetChildren(dir, true).Select(child => dir + "/" + child).ToList();

            foreach (var listener in listeners)
            {
                Action <ZooKeeperEvent> handler = e =>
                {
                    Console.WriteLine(e.Description);
                    listener.OnChildrenChanged(children);
                };

                var description = string.Format("Children of path {0} changed, send to {1}", dir, listener);
                var @event      = new ZooKeeperEvent(description, handler);
                _eventExecutor.Add(@event);
            }
        }