public void Execute() { if (listener != null) { listener.OnConfigurationChanged(eventArgs); } }
public void OnConfigurationChanged(ConfigChangeEventArgs arguments) { ChangeType type = ChangeType.None; if (arguments != null) { string clusterName = arguments.GetParamValue <string>(EventParamName.ClusterName); if (clusterName != null && !clusterName.Equals(context.ClusterName)) { return; } type = arguments.GetParamValue <ChangeType>(EventParamName.ConfigurationChangeType); switch (type) { case ChangeType.DistributionStrategyConfigured: case ChangeType.DatabaseCreated: case ChangeType.DatabaseDropped: case ChangeType.CollectionCreated: case ChangeType.CollectionMoved: case ChangeType.CollectionDropped: case ChangeType.ConfigRestored: case ChangeType.ResyncDatabase: case ChangeType.IntraShardStateTrxferCompleted: if (this.configChangeListener != null) { configChangeListener.OnConfigurationChanged(arguments); } break; case ChangeType.ConfigurationUpdated: break; case ChangeType.ShardAdded: { ShardInfo newShard = null; if (context.ConfigurationSession != null) { ClusterInfo latestInfo = context.ConfigurationSession.GetDatabaseClusterInfo(arguments.GetParamValue <string>(EventParamName.ClusterName)); newShard = latestInfo.GetShardInfo(arguments.GetParamValue <string>(EventParamName.ShardName)); } OnShardAdded(newShard); if (this._clusterListener != null) { _clusterListener.OnShardAdd(newShard); } } break; case ChangeType.ShardRemovedForceful: if (this._clusterListener != null) { ShardInfo removedShard = new ShardInfo() { Name = arguments.GetParamValue <string>(EventParamName.ShardName) }; _clusterListener.OnShardRemove(removedShard, false); } break; case ChangeType.ShardRemovedGraceful: if (this._clusterListener != null) { ShardInfo removedShard = new ShardInfo() { Name = arguments.GetParamValue <string>(EventParamName.ShardName) }; _clusterListener.OnShardRemove(removedShard, true); } break; case ChangeType.DistributionChanged: if (this._clusterListener != null) { _clusterListener.OnDistributionChanged(); } break; //write code for check if the primary has been changed for remote shard(s) connect with the new one case ChangeType.MembershipChanged: case ChangeType.PrimarySelected: case ChangeType.NodeJoined: // AR: This should be removing the node from the restoration manager of the local shard. //if (arguments.ConfigurationChangeType == ChangeType.PrimarySelected || arguments.ConfigurationChangeType == ChangeType.PrimaryGone) //{ // ControlConfigurationChangeTask(arguments); if (arguments.GetParamValue <ChangeType>(EventParamName.ConfigurationChangeType) == ChangeType.MembershipChanged) { HandlePrimaryChangeForRemoteshard(arguments); } //} //if (arguments.ConfigurationChangeType.Equals(ChangeType.PrimarySelected) && arguments.Membership.Primary != null || (arguments.ConfigurationChangeType.Equals(ChangeType.PrimaryGone) && arguments.Membership.Primary == null)) //{ //HandleMembershipChangeForRemoteShard(); //} //OnMembershipChanged(arguments); //HandlePrimaryChangeForRemoteshard(arguments); //HandleMembershipChanged(); break; case ChangeType.NodeAdded: case ChangeType.NodeRemoved: case ChangeType.PriorityChanged: case ChangeType.NodeLeft: case ChangeType.PrimaryGone: if (_localShard != null) { ((LocalShard)_localShard).OnConfigurationChanged(arguments); } break; case ChangeType.RangeUpdated: _clusterListener.OnRangesUpdated(); break; case ChangeType.NewRangeAdded: _clusterListener.OnNewRangeAdded(); break; default: //write code for check if the primary has been changed for remote shard(s) connect with the new one break; } } }