public static async Task <IClusterNode> CreateAsync(ClusterContext context, IPEndPoint endPoint) { var connection = endPoint.GetConnection(context.ClusterOptions); var serverFeatures = await connection.Hello().ConfigureAwait(false); var errorMap = await connection.GetErrorMap().ConfigureAwait(false); await connection.Authenticate(context.ClusterOptions, null).ConfigureAwait(false); var clusterNode = new ClusterNode(context) { EndPoint = endPoint, Connection = connection, ServerFeatures = serverFeatures, ErrorMap = errorMap }; clusterNode.BuildServiceUris(); return(clusterNode); }
protected async Task LoadClusterMap(IEnumerable <NodeAdapter> adapters) { foreach (var nodeAdapter in adapters) { var endPoint = nodeAdapter.GetIpEndPoint(11210);//will need to change this later to deal with custom ports if (BucketNodes.TryGetValue(endPoint, out IClusterNode bootstrapNode)) { bootstrapNode.NodesAdapter = nodeAdapter; bootstrapNode.BuildServiceUris(); continue; //bootstrap node is skipped because it already went through these steps } var connection = endPoint.GetConnection(); await connection.Authenticate(ClusterOptions, 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, ClusterOptions = ClusterOptions, NodesAdapter = nodeAdapter }; clusterNode.BuildServiceUris(); SupportsCollections = clusterNode.Supports(ServerFeatures.Collections); BucketNodes.AddOrUpdate(endPoint, clusterNode, (ep, node) => clusterNode); ClusterOptions.GlobalNodes.Add(clusterNode); } }