Ejemplo n.º 1
0
		internal static void SetDagNetwork(SetDagNetworkRequest changeReq)
		{
			NetworkManager.RunRpcOperation("SetDagNetwork", delegate(object param0, EventArgs param1)
			{
				NetworkManager manager = NetworkManager.GetManager();
				if (manager == null)
				{
					throw new DagNetworkManagementException(ReplayStrings.NetworkManagerInitError);
				}
				lock (manager.m_mapRefreshLock)
				{
					using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
					{
						dagConfigurationStore.Open();
						PersistentDagNetworkConfig persistentDagNetworkConfig = dagConfigurationStore.LoadNetworkConfig();
						if (persistentDagNetworkConfig != null)
						{
							string text = persistentDagNetworkConfig.Serialize();
							ReplayEventLogConstants.Tuple_DagNetworkConfigOld.LogEvent(DateTime.UtcNow.ToString(), new object[]
							{
								text
							});
						}
					}
					ExchangeNetworkMap exchangeNetworkMap = NetworkManager.FetchInitializedMap();
					PersistentDagNetworkConfig netConfig = exchangeNetworkMap.UpdateNetConfig(changeReq);
					manager.UpdateNetworkConfig(netConfig);
				}
			});
		}
        public void Save(IConfigurable instance)
        {
            DatabaseAvailabilityGroupNetwork databaseAvailabilityGroupNetwork = (DatabaseAvailabilityGroupNetwork)instance;
            DagNetworkObjectId   dagNetworkObjectId   = (DagNetworkObjectId)databaseAvailabilityGroupNetwork.Identity;
            SetDagNetworkRequest setDagNetworkRequest = new SetDagNetworkRequest();

            if (dagNetworkObjectId == null)
            {
                setDagNetworkRequest.Name = databaseAvailabilityGroupNetwork.Name;
            }
            else
            {
                setDagNetworkRequest.Name = dagNetworkObjectId.NetName;
            }
            if (databaseAvailabilityGroupNetwork.IsChanged(DatabaseAvailabilityGroupNetworkSchema.Name))
            {
                setDagNetworkRequest.NewName = databaseAvailabilityGroupNetwork.Name;
            }
            if (databaseAvailabilityGroupNetwork.IsChanged(DatabaseAvailabilityGroupNetworkSchema.Description))
            {
                setDagNetworkRequest.Description = databaseAvailabilityGroupNetwork.Description;
            }
            if (databaseAvailabilityGroupNetwork.IsChanged(DatabaseAvailabilityGroupNetworkSchema.ReplicationEnabled))
            {
                setDagNetworkRequest.ReplicationEnabled = databaseAvailabilityGroupNetwork.ReplicationEnabled;
            }
            if (databaseAvailabilityGroupNetwork.IsChanged(DatabaseAvailabilityGroupNetworkSchema.IgnoreNetwork))
            {
                setDagNetworkRequest.IgnoreNetwork = databaseAvailabilityGroupNetwork.IgnoreNetwork;
            }
            if (databaseAvailabilityGroupNetwork.IsChanged(DatabaseAvailabilityGroupNetworkSchema.Subnets))
            {
                setDagNetworkRequest.SubnetListIsSet = true;
                foreach (DatabaseAvailabilityGroupNetworkSubnet databaseAvailabilityGroupNetworkSubnet in databaseAvailabilityGroupNetwork.Subnets)
                {
                    setDagNetworkRequest.Subnets.Add(databaseAvailabilityGroupNetworkSubnet.SubnetId, null);
                }
            }
            this.GetDagByName(dagNetworkObjectId.DagName);
            DagNetworkRpc.SetDagNetwork(this.m_dag, setDagNetworkRequest);
            DagNetworkObjectId identity = new DagNetworkObjectId(this.m_dag.Name, databaseAvailabilityGroupNetwork.Name);

            databaseAvailabilityGroupNetwork.SetIdentity(identity);
            databaseAvailabilityGroupNetwork.ResetChangeTracking();
            this.m_dagNet = databaseAvailabilityGroupNetwork;
        }
Ejemplo n.º 3
0
        // Token: 0x0600177E RID: 6014 RVA: 0x0006121C File Offset: 0x0005F41C
        internal PersistentDagNetworkConfig UpdateNetConfig(SetDagNetworkRequest changeReq)
        {
            ExchangeNetwork network = this.GetNetwork(changeReq.Name);

            if (changeReq.NewName != null)
            {
                ExchangeNetwork network2 = this.GetNetwork(changeReq.NewName);
                if (network2 != null && network2 != network)
                {
                    NetworkManager.TraceError("SetDagNetwork Cannot rename {0} because {1} already exists", new object[]
                    {
                        changeReq.Name,
                        changeReq.NewName
                    });
                    throw new DagNetworkManagementException(ServerStrings.DagNetworkCreateDupName(changeReq.NewName));
                }
            }
            PersistentDagNetworkConfig persistentDagNetworkConfig = this.BuildNetConfigWithChange(changeReq);

            if (network == null)
            {
                PersistentDagNetwork persistentDagNetwork = new PersistentDagNetwork();
                persistentDagNetwork.Name               = changeReq.Name;
                persistentDagNetwork.Description        = changeReq.Description;
                persistentDagNetwork.IgnoreNetwork      = changeReq.IgnoreNetwork;
                persistentDagNetwork.ReplicationEnabled = changeReq.ReplicationEnabled;
                if (changeReq.Subnets.Count > 0)
                {
                    foreach (DatabaseAvailabilityGroupSubnetId databaseAvailabilityGroupSubnetId in changeReq.Subnets.Keys)
                    {
                        persistentDagNetwork.Subnets.Add(databaseAvailabilityGroupSubnetId.ToString());
                    }
                }
                persistentDagNetworkConfig.Networks.Add(persistentDagNetwork);
            }
            return(persistentDagNetworkConfig);
        }
Ejemplo n.º 4
0
        // Token: 0x0600177D RID: 6013 RVA: 0x00060F88 File Offset: 0x0005F188
        private PersistentDagNetworkConfig BuildNetConfigWithChange(SetDagNetworkRequest changeReq)
        {
            PersistentDagNetworkConfig persistentDagNetworkConfig = new PersistentDagNetworkConfig();

            persistentDagNetworkConfig.ReplicationPort    = this.m_mgr.ReplicationPort;
            persistentDagNetworkConfig.NetworkCompression = this.m_mgr.NetworkCompression;
            persistentDagNetworkConfig.NetworkEncryption  = this.m_mgr.NetworkEncryption;
            foreach (KeyValuePair <string, ExchangeNetwork> keyValuePair in this.m_networks)
            {
                ExchangeNetwork      value = keyValuePair.Value;
                PersistentDagNetwork persistentDagNetwork = new PersistentDagNetwork();
                persistentDagNetwork.Name               = value.Name;
                persistentDagNetwork.Description        = value.Description;
                persistentDagNetwork.ReplicationEnabled = value.ReplicationEnabled;
                persistentDagNetwork.IgnoreNetwork      = value.IgnoreNetwork;
                bool flag = false;
                if (changeReq != null && DatabaseAvailabilityGroupNetwork.NameComparer.Equals(changeReq.Name, value.Name))
                {
                    if (changeReq.NewName != null)
                    {
                        persistentDagNetwork.Name = changeReq.NewName;
                    }
                    if (changeReq.Description != null)
                    {
                        persistentDagNetwork.Description = changeReq.Description;
                    }
                    if (changeReq.IsIgnoreChanged)
                    {
                        persistentDagNetwork.IgnoreNetwork = changeReq.IgnoreNetwork;
                    }
                    if (changeReq.IsReplicationChanged)
                    {
                        persistentDagNetwork.ReplicationEnabled = changeReq.ReplicationEnabled;
                    }
                    if (changeReq.SubnetListIsSet || changeReq.Subnets.Count > 0)
                    {
                        flag = true;
                        foreach (KeyValuePair <DatabaseAvailabilityGroupSubnetId, object> keyValuePair2 in changeReq.Subnets)
                        {
                            persistentDagNetwork.Subnets.Add(keyValuePair2.Key.ToString());
                        }
                    }
                }
                if (!flag)
                {
                    foreach (ExchangeSubnet exchangeSubnet in value.Subnets)
                    {
                        if (changeReq != null && changeReq.Subnets.Count > 0 && changeReq.Subnets.ContainsKey(exchangeSubnet.SubnetId))
                        {
                            NetworkManager.TraceDebug("Subnet '{0}' moving from net '{1}' to net '{2}'", new object[]
                            {
                                exchangeSubnet.SubnetId,
                                value.Name,
                                changeReq.LatestName
                            });
                        }
                        else
                        {
                            string item = exchangeSubnet.SubnetId.ToString();
                            persistentDagNetwork.Subnets.Add(item);
                        }
                    }
                }
                persistentDagNetworkConfig.Networks.Add(persistentDagNetwork);
            }
            return(persistentDagNetworkConfig);
        }