Contains znode children changed event data
상속: ZooKeeperEventArgs
예제 #1
0
        /// <summary>
        /// Invokes subscribed handlers for ZooKeeeper children changes event
        /// </summary>
        /// <param name="e">
        /// The event data.
        /// </param>
        public void OnChildChanged(ZooKeeperChildChangedEventArgs e)
        {
            var handlers = this.childChanged;

            if (handlers == null)
            {
                return;
            }

            foreach (var handler in handlers.GetInvocationList())
            {
                Logger.Debug(e + " sent to " + handler.Target);
            }

            handlers(e);
        }
        /// <summary>
        /// Invokes subscribed handlers for ZooKeeeper children changes event
        /// </summary>
        /// <param name="e">
        /// The event data.
        /// </param>
        public void OnChildChanged(ZooKeeperChildChangedEventArgs e)
        {
            var handlers = this.childChanged;
            if (handlers == null)
            {
                return;
            }

            foreach (var handler in handlers.GetInvocationList())
            {
                Logger.Debug(e + " sent to " + handler.Target);
            }

            handlers(e);
        }
        /// <summary>
        /// Invokes subscribed handlers for ZooKeeeper child changes event
        /// </summary>
        /// <param name="e">
        /// The event data.
        /// </param>
        private void OnChildChanged(ZooKeeperChildChangedEventArgs e)
        {
            ChildChangedEventItem handlers;
            this.childChangedHandlers.TryGetValue(e.Path, out handlers);
            if (handlers == null || handlers.Count == 0)
            {
                return;
            }

            this.Exists(e.Path);
            try
            {
                IEnumerable<string> children = this.GetChildren(e.Path);
                e.Children = children;
            }
            catch (KeeperException ex)// KeeperException.NoNodeException)
            {
                if (ex.ErrorCode == KeeperException.Code.NONODE)
                {

                }
                else
                    throw;
            }

            handlers.OnChildChanged(e);
        }
예제 #4
0
 public void HandleChildChange(ZooKeeperChildChangedEventArgs args)
 {
     Logger.Debug(args + " reach test event handler");
     this.events.Add(args);
 }
예제 #5
0
        /// <summary>
        /// Invokes subscribed handlers for ZooKeeeper child changes event
        /// </summary>
        /// <param name="e">
        /// The event data.
        /// </param>
        private void OnChildChanged(ZooKeeperChildChangedEventArgs e)
        {
            ChildChangedEventItem handlers;
            this.childChangedHandlers.TryGetValue(e.Path, out handlers);
            if (handlers == null || handlers.Count == 0)
            {
                return;
            }

            this.Exists(e.Path);
            try
            {
                IList<string> children = this.GetChildren(e.Path);
                e.Children = children;
            }
            catch (KeeperException.NoNodeException)
            {
            }

            handlers.OnChildChanged(e);
        }
예제 #6
0
        /// <summary>
        /// Called when the children of the given path changed
        /// </summary>
        /// <param name="args">The <see cref="Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperChildChangedEventArgs"/> instance containing the event data
        /// as parent path and children (null if parent was deleted).
        /// </param>
        /// <remarks> 
        /// http://zookeeper.wiki.sourceforge.net/ZooKeeperWatches
        /// </remarks>
        public void HandleChildChange(ZooKeeperChildChangedEventArgs args)
        {
            Guard.NotNull(args, "args");
            Guard.NotNullNorEmpty(args.Path, "args.Path");
            Guard.NotNull(args.Children, "args.Children");

            SyncedRebalance();
        }
예제 #7
0
        /// <summary>
        /// Called when the children of the given path changed
        /// </summary>
        /// <param name="e">The <see cref="Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperChildChangedEventArgs"/> instance containing the event data
        /// as parent path and children (null if parent was deleted).
        /// </param>
        public void HandleChildChange(ZooKeeperChildChangedEventArgs e)
        {
            Guard.Assert<ArgumentNullException>(() => e != null);
            Guard.Assert<ArgumentException>(() => !string.IsNullOrEmpty(e.Path));
            Guard.Assert<ArgumentNullException>(() => e.Children != null);

            lock (this.syncLock)
            {
                try
                {
                    string path = e.Path;
                    IList<string> childs = e.Children;
                    Logger.Debug("Watcher fired for path: " + path);
                    switch (path)
                    {
                        case ZooKeeperClient.DefaultBrokerTopicsPath:
                            List<string> oldTopics = this.oldBrokerTopicsPartitionsMap.Keys.ToList();
                            List<string> newTopics = childs.Except(oldTopics).ToList();
                            Logger.Debug("List of topics was changed at " + e.Path);
                            Logger.Debug("Current topics -> " + e.Children.ToMultiString(","));
                            Logger.Debug("Old list of topics -> " + oldTopics.ToMultiString(","));
                            Logger.Debug("List of newly registered topics -> " + newTopics.ToMultiString(","));
                            foreach (var newTopic in newTopics)
                            {
                                string brokerTopicPath = ZooKeeperClient.DefaultBrokerTopicsPath + "/" + newTopic;
                                IList<string> brokerList = this.zkclient.GetChildrenParentMayNotExist(brokerTopicPath);
                                this.ProcessNewBrokerInExistingTopic(newTopic, brokerList);
                                this.zkclient.Subscribe(ZooKeeperClient.DefaultBrokerTopicsPath + "/" + newTopic, this);
                            }

                            break;
                        case ZooKeeperClient.DefaultBrokerIdsPath:
                            Logger.Debug("List of brokers changed in the Kafka cluster " + e.Path);
                            Logger.Debug("Currently registered list of brokers -> " + e.Children.ToMultiString(","));
                            this.ProcessBrokerChange(path, childs);
                            break;
                        default:
                            string[] parts = path.Split('/');
                            string topic = parts.Last();
                            if (parts.Length == 4 && parts[2] == "topics" && childs != null)
                            {
                                Logger.Debug("List of brokers changed at " + path);
                                Logger.Debug(
                                    "Currently registered list of brokers for topic " + topic + " -> " +
                                    childs.ToMultiString(","));
                                this.ProcessNewBrokerInExistingTopic(topic, childs);
                            }

                            break;
                    }

                    this.oldBrokerTopicsPartitionsMap = this.actualBrokerTopicsPartitionsMap;
                    this.oldBrokerIdMap = this.actualBrokerIdMap;
                }
                catch (Exception exc)
                {
                    Logger.Debug("Error while handling " + e, exc);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Called when the children of the given path changed
        /// </summary>
        /// <param name="args">The <see cref="Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperChildChangedEventArgs"/> instance containing the event data
        /// as parent path and children (null if parent was deleted).
        /// </param>
        /// <remarks> 
        /// http://zookeeper.wiki.sourceforge.net/ZooKeeperWatches
        /// </remarks>
        public void HandleChildChange(ZooKeeperChildChangedEventArgs args)
        {
            Guard.Assert<ArgumentNullException>(() => args != null);
            Guard.Assert<ArgumentException>(() => !string.IsNullOrEmpty(args.Path));
            Guard.Assert<ArgumentNullException>(() => args.Children != null);

            SyncedRebalance();
        }