Ejemplo n.º 1
0
		internal static void SetDagNetworkConfig(SetDagNetworkConfigRequest configChange)
		{
			NetworkManager.RunRpcOperation("SetDagNetworkConfig", delegate(object param0, EventArgs param1)
			{
				NetworkManager manager = NetworkManager.GetManager();
				if (manager == null)
				{
					throw new DagNetworkManagementException(ReplayStrings.NetworkManagerInitError);
				}
				lock (manager.m_mapRefreshLock)
				{
					using (IAmCluster amCluster = ClusterFactory.Instance.Open())
					{
						using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
						{
							dagConfigurationStore.Open();
							PersistentDagNetworkConfig persistentDagNetworkConfig = dagConfigurationStore.LoadNetworkConfig();
							if (persistentDagNetworkConfig == null)
							{
								persistentDagNetworkConfig = new PersistentDagNetworkConfig();
							}
							else
							{
								string text = persistentDagNetworkConfig.Serialize();
								ReplayEventLogConstants.Tuple_DagNetworkConfigOld.LogEvent(DateTime.UtcNow.ToString(), new object[]
								{
									text
								});
							}
							if (configChange.SetPort)
							{
								persistentDagNetworkConfig.ReplicationPort = configChange.ReplicationPort;
								manager.ReplicationPort = configChange.ReplicationPort;
							}
							manager.NetworkCompression = configChange.NetworkCompression;
							persistentDagNetworkConfig.NetworkCompression = configChange.NetworkCompression;
							manager.NetworkEncryption = configChange.NetworkEncryption;
							persistentDagNetworkConfig.NetworkEncryption = configChange.NetworkEncryption;
							manager.ManualDagNetworkConfiguration = configChange.ManualDagNetworkConfiguration;
							persistentDagNetworkConfig.ManualDagNetworkConfiguration = configChange.ManualDagNetworkConfiguration;
							if (configChange.DiscoverNetworks)
							{
								NetworkDiscovery networkDiscovery = new NetworkDiscovery();
								networkDiscovery.LoadClusterObjects(amCluster);
								networkDiscovery.DetermineDnsStatus();
								networkDiscovery.AggregateNetworks(true);
								ExchangeNetworkMap exchangeNetworkMap = new ExchangeNetworkMap(manager);
								exchangeNetworkMap.Load(networkDiscovery);
								persistentDagNetworkConfig = exchangeNetworkMap.BuildPersistentDagNetworkConfig();
							}
							manager.UpdateNetworkConfig(persistentDagNetworkConfig);
						}
					}
				}
			});
		}
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag = false;

            if ((base.Fields["ReplicationPort"] != null || base.Fields["NetworkCompression"] != null || base.Fields["NetworkEncryption"] != null || base.Fields["ManualDagNetworkConfiguration"] != null || base.Fields["DiscoverNetworks"] != null) && !this.m_dag.IsDagEmpty())
            {
                flag = true;
                this.m_IsObjectChanged = true;
            }
            if (this.DataObject.AllowCrossSiteRpcClientAccess != this.AllowCrossSiteRpcClientAccess)
            {
                if (base.Fields["AllowCrossSiteRpcClientAccess"] != null)
                {
                    this.DataObject.AllowCrossSiteRpcClientAccess = this.AllowCrossSiteRpcClientAccess;
                    this.m_IsObjectChanged = true;
                }
                else
                {
                    this.AllowCrossSiteRpcClientAccess = this.DataObject.AllowCrossSiteRpcClientAccess;
                }
            }
            if (this.m_fsw != null)
            {
                this.m_dag.SetWitnessServer(this.m_fsw.FileShareWitnessShare, this.m_fsw.WitnessDirectory);
                this.m_IsObjectChanged = true;
            }
            if (this.m_afsw != null)
            {
                this.m_dag.SetAlternateWitnessServer(this.m_afsw.FileShareWitnessShare, this.m_afsw.WitnessDirectory);
                this.m_IsObjectChanged = true;
            }
            else if (this.AlternateWitnessServer == null && this.m_alternateWitnessServerParameterSpecified)
            {
                this.m_dag.SetAlternateWitnessServer(null, null);
            }
            base.InternalProcessRecord();
            if (flag && !this.m_dag.IsDagEmpty())
            {
                SetDagNetworkConfigRequest setDagNetworkConfigRequest = new SetDagNetworkConfigRequest();
                if (base.Fields["ReplicationPort"] != null)
                {
                    setDagNetworkConfigRequest.ReplicationPort = this.ReplicationPort;
                }
                setDagNetworkConfigRequest.NetworkCompression            = this.m_dag.NetworkCompression;
                setDagNetworkConfigRequest.NetworkEncryption             = this.m_dag.NetworkEncryption;
                setDagNetworkConfigRequest.ManualDagNetworkConfiguration = this.m_dag.ManualDagNetworkConfiguration;
                if (base.Fields["DiscoverNetworks"] != null)
                {
                    setDagNetworkConfigRequest.DiscoverNetworks = true;
                }
                DagNetworkRpc.SetDagNetworkConfig(this.m_dag, setDagNetworkConfigRequest);
            }
            if (!this.m_dag.IsDagEmpty())
            {
                using (AmCluster amCluster = AmCluster.OpenDagClus(this.m_dag))
                {
                    if (amCluster.CnoName != string.Empty)
                    {
                        using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup())
                        {
                            using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
                            {
                                IPAddress[] dagIpAddressesFromAd = this.GetDagIpAddressesFromAd(this.m_output, this.m_dag);
                                AmClusterResourceHelper.FixUpIpAddressesForNetName(this.m_output, amCluster, (AmClusterGroup)amClusterGroup, (AmClusterResource)amClusterResource, dagIpAddressesFromAd);
                                DagTaskHelper.LogCnoState(this.m_output, this.m_dag.Name, amClusterResource);
                            }
                        }
                    }
                }
                this.UpdateFileShareWitness();
                DagTaskHelper.NotifyServersOfConfigChange(this.m_allServers.Keys);
            }
            TaskLogger.LogExit();
        }