/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="couchbaseClientSection"></param> public ClientConfiguration(CouchbaseClientSection couchbaseClientSection) { //For operation timing Timer = TimingFactory.GetTimer(Log); UseSsl = couchbaseClientSection.UseSsl; SslPort = couchbaseClientSection.SslPort; ApiPort = couchbaseClientSection.ApiPort; DirectPort = couchbaseClientSection.DirectPort; MgmtPort = couchbaseClientSection.MgmtPort; HttpsMgmtPort = couchbaseClientSection.HttpsMgmtPort; HttpsApiPort = couchbaseClientSection.HttpsApiPort; ObserveInterval = couchbaseClientSection.ObserveInterval; ObserveTimeout = couchbaseClientSection.ObserveTimeout; MaxViewRetries = couchbaseClientSection.MaxViewRetries; ViewHardTimeout = couchbaseClientSection.ViewHardTimeout; SerializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; DeserializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; EnableConfigHeartBeat = couchbaseClientSection.EnableConfigHeartBeat; HeartbeatConfigInterval = couchbaseClientSection.HeartbeatConfigInterval; ViewRequestTimeout = couchbaseClientSection.ViewRequestTimeout; Expect100Continue = couchbaseClientSection.Expect100Continue; EnableOperationTiming = couchbaseClientSection.EnableOperationTiming; PoolConfiguration = new PoolConfiguration(this); foreach (var server in couchbaseClientSection.Servers) { Servers.Add(((UriElement)server).Uri); _serversChanged = true; } BucketConfigs = new Dictionary <string, BucketConfiguration>(); foreach (var bucketElement in couchbaseClientSection.Buckets) { var bucket = (BucketElement)bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, ObserveTimeout = bucket.ObserveTimeout, PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, ClientConfiguration = this } }; BucketConfigs.Add(bucket.Name, bucketConfiguration); } }
// ReSharper disable once InconsistentNaming public static string GetN1QLBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(N1QLUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.N1QLSsl : adapter.N1QL); return uriAsString; }
public void When_UseSsl_True_N1QL_Uri_Contains_Https() { var serverConfigJson = ResourceHelper.ReadResource("Data\\Configuration\\nodesext-with-json-and-kv.json"); var serverConfig = JsonConvert.DeserializeObject<BucketConfig>(serverConfigJson); var clientConfig = new BucketConfiguration { UseSsl = true }; var expected = new Uri("https://192.168.77.102:18093/query"); var actual = UrlUtil.GetN1QLBaseUri(serverConfig.GetNodes().First(x => x.Hostname.Equals("192.168.77.102")), clientConfig); Assert.AreEqual(expected, actual); }
public void When_NodeAdapter_And_UseSsl_Is_True_IPEndPoint_Uses_Port_11210() { var serverConfigJson = File.ReadAllText("Data\\Configuration\\config-with-nodes-ext.json"); var serverConfig = JsonConvert.DeserializeObject<BucketConfig>(serverConfigJson); var clientConfig = new BucketConfiguration { UseSsl = false }; const string expected = "192.168.56.102:11210"; var actual = IPEndPointExtensions.GetEndPoint(serverConfig.GetNodes()[0], clientConfig, serverConfig); Assert.AreEqual(expected, actual.ToString()); }
public void When_UseSsl_True_View_Uri_Contains_Http() { var serverConfigJson = File.ReadAllText("Data\\Configuration\\nodesext-with-json-and-kv.json"); var serverConfig = JsonConvert.DeserializeObject<BucketConfig>(serverConfigJson); var clientConfig = new BucketConfiguration { UseSsl = false }; var expected = new Uri("http://192.168.77.102:8092/default/"); var actual = UrlUtil.GetViewBaseUri(serverConfig.GetNodes().First(x => x.Hostname.Equals("192.168.77.102")), clientConfig); Assert.AreEqual(expected, actual); }
public static string GetSearchBaseUri(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(BaseUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.FtsSsl : adapter.Fts); return uriAsString; }
public void When_Node_And_UseSsl_Is_True_IPEndPoint_Uses_Port_11207() { var serverConfigJson = ResourceHelper.ReadResource("Data\\Configuration\\config-with-nodes-ext.json"); var serverConfig = JsonConvert.DeserializeObject<BucketConfig>(serverConfigJson); var clientConfig = new BucketConfiguration { UseSsl = true }; const string expected = "192.168.56.101:11207"; var actual = IPEndPointExtensions.GetEndPoint(serverConfig.Nodes[0], clientConfig, serverConfig); Assert.AreEqual(expected, actual.ToString()); }
public static string GetViewBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(ViewUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.ViewsSsl : adapter.Views, config.BucketName); return uriAsString; }
public static IPEndPoint GetEndPoint(NodeExt nodeExt, BucketConfiguration bucketConfig, IBucketConfig serverConfig) { var address = nodeExt.Hostname.Split(':').First(); IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { var uri = new Uri(String.Format("http://{0}", address)); ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses); if (ipAddress == null) { throw new ArgumentException("ipAddress"); } } var port = bucketConfig.UseSsl ? nodeExt.Services.KvSSL : nodeExt.Services.KV; return new IPEndPoint(ipAddress, port); }
public static IPEndPoint GetEndPoint(INodeAdapter adapter, BucketConfiguration clientConfig, IBucketConfig server) { var address = adapter.Hostname.Split(':').First(); IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { var uri = new Uri(String.Format("http://{0}", address)); ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses); if (ipAddress == null) { throw new ArgumentException("ipAddress"); } } var port = clientConfig.UseSsl ? adapter.KeyValueSsl : adapter.KeyValue; return new IPEndPoint(ipAddress, port); }
public static IPEndPoint GetEndPoint(Node node, BucketConfiguration clientConfig, IBucketConfig serverConfig) { var address = node.Hostname.Split(':').First(); IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { var uri = new Uri(String.Format("http://{0}", address)); ipAddress = uri.GetIpAddress(); if (ipAddress == null) { throw new ArgumentException("ipAddress"); } } var port = clientConfig.UseSsl ? node.Ports.SslDirect : node.Ports.Direct; return new IPEndPoint(ipAddress, port); }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="couchbaseClientSection"></param> internal ClientConfiguration(CouchbaseClientSection couchbaseClientSection) { UseSsl = couchbaseClientSection.UseSsl; SslPort = couchbaseClientSection.SslPort; ApiPort = couchbaseClientSection.ApiPort; DirectPort = couchbaseClientSection.DirectPort; MgmtPort = couchbaseClientSection.MgmtPort; HttpsMgmtPort = couchbaseClientSection.HttpsMgmtPort; HttpsApiPort = couchbaseClientSection.HttpsApiPort; ObserveInterval = couchbaseClientSection.ObserveInterval; ObserveTimeout = couchbaseClientSection.ObserveTimeout; MaxViewRetries = couchbaseClientSection.MaxViewRetries; ViewHardTimeout = couchbaseClientSection.ViewHardTimeout; SerializationContractResolver = new CamelCasePropertyNamesContractResolver(); DeserializationContractResolver = new CamelCasePropertyNamesContractResolver(); EnableConfigHeartBeat = couchbaseClientSection.EnableConfigHeartBeat; HeartbeatConfigInterval = couchbaseClientSection.HeartbeatConfigInterval; foreach (var server in couchbaseClientSection.Servers) { Servers.Add(((UriElement)server).Uri); _serversChanged = true; } foreach (var bucketElement in couchbaseClientSection.Buckets) { var bucket = (BucketElement)bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, ObserveTimeout = bucket.ObserveTimeout, PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, } }; BucketConfigs = new Dictionary <string, BucketConfiguration> { { bucket.Name, bucketConfiguration } }; } }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="couchbaseClientSection"></param> internal ClientConfiguration(CouchbaseClientSection couchbaseClientSection) { UseSsl = couchbaseClientSection.UseSsl; SslPort = couchbaseClientSection.SslPort; ApiPort = couchbaseClientSection.ApiPort; DirectPort = couchbaseClientSection.DirectPort; MgmtPort = couchbaseClientSection.MgmtPort; HttpsMgmtPort = couchbaseClientSection.HttpsMgmtPort; HttpsApiPort = couchbaseClientSection.HttpsApiPort; Servers = new List <Uri>(); foreach (var server in couchbaseClientSection.Servers) { Servers.Add(((UriElement)server).Uri); } foreach (var bucketElement in couchbaseClientSection.Buckets) { var bucket = (BucketElement)bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, } }; BucketConfigs = new Dictionary <string, BucketConfiguration> { { bucket.Name, bucketConfiguration } }; } }
/// <summary> /// Gets an <see cref="BucketConfiguration"/> from the <see cref="ClientConfiguration"/>. If one doesn't exist /// for a given bucket, a new one will be created and added to the configuration. /// </summary> /// <param name="bucketName">The <see cref="IBucket.Name"/> to use for the lookup.</param> /// <returns>An <see cref="BucketConfiguration"/> instance.</returns> protected virtual BucketConfiguration GetOrCreateConfiguration(string bucketName) { try { ConfigLock.EnterWriteLock(); BucketConfiguration bucketConfiguration = null; if (ClientConfig.BucketConfigs.ContainsKey(bucketName)) { bucketConfiguration = ClientConfig.BucketConfigs[bucketName]; } if (bucketConfiguration != null) return bucketConfiguration; var defaultBucket = ClientConfig.BucketConfigs.FirstOrDefault(); if (defaultBucket.Value == null) { bucketConfiguration = new BucketConfiguration { BucketName = bucketName, PoolConfiguration = ClientConfig.PoolConfiguration, Servers = ClientConfig.Servers, UseSsl = ClientConfig.UseSsl }; } else { var defaultConfig = defaultBucket.Value; bucketConfiguration = new BucketConfiguration { BucketName = bucketName, PoolConfiguration = defaultConfig.PoolConfiguration, Servers = defaultConfig.Servers, Port = defaultConfig.Port, Username = defaultConfig.Username, Password = defaultConfig.Password, UseSsl = defaultConfig.UseSsl }; } ClientConfig.BucketConfigs.Add(bucketConfiguration.BucketName, bucketConfiguration); return bucketConfiguration; } finally { ConfigLock.ExitWriteLock(); } }
public static Uri GetViewBaseUri(INodeAdapter adapter, BucketConfiguration config) { return new Uri(GetViewBaseUriAsString(adapter, config)); }
protected void CreateCouchBaseDBClientConfiguration(Config config) { if(config.GetBoolean("UseClusterHelper")) { BucketName = config.GetString("BucketName"); CBClientConfiguration = ClusterHelper.GetBucket(BucketName).Cluster.Configuration; UseClusterHelper = true; } else { CBClientConfiguration = new ClientConfiguration(); // Reset the serializers and deserializers so that JSON is stored as PascalCase instead of camelCase CBClientConfiguration.Serializer = () => new DefaultSerializer(new JsonSerializerSettings(), new JsonSerializerSettings()); CBClientConfiguration.Servers.RemoveAt(0); //Get the URI's from the HOCON config try { if (config.GetStringList("ServersURI").Count > 0) { List<Uri> uris = new List<Uri>(); foreach (string s in config.GetStringList("ServersURI")) { CBClientConfiguration.Servers.Add(new Uri(s)); } } } catch (Exception ex) { throw new Exception("Invalid URI specified in HOCON configuration", ex); } // Use SSL? CBClientConfiguration.UseSsl = config.GetBoolean("UseSSL"); // This will not be needed since we are not creating a bucket on the fly. //AdminPassword = config.GetString("AdminPassword"); //AdminUserName = config.GetString("AdminUserName"); // Get the bucket(s) configuration Dictionary<string, BucketConfiguration> BucketConfigs = new Dictionary<string, BucketConfiguration>(); BucketConfiguration newBC = new BucketConfiguration(); newBC.UseSsl = config.GetBoolean("BucketUseSSL"); newBC.Password = config.GetString("Password"); newBC.DefaultOperationLifespan = (uint)config.GetInt("DefaultOperationLifespan"); BucketName = config.GetString("BucketName"); newBC.BucketName = BucketName; newBC.PoolConfiguration.MinSize = config.GetInt("PoolConfiguration.MinSize"); newBC.PoolConfiguration.MaxSize = config.GetInt("PoolConfiguration.MaxSize"); // Create the bucket config specified in the HOCON BucketConfigs.Add(newBC.BucketName, newBC); CBClientConfiguration.BucketConfigs = BucketConfigs; } }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="definition"></param> public ClientConfiguration(ICouchbaseClientDefinition definition, ILoggerFactory loggerFactory) { _loggerFactory = loggerFactory; Log = _loggerFactory.CreateLogger<ClientConfiguration>(); Timer = TimingFactory.GetTimer(_loggerFactory); NodeAvailableCheckInterval = definition.NodeAvailableCheckInterval; UseSsl = definition.UseSsl; SslPort = definition.SslPort; ApiPort = definition.ApiPort; DirectPort = definition.DirectPort; MgmtPort = definition.MgmtPort; HttpsMgmtPort = definition.HttpsMgmtPort; HttpsApiPort = definition.HttpsApiPort; ObserveInterval = definition.ObserveInterval; ObserveTimeout = definition.ObserveTimeout; MaxViewRetries = definition.MaxViewRetries; ViewHardTimeout = definition.ViewHardTimeout; SerializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; DeserializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; EnableConfigHeartBeat = definition.EnableConfigHeartBeat; HeartbeatConfigInterval = definition.HeartbeatConfigInterval; ViewRequestTimeout = definition.ViewRequestTimeout; Expect100Continue = definition.Expect100Continue; DefaultConnectionLimit = definition.DefaultConnectionLimit; MaxServicePointIdleTime = definition.MaxServicePointIdleTime; EnableOperationTiming = definition.EnableOperationTiming; DefaultOperationLifespan = definition.OperationLifespan; QueryRequestTimeout = definition.QueryRequestTimeout; SearchRequestTimeout = definition.SearchRequestTimeout; IOErrorCheckInterval = definition.IOErrorCheckInterval; IOErrorThreshold = definition.IOErrorThreshold; //transcoders, converters, and serializers...o mai. Serializer = definition.Serializer != null ? SerializerFactory.GetSerializer(definition.Serializer) : SerializerFactory.GetSerializer(); Converter = definition.Converter != null ? ConverterFactory.GetConverter(definition.Converter) : ConverterFactory.GetConverter(); Transcoder = definition.Transcoder != null ? TranscoderFactory.GetTranscoder(this, definition.Transcoder) : TranscoderFactory.GetTranscoder(this); IOServiceCreator = definition.IOService != null ? IOServiceFactory.GetFactory(definition.IOService) : IOServiceFactory.GetFactory(); //to enable tcp keep-alives EnableTcpKeepAlives = definition.EnableTcpKeepAlives; TcpKeepAliveInterval = definition.TcpKeepAliveInterval; TcpKeepAliveTime = definition.TcpKeepAliveTime; var keepAlivesChanged = EnableTcpKeepAlives != true || TcpKeepAliveInterval != 1000 || TcpKeepAliveTime != 2*60*60*1000; //The default sasl mechanism creator CreateSaslMechanism = SaslFactory.GetFactory(_loggerFactory); //NOTE: this is a global setting and applies to all instances IgnoreRemoteCertificateNameMismatch = definition.IgnoreRemoteCertificateNameMismatch; UseInterNetworkV6Addresses = definition.UseInterNetworkV6Addresses; foreach (var server in definition.Servers ?? new[] { Defaults.Server }) { Servers.Add(server); _serversChanged = true; } if (definition.ConnectionPool != null) { ConnectionPoolCreator = definition.ConnectionPool.Type != null ? ConnectionPoolFactory.GetFactory(definition.ConnectionPool.Type) : ConnectionPoolFactory.GetFactory(_loggerFactory); PoolConfiguration = new PoolConfiguration { MaxSize = definition.ConnectionPool.MaxSize, MinSize = definition.ConnectionPool.MinSize, WaitTimeout = definition.ConnectionPool.WaitTimeout, ShutdownTimeout = definition.ConnectionPool.ShutdownTimeout, UseSsl = UseSsl ? UseSsl : definition.ConnectionPool.UseSsl, BufferSize = definition.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize*p.BufferSize, p.BufferSize, _loggerFactory), ConnectTimeout = definition.ConnectionPool.ConnectTimeout, SendTimeout = definition.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : definition.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : definition.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : definition.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = definition.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = definition.ConnectionPool.MaxCloseAttempts, ClientConfiguration = this }; } else { ConnectionPoolCreator = ConnectionPoolFactory.GetFactory(_loggerFactory); PoolConfiguration = new PoolConfiguration(_loggerFactory, this); } BucketConfigs = new Dictionary<string, BucketConfiguration>(); if (definition.Buckets != null) { foreach (var bucket in definition.Buckets) { var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, DefaultOperationLifespan = bucket.OperationLifespan ?? (uint) DefaultOperationLifespan, ObserveTimeout = bucket.ObserveTimeout, UseEnhancedDurability = bucket.UseEnhancedDurability }; //By skipping the bucket specific connection pool settings we allow inheritance from clien-wide connection pool settings. if (bucket.ConnectionPool != null) { bucketConfiguration.PoolConfiguration = new PoolConfiguration { Log = Log, MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, BufferSize = bucket.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize*p.BufferSize, p.BufferSize, _loggerFactory), ConnectTimeout = bucket.ConnectionPool.ConnectTimeout, SendTimeout = bucket.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : bucket.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : bucket.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : bucket.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = bucket.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = bucket.ConnectionPool.MaxCloseAttempts, UseEnhancedDurability = bucket.UseEnhancedDurability, ClientConfiguration = this }; } else { bucketConfiguration.PoolConfiguration = PoolConfiguration; bucketConfiguration.PoolConfiguration.UseSsl = bucketConfiguration.UseSsl; bucketConfiguration.PoolConfiguration.UseEnhancedDurability = bucketConfiguration.UseEnhancedDurability; } BucketConfigs.Add(bucket.Name, bucketConfiguration); } } //Set back to default _operationLifespanChanged = false; _poolConfigurationChanged = false; }
public static FailureCountingUri GetFailureCountinSearchBaseUri(INodeAdapter adapter, BucketConfiguration config) { return new FailureCountingUri(GetSearchBaseUri(adapter, config)); }
public static FailureCountingUri GetFailureCountingBaseUri(INodeAdapter adapter, BucketConfiguration config) { return new FailureCountingUri(GetN1QLBaseUriAsString(adapter, config)); }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="definition"></param> public ClientConfiguration(ICouchbaseClientDefinition definition) { Timer = TimingFactory.GetTimer(); UseConnectionPooling = definition.UseConnectionPooling; EnableDeadServiceUriPing = definition.EnableDeadServiceUriPing; NodeAvailableCheckInterval = definition.NodeAvailableCheckInterval; UseSsl = definition.UseSsl; SslPort = definition.SslPort; ApiPort = definition.ApiPort; DirectPort = definition.DirectPort; MgmtPort = definition.MgmtPort; HttpsMgmtPort = definition.HttpsMgmtPort; HttpsApiPort = definition.HttpsApiPort; ObserveInterval = definition.ObserveInterval; ObserveTimeout = definition.ObserveTimeout; MaxViewRetries = definition.MaxViewRetries; #pragma warning disable 618 ViewHardTimeout = definition.ViewHardTimeout; SerializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; DeserializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; #pragma warning restore 618 EnableConfigHeartBeat = definition.EnableConfigHeartBeat; HeartbeatConfigInterval = definition.HeartbeatConfigInterval; ViewRequestTimeout = definition.ViewRequestTimeout; Expect100Continue = definition.Expect100Continue; DefaultConnectionLimit = definition.DefaultConnectionLimit; MaxServicePointIdleTime = definition.MaxServicePointIdleTime; EnableOperationTiming = definition.EnableOperationTiming; DefaultOperationLifespan = definition.OperationLifespan; QueryFailedThreshold = definition.QueryFailedThreshold; QueryRequestTimeout = definition.QueryRequestTimeout; EnableQueryTiming = definition.EnableQueryTiming; SearchRequestTimeout = definition.SearchRequestTimeout; VBucketRetrySleepTime = definition.VBucketRetrySleepTime; IOErrorCheckInterval = definition.IOErrorCheckInterval; IOErrorThreshold = definition.IOErrorThreshold; //transcoders, converters, and serializers...o mai. Serializer = definition.Serializer != null ? SerializerFactory.GetSerializer(definition.Serializer) : SerializerFactory.GetSerializer(); Converter = definition.Converter != null ? ConverterFactory.GetConverter(definition.Converter) : ConverterFactory.GetConverter(); Transcoder = definition.Transcoder != null ? TranscoderFactory.GetTranscoder(this, definition.Transcoder) : TranscoderFactory.GetTranscoder(this); IOServiceCreator = definition.IOService != null ? IOServiceFactory.GetFactory(definition.IOService) : IOServiceFactory.GetFactory(this); #if NETSTANDARD //TODO not implemented for json configs...yet, so default LoggerFactory = new LoggerFactory(); #endif //to enable tcp keep-alives EnableTcpKeepAlives = definition.EnableTcpKeepAlives; TcpKeepAliveInterval = definition.TcpKeepAliveInterval; TcpKeepAliveTime = definition.TcpKeepAliveTime; var keepAlivesChanged = EnableTcpKeepAlives != true || TcpKeepAliveInterval != 1000 || TcpKeepAliveTime != 2 * 60 * 60 * 1000; //The default sasl mechanism creator CreateSaslMechanism = SaslFactory.GetFactory(); //NOTE: this is a global setting and applies to all instances IgnoreRemoteCertificateNameMismatch = definition.IgnoreRemoteCertificateNameMismatch; UseInterNetworkV6Addresses = definition.UseInterNetworkV6Addresses; List <Uri> servers; if (!string.IsNullOrEmpty(definition.ServerResolverType)) { servers = ServerResolverUtil.GetServers(definition.ServerResolverType); } else if (definition.Servers != null && definition.Servers.Any()) { servers = definition.Servers.ToList(); } else { servers = new List <Uri> { Defaults.Server }; } Servers = servers; _serversChanged = true; if (definition.ConnectionPool != null) { ConnectionPoolCreator = definition.ConnectionPool.Type != null ? ConnectionPoolFactory.GetFactory(definition.ConnectionPool.Type) : ConnectionPoolFactory.GetFactory(); PoolConfiguration = new PoolConfiguration { MaxSize = definition.ConnectionPool.MaxSize, MinSize = definition.ConnectionPool.MinSize, WaitTimeout = definition.ConnectionPool.WaitTimeout, ShutdownTimeout = definition.ConnectionPool.ShutdownTimeout, UseSsl = UseSsl ? UseSsl : definition.ConnectionPool.UseSsl, BufferSize = definition.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize), ConnectTimeout = definition.ConnectionPool.ConnectTimeout, SendTimeout = definition.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : definition.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : definition.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : definition.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = definition.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = definition.ConnectionPool.MaxCloseAttempts, ClientConfiguration = this }; } else { ConnectionPoolCreator = ConnectionPoolFactory.GetFactory(); PoolConfiguration = new PoolConfiguration(this); } BucketConfigs = new Dictionary <string, BucketConfiguration>(); if (definition.Buckets != null) { foreach (var bucket in definition.Buckets) { var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, DefaultOperationLifespan = bucket.OperationLifespan ?? (uint)DefaultOperationLifespan, ObserveTimeout = bucket.ObserveTimeout, UseEnhancedDurability = bucket.UseEnhancedDurability }; //By skipping the bucket specific connection pool settings we allow inheritance from clien-wide connection pool settings. if (bucket.ConnectionPool != null) { bucketConfiguration.PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, BufferSize = bucket.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize), ConnectTimeout = bucket.ConnectionPool.ConnectTimeout, SendTimeout = bucket.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : bucket.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : bucket.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : bucket.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = bucket.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = bucket.ConnectionPool.MaxCloseAttempts, UseEnhancedDurability = bucket.UseEnhancedDurability, ClientConfiguration = this }; } else { bucketConfiguration.PoolConfiguration = PoolConfiguration; bucketConfiguration.PoolConfiguration.UseSsl = bucketConfiguration.UseSsl; bucketConfiguration.PoolConfiguration.UseEnhancedDurability = bucketConfiguration.UseEnhancedDurability; } BucketConfigs.Add(bucket.Name, bucketConfiguration); } } //Set back to default _operationLifespanChanged = false; _poolConfigurationChanged = false; }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="section"></param> public ClientConfiguration(CouchbaseClientSection section) { Timer = TimingFactory.GetTimer(Log); NodeAvailableCheckInterval = section.NodeAvailableCheckInterval; UseSsl = section.UseSsl; SslPort = section.SslPort; ApiPort = section.ApiPort; DirectPort = section.DirectPort; MgmtPort = section.MgmtPort; HttpsMgmtPort = section.HttpsMgmtPort; HttpsApiPort = section.HttpsApiPort; ObserveInterval = section.ObserveInterval; ObserveTimeout = section.ObserveTimeout; MaxViewRetries = section.MaxViewRetries; ViewHardTimeout = section.ViewHardTimeout; SerializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; DeserializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; EnableConfigHeartBeat = section.EnableConfigHeartBeat; HeartbeatConfigInterval = section.HeartbeatConfigInterval; ViewRequestTimeout = section.ViewRequestTimeout; Expect100Continue = section.Expect100Continue; DefaultConnectionLimit = section.DefaultConnectionLimit; MaxServicePointIdleTime = section.MaxServicePointIdleTime; EnableOperationTiming = section.EnableOperationTiming; DefaultOperationLifespan = section.OperationLifespan; QueryRequestTimeout = section.QueryRequestTimeout; IOErrorCheckInterval = section.IOErrorCheckInterval; IOErrorThreshold = section.IOErrorThreshold; //transcoders, converters, and serializers...o mai. Serializer = SerializerFactory.GetSerializer(this, section.Serializer); Converter = ConverterFactory.GetConverter(section.Converter); Transcoder = TranscoderFactory.GetTranscoder(this, section.Transcoder); //to enable tcp keep-alives EnableTcpKeepAlives = section.EnableTcpKeepAlives; TcpKeepAliveInterval = section.TcpKeepAliveInterval; TcpKeepAliveTime = section.TcpKeepAliveTime; var keepAlivesChanged = EnableTcpKeepAlives != true || TcpKeepAliveInterval != 1000 || TcpKeepAliveTime != 2*60*60*1000; //the default ioservice - this should be refactored to come from the configsection IOServiceCreator = IOServiceFactory.GetFactory(section.IOService); //the default connection pool creator ConnectionPoolCreator = ConnectionPoolFactory.GetFactory(section.ConnectionPool); //The default sasl mechanism creator CreateSaslMechanism = SaslFactory.GetFactory(); foreach (var server in section.Servers) { Servers.Add(((UriElement)server).Uri); _serversChanged = true; } PoolConfiguration = new PoolConfiguration { MaxSize = section.ConnectionPool.MaxSize, MinSize = section.ConnectionPool.MinSize, WaitTimeout = section.ConnectionPool.WaitTimeout, ShutdownTimeout = section.ConnectionPool.ShutdownTimeout, UseSsl = UseSsl ? UseSsl : section.ConnectionPool.UseSsl, BufferSize = section.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize), ConnectTimeout = section.ConnectionPool.ConnectTimeout, SendTimeout = section.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : section.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : section.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : section.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = section.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = section.ConnectionPool.MaxCloseAttempts, ClientConfiguration = this }; BucketConfigs = new Dictionary<string, BucketConfiguration>(); foreach (var bucketElement in section.Buckets) { var bucket = (BucketElement)bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, DefaultOperationLifespan = bucket.OperationLifespan ??(uint) DefaultOperationLifespan, ObserveTimeout = bucket.ObserveTimeout, UseEnhancedDurability = bucket.UseEnhancedDurability }; //Configuration properties (including elements) can not be null, but we can check if it was originally presnt in xml and skip it. //By skipping the bucket specific connection pool settings we allow inheritance from clien-wide connection pool settings. if (bucket.ConnectionPool.ElementInformation.IsPresent) { bucketConfiguration.PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, BufferSize = bucket.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize*p.BufferSize, p.BufferSize), ConnectTimeout = bucket.ConnectionPool.ConnectTimeout, SendTimeout = bucket.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : bucket.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : bucket.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : bucket.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = bucket.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = bucket.ConnectionPool.MaxCloseAttempts, UseEnhancedDurability = bucket.UseEnhancedDurability, ClientConfiguration = this }; } else { bucketConfiguration.PoolConfiguration = PoolConfiguration; } BucketConfigs.Add(bucket.Name, bucketConfiguration); } //Set back to default _operationLifespanChanged = false; _poolConfigurationChanged = false; }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="section"></param> public ClientConfiguration(CouchbaseClientSection section) { Timer = TimingFactory.GetTimer(Log); NodeAvailableCheckInterval = section.NodeAvailableCheckInterval; UseSsl = section.UseSsl; SslPort = section.SslPort; ApiPort = section.ApiPort; DirectPort = section.DirectPort; MgmtPort = section.MgmtPort; HttpsMgmtPort = section.HttpsMgmtPort; HttpsApiPort = section.HttpsApiPort; ObserveInterval = section.ObserveInterval; ObserveTimeout = section.ObserveTimeout; MaxViewRetries = section.MaxViewRetries; ViewHardTimeout = section.ViewHardTimeout; SerializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; DeserializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; EnableConfigHeartBeat = section.EnableConfigHeartBeat; HeartbeatConfigInterval = section.HeartbeatConfigInterval; ViewRequestTimeout = section.ViewRequestTimeout; Expect100Continue = section.Expect100Continue; EnableOperationTiming = section.EnableOperationTiming; DefaultOperationLifespan = section.OperationLifespan; QueryRequestTimeout = section.QueryRequestTimeout; IOErrorCheckInterval = section.IOErrorCheckInterval; IOErrorThreshold = section.IOErrorThreshold; //transcoders, converters, and serializers...o mai. Serializer = SerializerFactory.GetSerializer(this, section.Serializer); Converter = ConverterFactory.GetConverter(section.Converter); Transcoder = TranscoderFactory.GetTranscoder(this, section.Transcoder); //to enable tcp keep-alives EnableTcpKeepAlives = section.EnableTcpKeepAlives; TcpKeepAliveInterval = section.TcpKeepAliveInterval; TcpKeepAliveTime = section.TcpKeepAliveTime; var keepAlivesChanged = EnableTcpKeepAlives != true || TcpKeepAliveInterval != 1000 || TcpKeepAliveTime != 2 * 60 * 60 * 1000; foreach (var server in section.Servers) { Servers.Add(((UriElement)server).Uri); _serversChanged = true; } PoolConfiguration = new PoolConfiguration { MaxSize = section.ConnectionPool.MaxSize, MinSize = section.ConnectionPool.MinSize, WaitTimeout = section.ConnectionPool.WaitTimeout, ShutdownTimeout = section.ConnectionPool.ShutdownTimeout, UseSsl = section.ConnectionPool.UseSsl, BufferSize = section.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize), ConnectTimeout = section.ConnectionPool.ConnectTimeout, SendTimeout = section.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : section.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : section.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : section.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = section.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = section.ConnectionPool.MaxCloseAttempts, ClientConfiguration = this }; BucketConfigs = new Dictionary <string, BucketConfiguration>(); foreach (var bucketElement in section.Buckets) { var bucket = (BucketElement)bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, DefaultOperationLifespan = bucket.OperationLifespan ?? (uint)DefaultOperationLifespan, ObserveTimeout = bucket.ObserveTimeout, UseEnhancedDurability = bucket.UseEnhancedDurability }; //Configuration properties (including elements) can not be null, but we can check if it was originally presnt in xml and skip it. //By skipping the bucket specific connection pool settings we allow inheritance from clien-wide connection pool settings. if (bucket.ConnectionPool.ElementInformation.IsPresent) { bucketConfiguration.PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, BufferSize = bucket.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize), ConnectTimeout = bucket.ConnectionPool.ConnectTimeout, SendTimeout = bucket.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : bucket.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : bucket.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : bucket.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = bucket.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = bucket.ConnectionPool.MaxCloseAttempts, UseEnhancedDurability = bucket.UseEnhancedDurability, ClientConfiguration = this }; } else { bucketConfiguration.PoolConfiguration = PoolConfiguration; } BucketConfigs.Add(bucket.Name, bucketConfiguration); } //Set back to default _operationLifespanChanged = false; _poolConfigurationChanged = false; }
public void When_NotSupportedException_Thrown_When_Proxy_Port_Is_Configured() { var configuration = new ClientConfiguration {PoolConfiguration = {MaxSize = 10, MinSize = 10}}; configuration.Servers.Clear(); configuration.Servers.Add(new Uri("http://127.0.0.1:8091/pools")); var bc = new BucketConfiguration(); bc.Password = "******"; bc.Username = "******"; bc.BucketName = "authenticated"; bc.Servers.Clear(); bc.Servers.Add(new Uri("http://127.0.0.1:8091/pools")); bc.Port = 11211; configuration.BucketConfigs.Clear(); configuration.BucketConfigs.Add("authenticated", bc); configuration.Initialize(); }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="section"></param> public ClientConfiguration(CouchbaseClientSection section) { Timer = TimingFactory.GetTimer(Log); UseSsl = section.UseSsl; SslPort = section.SslPort; ApiPort = section.ApiPort; DirectPort = section.DirectPort; MgmtPort = section.MgmtPort; HttpsMgmtPort = section.HttpsMgmtPort; HttpsApiPort = section.HttpsApiPort; ObserveInterval = section.ObserveInterval; ObserveTimeout = section.ObserveTimeout; MaxViewRetries = section.MaxViewRetries; ViewHardTimeout = section.ViewHardTimeout; SerializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; DeserializationSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; EnableConfigHeartBeat = section.EnableConfigHeartBeat; HeartbeatConfigInterval = section.HeartbeatConfigInterval; ViewRequestTimeout = section.ViewRequestTimeout; Expect100Continue = section.Expect100Continue; EnableOperationTiming = section.EnableOperationTiming; PoolConfiguration = new PoolConfiguration(this); DefaultOperationLifespan = section.OperationLifespan; //transcoders, converters, and serializers...o mai. Serializer = SerializerFactory.GetSerializer(this, section.Serializer); Converter = ConverterFactory.GetConverter(section.Converter); Transcoder = TranscoderFactory.GetTranscoder(this, section.Transcoder); //to enable tcp keep-alives EnableTcpKeepAlives = section.EnableTcpKeepAlives; TcpKeepAliveInterval = section.TcpKeepAliveInterval; TcpKeepAliveTime = section.TcpKeepAliveTime; var keepAlivesChanged = EnableTcpKeepAlives != true || TcpKeepAliveInterval != 1000 || TcpKeepAliveTime != 2 * 60 * 60 * 1000; foreach (var server in section.Servers) { Servers.Add(((UriElement)server).Uri); _serversChanged = true; } BucketConfigs = new Dictionary <string, BucketConfiguration>(); foreach (var bucketElement in section.Buckets) { var bucket = (BucketElement)bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, DefaultOperationLifespan = bucket.OperationLifespan ?? (uint)DefaultOperationLifespan, ObserveTimeout = bucket.ObserveTimeout, PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, BufferSize = bucket.ConnectionPool.BufferSize, BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize), ConnectTimeout = bucket.ConnectionPool.ConnectTimeout, SendTimeout = bucket.ConnectionPool.SendTimeout, EnableTcpKeepAlives = keepAlivesChanged ? EnableTcpKeepAlives : bucket.ConnectionPool.EnableTcpKeepAlives, TcpKeepAliveInterval = keepAlivesChanged ? TcpKeepAliveInterval : bucket.ConnectionPool.TcpKeepAliveInterval, TcpKeepAliveTime = keepAlivesChanged ? TcpKeepAliveTime : bucket.ConnectionPool.TcpKeepAliveTime, CloseAttemptInterval = bucket.ConnectionPool.CloseAttemptInterval, MaxCloseAttempts = bucket.ConnectionPool.MaxCloseAttempts, ClientConfiguration = this } }; BucketConfigs.Add(bucket.Name, bucketConfiguration); } //Set back to default _operationLifespanChanged = false; _poolConfigurationChanged = false; }
/// <summary> /// For synchronization with App.config or Web.configs. /// </summary> /// <param name="couchbaseClientSection"></param> internal ClientConfiguration(CouchbaseClientSection couchbaseClientSection) { UseSsl = couchbaseClientSection.UseSsl; SslPort = couchbaseClientSection.SslPort; ApiPort = couchbaseClientSection.ApiPort; DirectPort = couchbaseClientSection.DirectPort; MgmtPort = couchbaseClientSection.MgmtPort; HttpsMgmtPort = couchbaseClientSection.HttpsMgmtPort; HttpsApiPort = couchbaseClientSection.HttpsApiPort; ObserveInterval = couchbaseClientSection.ObserveInterval; ObserveTimeout = couchbaseClientSection.ObserveTimeout; MaxViewRetries = couchbaseClientSection.MaxViewRetries; ViewHardTimeout = couchbaseClientSection.ViewHardTimeout; SerializationContractResolver = new CamelCasePropertyNamesContractResolver(); DeserializationContractResolver = new CamelCasePropertyNamesContractResolver(); foreach (var server in couchbaseClientSection.Servers) { Servers.Add(((UriElement)server).Uri); } foreach (var bucketElement in couchbaseClientSection.Buckets) { var bucket = (BucketElement) bucketElement; var bucketConfiguration = new BucketConfiguration { BucketName = bucket.Name, UseSsl = bucket.UseSsl, Password = bucket.Password, ObserveInterval = bucket.ObserveInterval, ObserveTimeout = bucket.ObserveTimeout, PoolConfiguration = new PoolConfiguration { MaxSize = bucket.ConnectionPool.MaxSize, MinSize = bucket.ConnectionPool.MinSize, WaitTimeout = bucket.ConnectionPool.WaitTimeout, ShutdownTimeout = bucket.ConnectionPool.ShutdownTimeout, UseSsl = bucket.ConnectionPool.UseSsl, } }; BucketConfigs = new Dictionary<string, BucketConfiguration> {{bucket.Name, bucketConfiguration}}; } }