async Task IBucketInternal.Bootstrap(ClusterNode bootstrapNode) { //should never happen if (bootstrapNode == null) { throw new ArgumentNullException(nameof(bootstrapNode)); } bootstrapNode.Owner = this; //reuse the bootstrapNode _bucketNodes.AddOrUpdate(bootstrapNode.EndPoint, bootstrapNode, (key, node) => bootstrapNode); bootstrapNode.Configuration = _configuration; //the initial bootstrapping endpoint; await bootstrapNode.SelectBucket(Name).ConfigureAwait(false); _manifest = await bootstrapNode.GetManifest().ConfigureAwait(false); _supportsCollections = bootstrapNode.Supports(ServerFeatures.Collections); var bucketConfig = await bootstrapNode.GetClusterMap().ConfigureAwait(false); //TODO this should go through standard config check process NCBC-1944 //first call should be synchronous ConfigUpdated(this, new BucketConfigEventArgs(bucketConfig)); }
private async Task LoadClusterMap() { foreach (var nodesExt in _bucketConfig.NodesExt)//will need to update to use "NodeAdapter" = Nodes + NodesExt like in 2.0 { var endpoint = nodesExt.GetIpEndPoint(_configuration); if (_bucketNodes.TryGetValue(endpoint, out ClusterNode bootstrapNode)) { bootstrapNode.NodesExt = nodesExt; bootstrapNode.BuildServiceUris(); continue; //bootstrap node is skipped because it already went through these steps } var connection = endpoint.GetConnection(); await connection.Authenticate(_configuration, Name).ConfigureAwait(false); await connection.SelectBucket(Name).ConfigureAwait(false); //one error map per node var errorMap = await connection.GetErrorMap().ConfigureAwait(false); var supportedFeatures = await connection.Hello().ConfigureAwait(false); var clusterNode = new ClusterNode { Connection = connection, ErrorMap = errorMap, EndPoint = endpoint, ServerFeatures = supportedFeatures, Configuration = _configuration, NodesExt = nodesExt, //build the services urls QueryUri = endpoint.GetQueryUri(_configuration, nodesExt), SearchUri = endpoint.GetSearchUri(_configuration, nodesExt), AnalyticsUri = endpoint.GetAnalyticsUri(_configuration, nodesExt), ViewsUri = endpoint.GetViewsUri(_configuration, nodesExt), }; clusterNode.BuildServiceUris(); _supportsCollections = clusterNode.Supports(ServerFeatures.Collections); _bucketNodes.AddOrUpdate(endpoint, clusterNode, (ep, node) => clusterNode); _configuration.GlobalNodes.Add(clusterNode); } }
private async Task LoadClusterMap(BucketConfig bucketConfig) { foreach (var nodesExt in bucketConfig.NodesExt) { var endPoint = nodesExt.GetIpEndPoint(_configuration); if (_bucketNodes.TryGetValue(endPoint, out ClusterNode bootstrapNode)) { bootstrapNode.NodesExt = nodesExt; bootstrapNode.BuildServiceUris(); continue; //bootstrap node is skipped because it already went through these steps } var connection = endPoint.GetConnection(); await connection.Authenticate(_configuration, Name).ConfigureAwait(false); await connection.SelectBucket(Name).ConfigureAwait(false); //one error map per node var errorMap = await connection.GetErrorMap().ConfigureAwait(false); var supportedFeatures = await connection.Hello().ConfigureAwait(false); var clusterNode = new ClusterNode { Connection = connection, ErrorMap = errorMap, EndPoint = endPoint, ServerFeatures = supportedFeatures, Configuration = _configuration, NodesExt = nodesExt }; clusterNode.BuildServiceUris(); _supportsCollections = clusterNode.Supports(ServerFeatures.Collections); _bucketNodes.AddOrUpdate(endPoint, clusterNode, (ep, node) => clusterNode); _configuration.GlobalNodes.Add(clusterNode); } }