internal override async Task Bootstrap(params ClusterNode[] bootstrapNodes)
        {
            //should never happen
            if (bootstrapNodes == null)
            {
                throw new ArgumentNullException(nameof(bootstrapNodes));
            }

            var bootstrapNode = bootstrapNodes.FirstOrDefault();

            //fetch the cluster map to avoid race condition with streaming http
            BucketConfig = await _httClusterMap.GetClusterMapAsync(
                Name, bootstrapNode.BootstrapUri, CancellationToken.None).ConfigureAwait(false);

            KeyMapper = new KetamaKeyMapper(BucketConfig, Configuration);

            //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);

            LoadManifest();
            LoadClusterMap(BucketConfig.GetNodes()).ConfigureAwait(false).GetAwaiter().GetResult();
            bootstrapNode.Owner = this;
        }
        internal override async Task Bootstrap(params ClusterNode[] bootstrapNodes)
        {
            //should never happen
            if (bootstrapNodes == null)
            {
                throw new ArgumentNullException(nameof(bootstrapNodes));
            }

            List <NodeAdapter> nodeAdapters = null;
            var bootstrapNode = bootstrapNodes.First();

            //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);

            BucketConfig = await bootstrapNode.GetClusterMap().ConfigureAwait(false);

            KeyMapper = new VBucketKeyMapper(BucketConfig);

            nodeAdapters = BucketConfig.GetNodes();
            if (nodeAdapters.Count == 1)
            {
                var nodeAdapter = nodeAdapters.First();
                bootstrapNode.NodesAdapter = nodeAdapter;
            }
            else
            {
                bootstrapNode.NodesAdapter =
                    nodeAdapters.Find(x => x.Hostname == bootstrapNode.BootstrapUri.Host);
            }

            LoadManifest();
            LoadClusterMap(nodeAdapters).ConfigureAwait(false).GetAwaiter().GetResult();
            bootstrapNode.Owner = this;
        }
Beispiel #3
0
        internal override async Task Bootstrap(params IClusterNode[] bootstrapNodes)
        {
            var bootstrapNode = bootstrapNodes.FirstOrDefault();

            //fetch the cluster map to avoid race condition with streaming http
            BucketConfig = await _httpClusterMap.GetClusterMapAsync(
                Name, bootstrapNode.BootstrapUri, CancellationToken.None).ConfigureAwait(false);

            KeyMapper = new KetamaKeyMapper(BucketConfig, ClusterOptions);

            //reuse the bootstrapNode
            BucketNodes.AddOrUpdate(bootstrapNode.EndPoint, bootstrapNode, (key, node) => bootstrapNode);
            bootstrapNode.ClusterOptions = ClusterOptions;

            //the initial bootstrapping endpoint;
            await bootstrapNode.SelectBucket(Name).ConfigureAwait(false);

            LoadManifest();
            LoadClusterMap(BucketConfig.GetNodes()).ConfigureAwait(false).GetAwaiter().GetResult();
            bootstrapNode.Owner = this;
        }