public ClusterFixture() { Configuration = new Couchbase.Configuration() .WithServers("couchbase://localhost") .WithBucket("default") .WithCredentials("Administrator", "password"); Cluster = new Cluster(Configuration); Cluster.InitializeAsync().ConfigureAwait(false).GetAwaiter().GetResult(); }
public static Func <IOrphanedResponseLogger> GetFactory(Couchbase.Configuration config) { if (config.OrphanedResponseLoggingEnabled) { // TODO: extend to allow type building from config return(() => new OrphanedResponseLogger()); } return(() => NullOrphanedResponseLogger.Instance); }
public void Test_Filter_Removed_Nodes(string oldConfigPath, string newConfigPath) { var oldConfig = ResourceHelper.ReadResource <BucketConfig>(oldConfigPath); var newConfig = ResourceHelper.ReadResource <BucketConfig>(newConfigPath); var configuration = new Couchbase.Configuration(); var bucketNodes = new ConcurrentDictionary <IPEndPoint, ClusterNode>(); //load up the initial state after bootstrapping foreach (var server in oldConfig.NodesExt) { var endPoint = server.GetIpEndPoint(configuration); var clusterNode = new ClusterNode { EndPoint = endPoint }; configuration.GlobalNodes.Add(clusterNode); bucketNodes.TryAdd(endPoint, clusterNode); } foreach (var nodesExt in newConfig.NodesExt) { var endPoint = nodesExt.GetIpEndPoint(configuration); if (bucketNodes.ContainsKey(endPoint)) { continue; } var clusterNode = new ClusterNode { EndPoint = endPoint }; configuration.GlobalNodes.Add(clusterNode); bucketNodes.TryAdd(endPoint, clusterNode); } var removed = bucketNodes.Where(x => !newConfig.NodesExt.Any(y => x.Key.Equals(y.GetIpEndPoint(configuration)))); foreach (var valuePair in removed) { if (!bucketNodes.TryRemove(valuePair.Key, out var clusterNode)) { continue; } if (configuration.GlobalNodes.TryTake(out clusterNode)) { clusterNode.Dispose(); } } Assert.Equal(newConfig.NodesExt.Count, bucketNodes.Count); Assert.Equal(configuration.GlobalNodes.Count, bucketNodes.Count); }
public ConfigContext(Couchbase.Configuration configuration) { _configuration = configuration; }
public static int GetKeyValuePort(this Node node, Couchbase.Configuration configuration) { return(configuration.UseSsl ? node.Ports.Direct : node.Ports.SslDirect); }
public ConfigContext(Couchbase.Configuration configuration) { _configuration = configuration; _httpClient = new CouchbaseHttpClient(_configuration); }
private static HttpClientHandler CreateClientHandler(string username, string password, Couchbase.Configuration clientConfig) { HttpClientHandler handler; //for x509 cert authentication if (clientConfig != null && clientConfig.EnableCertificateAuthentication) { handler = new NonAuthenticatingHttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual, SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 }; //handler.ClientCertificates.AddRange(config.CertificateFactory()); //TODO } else { handler = new AuthenticatingHttpClientHandler(username, password); } try { handler.CheckCertificateRevocationList = clientConfig.EnableCertificateRevocation; //handler.ServerCertificateCustomValidationCallback = config?.HttpServerCertificateValidationCallback ?? // OnCertificateValidation; } catch (NotImplementedException) { //Log.Debug("Cannot set ServerCertificateCustomValidationCallback, not supported on this platform"); } if (clientConfig != null) { try { handler.MaxConnectionsPerServer = clientConfig.MaxQueryConnectionsPerServer; } catch (PlatformNotSupportedException e) { // Log.Debug("Cannot set MaxConnectionsPerServer, not supported on this platform", e); } } return(handler); }
public static int GetKeyValuePort(this NodesExt nodesExt, Couchbase.Configuration configuration) { return(configuration.UseSsl ? nodesExt.Services.KvSsl : nodesExt.Services.Kv); }
public HttpClusterMap(HttpClient httpClient, ConfigContext ctx, Couchbase.Configuration configuration) { _httpClient = httpClient; _ctx = ctx; _configuration = configuration; }
//used by all http services internal CouchbaseHttpClient(Couchbase.Configuration clientConfig) : this(CreateClientHandler(clientConfig.UserName, clientConfig.Password, clientConfig)) { ClientConfig = clientConfig; DefaultRequestHeaders.ExpectContinue = clientConfig.Expect100Continue; }