/// <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.NotNull(args, "args");

            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();
        }
Exemple #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.NotNull(args, "args");

            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);
            }
        }
Exemple #3
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.NotNull(args, "args");

            // Notify listeners that ZK session has expired
            OnZKSessionExpired(EventArgs.Empty);

            Logger.InfoFormat("ZK session expired; release old broker partition ownership; re-register consumer {0}", this.consumerIdString);
            this.loadBalancerListener.ResetState();
            this.zkConsumerConnector.RegisterConsumerInZk(this.dirs, this.consumerIdString, this.topicCount);

            Logger.Info("Performing rebalancing. ZK session has previously expired and a new session has been created");
            this.loadBalancerListener.AsyncRebalance();
        }
        /// <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);
        }
Exemple #5
0
 public void HandleSessionCreated(ZooKeeperSessionCreatedEventArgs args)
 {
     Logger.Debug(args + " reach test event handler");
     this.events.Add(args);
 }