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