コード例 #1
0
        public override void Initialize()
        {
            base.Initialize();
            if (_state.TryChange(State.Initial, State.Open))
            {
                if (_openingEventHandler != null)
                {
                    _openingEventHandler(new ClusterOpeningEvent(ClusterId, Settings));
                }

                var stopwatch = Stopwatch.StartNew();
                _server = CreateServer(Settings.EndPoints[0]);
                var newClusterDescription = Description.WithServerDescription(_server.Description);
                if (_addingServerEventHandler != null)
                {
                    _addingServerEventHandler(new ClusterAddingServerEvent(ClusterId, _server.EndPoint));
                }
                _server.DescriptionChanged += ServerDescriptionChanged;
                stopwatch.Stop();

                if (_addedServerEventHandler != null)
                {
                    _addedServerEventHandler(new ClusterAddedServerEvent(_server.ServerId, stopwatch.Elapsed));
                }

                UpdateClusterDescription(newClusterDescription);

                _server.Initialize();

                if (_openedEventHandler != null)
                {
                    _openedEventHandler(new ClusterOpenedEvent(ClusterId, Settings, stopwatch.Elapsed));
                }
            }
        }
コード例 #2
0
        // private method
        private void InitializeServer(IClusterableServer server)
        {
            ThrowIfDisposed();

            var newClusterDescription = _description
                                        .WithType(ClusterType.LoadBalanced)
                                        .WithServerDescription(server.Description)
                                        .WithDnsMonitorException(null);

            UpdateClusterDescription(newClusterDescription);

            server.DescriptionChanged += ServerDescriptionChangedHandler;
            server.Initialize();
        }
コード例 #3
0
        public override void Initialize()
        {
            base.Initialize();
            if (_state.TryChange(State.Initial, State.Open))
            {
                if (Listener != null)
                {
                    Listener.ClusterBeforeOpening(ClusterId, Settings);
                    Listener.ClusterBeforeAddingServer(ClusterId, Settings.EndPoints[0]);
                }

                var stopwatch = Stopwatch.StartNew();
                _server = CreateServer(Settings.EndPoints[0]);
                _server.DescriptionChanged += ServerDescriptionChanged;
                _server.Initialize();
                stopwatch.Stop();

                if (Listener != null)
                {
                    Listener.ClusterAfterAddingServer(_server.ServerId, stopwatch.Elapsed);
                    Listener.ClusterAfterOpening(ClusterId, Settings, stopwatch.Elapsed);
                }
            }
        }
コード例 #4
0
        public override void Initialize()
        {
            base.Initialize();
            if (_state.TryChange(State.Initial, State.Open))
            {
                if (_openingEventHandler != null)
                {
                    _openingEventHandler(new ClusterOpeningEvent(ClusterId, Settings));
                }

                var stopwatch = Stopwatch.StartNew();
                _server = CreateServer(Settings.EndPoints[0]);
                var newClusterDescription = Description.WithServerDescription(_server.Description);
                if (_addingServerEventHandler != null)
                {
                    _addingServerEventHandler(new ClusterAddingServerEvent(ClusterId, _server.EndPoint));
                }
                _server.DescriptionChanged += ServerDescriptionChanged;
                stopwatch.Stop();

                if (_addedServerEventHandler != null)
                {
                    _addedServerEventHandler(new ClusterAddedServerEvent(_server.ServerId, stopwatch.Elapsed));
                }

                UpdateClusterDescription(newClusterDescription);

                _server.Initialize();

                if (_openedEventHandler != null)
                {
                    _openedEventHandler(new ClusterOpenedEvent(ClusterId, Settings, stopwatch.Elapsed));
                }
            }
        }
コード例 #5
0
        public override void Initialize()
        {
            base.Initialize();
            if (_state.TryChange(State.Initial, State.Open))
            {
                if (Listener != null)
                {
                    Listener.ClusterBeforeOpening(ClusterId, Settings);
                    Listener.ClusterBeforeAddingServer(ClusterId, Settings.EndPoints[0]);
                }

                var stopwatch = Stopwatch.StartNew();
                _server = CreateServer(Settings.EndPoints[0]);
                _server.DescriptionChanged += ServerDescriptionChanged;
                _server.Initialize();
                stopwatch.Stop();

                if (Listener != null)
                {
                    Listener.ClusterAfterAddingServer(_server.ServerId, stopwatch.Elapsed);
                    Listener.ClusterAfterOpening(ClusterId, Settings, stopwatch.Elapsed);
                }
            }
        }