Contains ZooKeeper session created event data
Inheritance: ZooKeeperEventArgs
Esempio n. 1
0
        /// <summary>
        /// Called after the ZooKeeper session has expired and a new session has been created.
        /// </summary>
        /// <param name="args">The <see cref="Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperSessionCreatedEventArgs"/> instance containing the event data.</param>
        /// <remarks>
        /// You would have to re-create any ephemeral nodes here.
        /// Explicitly trigger load balancing for this consumer.
        /// </remarks>
        public void HandleSessionCreated(ZooKeeperSessionCreatedEventArgs args)
        {
            Guard.Assert<ArgumentNullException>(() => args != null);

            Logger.InfoFormat(
                CultureInfo.CurrentCulture,
                "ZK expired; release old broker partition ownership; re-register consumer {0}",
                this.consumerIdString);
            this.loadBalancerListener.ResetState();
            this.zkConsumerConnector.RegisterConsumerInZk(this.dirs, this.consumerIdString, this.topicCount);
            this.loadBalancerListener.SyncedRebalance();
        }
Esempio n. 2
0
        /// <summary>
        /// Called after the ZooKeeper session has expired and a new session has been created.
        /// </summary>
        /// <param name="args">The <see cref="Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperSessionCreatedEventArgs"/> instance containing the event data.</param>
        /// <remarks>
        /// We would have to re-create any ephemeral nodes here.
        /// </remarks>
        public void HandleSessionCreated(ZooKeeperSessionCreatedEventArgs args)
        {
            Guard.Assert<ArgumentNullException>(() => args != null);

            this.EnsuresNotDisposed();
            Logger.Debug("ZK expired; release old list of broker partitions for topics ");
            this.Reset();
            this.brokerTopicsListener.ResetState();
            foreach (var topic in this.topicBrokerPartitions.Keys)
            {
                this.zkclient.Subscribe(ZooKeeperClient.DefaultBrokerTopicsPath + "/" + topic, this.brokerTopicsListener);
            }
        }
        /// <summary>
        /// Invokes subscribed handlers for ZooKeeeper session re-creates event
        /// </summary>
        /// <param name="e">
        /// The event data.
        /// </param>
        private void OnSessionCreated(ZooKeeperSessionCreatedEventArgs e)
        {
            var handlers = this.sessionCreatedHandlers;
            if (handlers == null)
            {
                return;
            }

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

            handlers(e);
        }
Esempio n. 4
0
 public void HandleSessionCreated(ZooKeeperSessionCreatedEventArgs args)
 {
     Logger.Debug(args + " reach test event handler");
     this.events.Add(args);
 }
        /// <summary>
        /// Called after the ZooKeeper session has expired and a new session has been created.
        /// </summary>
        /// <param name="args">The <see cref="Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperSessionCreatedEventArgs"/> instance containing the event data.</param>
        /// <remarks>
        /// We would have to re-create any ephemeral nodes here.
        /// </remarks>
        public void HandleSessionCreated(ZooKeeperSessionCreatedEventArgs args)
        {
            Guard.NotNull(args, "args");
            this.resetSlimLock.EnterWriteLock();

            try
            {
                this.EnsuresNotDisposed();
                Logger.Debug("ZK expired; release old list of broker partitions for topics ");
                this.Reset();
                this.brokerTopicsListener.ResetState();
                foreach (var topic in this.topicBrokerPartitions.Keys)
                {
                    this.zkclient.Subscribe(ZooKeeperClient.DefaultBrokerTopicsPath + "/" + topic,
                                            this.brokerTopicsListener);
                }
            }
            finally
            {
                this.resetSlimLock.ExitWriteLock();
            }
        }