Esempio n. 1
0
        private void RegisterConsumerInZK(ZKGroupDirs dirs, string consumerIdString, TopicCount topicCount)
        {
            Logger.InfoFormat("begin registering consumer {0} in ZK", consumerIdString);
            var timestamp = DateTimeHelper.CurrentTimeMilis();
            var consumerRegistrationInfo = JsonConvert.SerializeObject(new
            {
                version      = 1,
                subscription = topicCount.TopicCountMap,
                pattern      = topicCount.Pattern,
                timestamp
            });

            ZkUtils.CreateEphemeralPathExpectConflictHandleZKBug(
                zkClient,
                dirs.ConsumerRegistryDir + "/" + consumerIdString,
                consumerRegistrationInfo,
                null,
                (consumerZKstring, consumer) => true,
                this.Config.ZooKeeper.ZkSessionTimeoutMs);

            Logger.InfoFormat("end registering consumer {0} in ZK", consumerIdString);
        }