Пример #1
0
        void IServerPool.Start()
        {
            log.WarnFormat("Starting {0}", this);
            // get the pool urls
            this.poolUrls = this.configuration.Urls.ToArray();
            if (this.poolUrls.Length == 0)
            {
                throw new InvalidOperationException("At least 1 pool url must be specified.");
            }

            this.configListener = new BucketConfigListener(new BucketConfigSettings {
                BucketName         = this.configuration.Bucket,
                BucketPassword     = this.configuration.BucketPassword,
                Uris               = this.poolUrls,
                IsHeartbeatEnabled = configuration.HeartbeatMonitor.Enabled,
                HeartbeatUri       = string.IsNullOrEmpty(configuration.HeartbeatMonitor.Uri)
                    ? null : new Uri(configuration.HeartbeatMonitor.Uri),
                HeartbeatInterval = configuration.HeartbeatMonitor.Interval
            })
            {
                Timeout      = (int)this.configuration.HttpRequestTimeout.TotalMilliseconds,
                DeadTimeout  = (int)this.configuration.SocketPool.DeadTimeout.TotalMilliseconds,
                RetryCount   = this.configuration.RetryCount,
                RetryTimeout = this.configuration.RetryTimeout
            };

            this.configListener.ClusterConfigChanged += this.InitNodes;

            // start blocks until the first NodeListChanged event is triggered
            this.configListener.Start();
        }
Пример #2
0
        void IDisposable.Dispose()
        {
            log.WarnFormat("Disposing {0}", this);
            GC.SuppressFinalize(this);

            if (this.state != null && this.state != InternalState.Empty)
            {
                lock (_syncObj)
                {
                    if (this.state != null && this.state != InternalState.Empty)
                    {
                        var currentNodes = this.state.CurrentNodes;
                        this.state = null;

                        this.configListener.Stop();
                        this.configListener = null;

                        if (this.resurrectTimer != null)
                        {
                            using (this.resurrectTimer)
                                this.resurrectTimer.Change(Timeout.Infinite, Timeout.Infinite);
                        }

                        this.resurrectTimer = null;

                        // close the pools
                        if (currentNodes != null)
                        {
                            foreach (var node in currentNodes)
                            {
                                node.Dispose();
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        void IDisposable.Dispose()
        {
            GC.SuppressFinalize(this);

            if (this.state != null && this.state != InternalState.Empty)
            {
                lock (this.DeadSync)
                {
                    if (this.state != null && this.state != InternalState.Empty)
                    {
                        var currentNodes = this.state.CurrentNodes;
                        this.state = null;

                        this.configListener.Stop();
                        this.configListener = null;

                        if (this.resurrectTimer != null)
                        {
                            using (this.resurrectTimer)
                                this.resurrectTimer.Change(Timeout.Infinite, Timeout.Infinite);
                        }

                        this.resurrectTimer = null;

                        // close the pools
                        if (currentNodes != null)
                        {
                            for (var i = 0; i < currentNodes.Length; i++)
                            {
                                currentNodes[i].Dispose();
                            }
                        }
                    }
                }
            }
        }
        void IServerPool.Start()
        {
            // get the pool urls
            this.poolUrls = this.configuration.Urls.ToArray();
            if (this.poolUrls.Length == 0)
                throw new InvalidOperationException("At least 1 pool url must be specified.");

            this.configListener = new BucketConfigListener(this.poolUrls, this.configuration.Bucket, this.configuration.BucketPassword)
            {
                Timeout = (int)this.configuration.SocketPool.ConnectionTimeout.TotalMilliseconds,
                DeadTimeout = (int)this.configuration.SocketPool.DeadTimeout.TotalMilliseconds,
                RetryCount = this.configuration.RetryCount,
                RetryTimeout = this.configuration.RetryTimeout
            };

            this.configListener.ClusterConfigChanged += this.InitNodes;

            // start blocks until the first NodeListChanged event is triggered
            this.configListener.Start();
        }
        void IDisposable.Dispose()
        {
            GC.SuppressFinalize(this);

            if (this.state != null && this.state != InternalState.Empty)
                lock (this.DeadSync)
                {
                    if (this.state != null && this.state != InternalState.Empty)
                    {
                        var currentNodes = this.state.CurrentNodes;
                        this.state = null;

                        this.configListener.Stop();
                        this.configListener = null;

                        if (this.resurrectTimer != null)
                            using (this.resurrectTimer)
                                this.resurrectTimer.Change(Timeout.Infinite, Timeout.Infinite);

                        this.resurrectTimer = null;

                        // close the pools
                        if (currentNodes != null)
                            for (var i = 0; i < currentNodes.Length; i++)
                                currentNodes[i].Dispose();
                    }
                }
        }
Пример #6
0
        void IServerPool.Start()
        {
            log.WarnFormat("Starting {0}", this);
            // get the pool urls
            this.poolUrls = this.configuration.Urls.ToArray();
            if (this.poolUrls.Length == 0)
                throw new InvalidOperationException("At least 1 pool url must be specified.");

            this.configListener = new BucketConfigListener(new BucketConfigSettings {
                BucketName = this.configuration.Bucket,
                BucketPassword = this.configuration.BucketPassword,
                Uris = this.poolUrls,
                IsHeartbeatEnabled = configuration.HeartbeatMonitor.Enabled,
                HeartbeatUri = string.IsNullOrEmpty(configuration.HeartbeatMonitor.Uri)
                    ? null : new Uri(configuration.HeartbeatMonitor.Uri),
                HeartbeatInterval = configuration.HeartbeatMonitor.Interval
            })
            {
                Timeout = (int)this.configuration.HttpRequestTimeout.TotalMilliseconds,
                DeadTimeout = (int)this.configuration.SocketPool.DeadTimeout.TotalMilliseconds,
                RetryCount = this.configuration.RetryCount,
                RetryTimeout = this.configuration.RetryTimeout
            };

            this.configListener.ClusterConfigChanged += this.InitNodes;

            // start blocks until the first NodeListChanged event is triggered
            this.configListener.Start();
        }
Пример #7
0
        void IDisposable.Dispose()
        {
            log.WarnFormat("Disposing {0}", this);
            GC.SuppressFinalize(this);

            if (this.state != null && this.state != InternalState.Empty)
                lock (_syncObj)
                {
                    if (this.state != null && this.state != InternalState.Empty)
                    {
                        var currentNodes = this.state.CurrentNodes;
                        this.state = null;

                        this.configListener.Stop();
                        this.configListener = null;

                        if (this.resurrectTimer != null)
                            using (this.resurrectTimer)
                                this.resurrectTimer.Change(Timeout.Infinite, Timeout.Infinite);

                        this.resurrectTimer = null;

                        // close the pools
                        if (currentNodes != null)
                        {
                            foreach (var node in currentNodes)
                            {
                                node.Dispose();
                            }
                        }
                    }
                }
        }