Ejemplo n.º 1
0
        private void SetZooKeeperConfiguration(ZooKeeperConfigurationElement config)
        {
            if (config.Servers.Count == 0)
            {
                throw new ConfigurationErrorsException();
            }

            var sb = new StringBuilder();

            foreach (ZooKeeperServerConfigurationElement server in config.Servers)
            {
                sb.Append(GetIpAddress(server.Host));
                sb.Append(':');
                sb.Append(server.Port);
                sb.Append(',');
            }

            sb.Remove(sb.Length - 1, 1);
            ZooKeeper = new ZooKeeperConfiguration(
                sb.ToString(),
                config.SessionTimeout,
                config.ConnectionTimeout,
                config.SyncTime);
        }
        /// <summary>
        /// Convert Zookeeper string to ZookeeperConfiguration
        /// </summary>
        /// <param name="zookeeperAddress"></param>
        /// <returns></returns>
        public static ZooKeeperConfiguration ToZookeeperConfig(string zookeeperAddress)
        {
            ZooKeeperConfiguration zookeeperConfig = null;
            if (!string.IsNullOrEmpty(zookeeperAddress))
            {
                zookeeperConfig = new ZooKeeperConfiguration();
                zookeeperConfig.ZkConnect = zookeeperAddress;
            }

            return zookeeperConfig;
        }
Ejemplo n.º 3
0
 public ProducerConfiguration(ZooKeeperConfiguration zooKeeperConfig)
     : this()
 {
     this.ZooKeeper        = zooKeeperConfig;
     this.PartitionerClass = DefaultPartitioner;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZooKeeperAwareKafkaClientBase"/> class.
 /// </summary>
 /// <param name="config">The config.</param>
 protected ZooKeeperAwareKafkaClientBase(ZooKeeperConfiguration config)
 {
     this.IsZooKeeperEnabled = config != null && !string.IsNullOrEmpty(config.ZkConnect);
 }
        private void SetZooKeeperConfiguration(ZooKeeperConfigurationElement config)
        {
            if (config.Servers.Count == 0)
            {
                throw new ConfigurationErrorsException();
            }

            var sb = new StringBuilder();
            foreach (ZooKeeperServerConfigurationElement server in config.Servers)
            {
                sb.Append(GetIpAddress(server.Host));
                sb.Append(':');
                sb.Append(server.Port);
                sb.Append(',');
            }

            sb.Remove(sb.Length - 1, 1);
            this.ZooKeeper = new ZooKeeperConfiguration(
                sb.ToString(),
                config.SessionTimeout,
                config.ConnectionTimeout,
                config.SyncTime);
        }