// Token: 0x060008AE RID: 2222 RVA: 0x00029798 File Offset: 0x00027998
 internal static void RevertToMnsQuorum(ILogTraceHelper output, IAmCluster cluster)
 {
     using (IAmClusterGroup amClusterGroup = cluster.FindCoreClusterGroup())
     {
         string text;
         uint   maxLogSize;
         string quorumResourceInformation = cluster.GetQuorumResourceInformation(out text, out maxLogSize);
         if (string.IsNullOrEmpty(quorumResourceInformation))
         {
             output.AppendLogMessage("RevertToMnsQuorum: It's already using MNS!", new object[0]);
             using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("File Share Witness"))
             {
                 if (amClusterResource != null)
                 {
                     output.AppendLogMessage("Even though the quorum is set to MNS, there is a FSW resource present named '{0}', which will be deleted shortly.", new object[]
                     {
                         amClusterResource.Name
                     });
                     amClusterResource.DeleteResource();
                     output.AppendLogMessage("The resource has been deleted!", new object[0]);
                 }
                 goto IL_13D;
             }
         }
         using (AmClusterResource amClusterResource2 = cluster.OpenResource(quorumResourceInformation))
         {
             output.AppendLogMessage("Setting cluster quorum to MNS", new object[0]);
             if (cluster.CnoName == string.Empty)
             {
                 cluster.ClearQuorumResource();
             }
             else
             {
                 using (IAmClusterResource amClusterResource3 = amClusterGroup.FindResourceByTypeName("Network Name"))
                 {
                     output.AppendLogMessage("Setting cluster quorum resource to the netname resource (i.e. MNS quorum).", new object[0]);
                     cluster.SetQuorumResource(amClusterResource3, null, maxLogSize);
                     if (amClusterResource2 != null && amClusterResource2.GetTypeName() == "File Share Witness")
                     {
                         output.AppendLogMessage("Offlining and deleting the old FSW resource '{0}'.", new object[]
                         {
                             quorumResourceInformation
                         });
                         amClusterResource2.OfflineResource();
                         amClusterResource2.DeleteResource();
                     }
                 }
             }
         }
         IL_13D :;
     }
 }
示例#2
0
        internal static void FixIPAddress(AmServerName nodeName, DatabaseAvailabilityGroup dag, IEnumerable <AmServerName> startedMailboxServers, ITaskOutputHelper output)
        {
            output.WriteProgressSimple(Strings.DagTaskFixingUpIpResources);
            MultiValuedProperty <IPAddress> databaseAvailabilityGroupIpv4Addresses = dag.DatabaseAvailabilityGroupIpv4Addresses;

            IPAddress[] array = new IPAddress[0];
            if (databaseAvailabilityGroupIpv4Addresses.Count > 0)
            {
                array = databaseAvailabilityGroupIpv4Addresses.ToArray();
            }
            string[] value = (from addr in array
                              select addr.ToString()).ToArray <string>();
            output.AppendLogMessage("Got the following IP addresses for the DAG (blank means DHCP):{0}", new object[]
            {
                string.Join(",", value)
            });
            using (AmCluster amCluster = AmCluster.OpenByNames(startedMailboxServers))
            {
                if (amCluster.CnoName != string.Empty)
                {
                    using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup())
                    {
                        using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
                        {
                            LocalizedString value2 = AmClusterResourceHelper.FixUpIpAddressesForNetName(output, amCluster, (AmClusterGroup)amClusterGroup, (AmClusterResource)amClusterResource, array);
                            output.WriteProgressSimple(Strings.DagTaskFixedUpIpResources(value2));
                            DagTaskHelper.LogCnoState(output, dag.Name, amClusterResource);
                        }
                    }
                }
            }
        }
示例#3
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     this.LogCommandLineParameters();
     this.m_removeNode     = false;
     this.m_destroyCluster = false;
     this.ResolveParameters();
     DagTaskHelper.VerifyDagAndServersAreWithinScopes <DatabaseAvailabilityGroup>(this, this.m_dag, true);
     this.m_output.WriteProgress(Strings.ProgressStatusInProgress, Strings.DagTaskRemoveDagServerRunningChecks(this.m_mailboxServerName, this.m_dagName), 0);
     this.CheckDatabasesAreNotReplicated();
     if (!this.m_configurationOnly)
     {
         DagTaskHelper.CheckServerDoesNotBelongToDifferentDag(new Task.TaskErrorLoggingDelegate(this.m_output.WriteError), base.DataSession, this.m_mailboxServer, this.m_dagName);
         this.CheckFswSettings();
         this.CheckClusterStateForDagServerRemoval();
         if (!this.m_configurationOnly)
         {
             using (IAmClusterGroup amClusterGroup = this.m_clusDag.FindCoreClusterGroup())
             {
                 AmServerName ownerNode = amClusterGroup.OwnerNode;
                 this.m_output.AppendLogMessage("Checking if msexchangerepl is running on {0}.", new object[]
                 {
                     ownerNode.NetbiosName
                 });
                 DatabaseTasksHelper.CheckReplayServiceRunningOnNode(ownerNode, new Task.TaskErrorLoggingDelegate(base.WriteError));
                 if (this.m_clusDag.CnoName != string.Empty)
                 {
                     using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
                     {
                         DagTaskHelper.LogCnoState(this.m_output, this.m_dagName, amClusterResource);
                     }
                 }
             }
         }
     }
     if (DagTaskHelper.FindServerAdObjectIdInDag(this.m_dag, this.m_mailboxAmServerName) == null)
     {
         StringBuilder stringBuilder = new StringBuilder(string.Format("{0}. srvToRemove={1} dagSvrs=(", this.m_dagName, this.m_mailboxAmServerName.NetbiosName));
         bool          flag          = false;
         foreach (ADObjectId adobjectId in this.m_dag.Servers)
         {
             if (flag)
             {
                 stringBuilder.Append(",");
             }
             else
             {
                 flag = true;
             }
             stringBuilder.Append(adobjectId.Name);
         }
         stringBuilder.Append(")");
         this.m_output.WriteErrorSimple(new DagTaskServerIsNotInDagException(this.m_mailboxServerName, stringBuilder.ToString()));
     }
     base.InternalValidate();
     TaskLogger.LogExit();
 }
 // Token: 0x060008B4 RID: 2228 RVA: 0x00029BAC File Offset: 0x00027DAC
 internal static void FollowBestPractices(ITaskOutputHelper output, IAmCluster cluster)
 {
     if (string.Empty != cluster.CnoName)
     {
         using (IAmClusterGroup amClusterGroup = cluster.FindCoreClusterGroup())
         {
             using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
             {
                 output.AppendLogMessage("Setting the DNS TTL to 300", new object[0]);
                 amClusterResource.SetPrivateProperty <int>("HostRecordTTL", 300);
             }
         }
     }
 }
示例#5
0
 private void RemoveNodeFromCluster()
 {
     this.m_output.WriteProgressSimple(Strings.DagTaskRemovedNodeToCluster(this.m_mailboxServerName));
     using (IAmClusterNode amClusterNode = this.m_clusDag.OpenNode(this.m_mailboxAmServerName))
     {
         bool   flag             = false;
         string empty            = string.Empty;
         string remoteServerName = "<unknown>";
         try
         {
             using (IAmClusterGroup amClusterGroup = this.m_clusDag.FindCoreClusterGroup())
             {
                 AmServerName ownerNode = amClusterGroup.OwnerNode;
                 remoteServerName = ownerNode.Fqdn;
                 ReplayRpcClientWrapper.RunEvictNodeFromCluster(ownerNode, this.m_mailboxAmServerName, out empty);
             }
         }
         catch (DagTaskOperationFailedException ex)
         {
             AmClusterEvictWithoutCleanupException ex2;
             if (ex.TryGetTypedInnerException(out ex2))
             {
                 this.m_output.WriteWarning(ex2.LocalizedString);
             }
             else
             {
                 DagTaskHelper.LogRemoteVerboseLog(this.m_output, remoteServerName, empty);
                 this.m_output.WriteErrorSimple(ex);
             }
         }
         catch (LocalizedException error)
         {
             DagTaskHelper.LogRemoteVerboseLog(this.m_output, remoteServerName, empty);
             this.m_output.WriteErrorSimple(error);
         }
         DagTaskHelper.LogRemoteVerboseLog(this.m_output, remoteServerName, empty);
         if (flag)
         {
             this.m_output.WriteWarning(Strings.DagTaskRemoveNodeCleanupFailed(amClusterNode.Name.Fqdn));
         }
     }
     this.m_output.WriteProgressSimple(Strings.DagTaskRemovedNodeToCluster(this.m_mailboxServerName));
     if (this.m_clusDag.CnoName != string.Empty)
     {
         this.m_output.WriteProgressSimple(Strings.DagTaskFixingUpIpResources);
         List <AmServerName>        source     = this.m_clusDag.EnumerateNodeNames().ToList <AmServerName>();
         IEnumerable <AmServerName> enumerable = from name in source
                                                 where name != this.m_mailboxAmServerName
                                                 select name;
         IEnumerable <string> source2 = from serverName in enumerable
                                        select serverName.NetbiosName;
         this.m_output.AppendLogMessage("Refreshing the cluster using the names [{0}].", new object[]
         {
             string.Join(", ", source2.ToArray <string>())
         });
         this.m_clusDag.Dispose();
         MultiValuedProperty <IPAddress> databaseAvailabilityGroupIpv4Addresses = this.m_dag.DatabaseAvailabilityGroupIpv4Addresses;
         IPAddress[] array = new IPAddress[0];
         if (databaseAvailabilityGroupIpv4Addresses.Count > 0)
         {
             array = databaseAvailabilityGroupIpv4Addresses.ToArray();
         }
         string[] value = (from addr in array
                           select addr.ToString()).ToArray <string>();
         this.m_output.AppendLogMessage("Got the following IP addresses for the DAG (blank means DHCP): {0}", new object[]
         {
             string.Join(",", value)
         });
         this.m_clusDag = AmCluster.OpenByNames(enumerable);
         using (IAmClusterGroup amClusterGroup2 = this.m_clusDag.FindCoreClusterGroup())
         {
             using (IAmClusterResource amClusterResource = amClusterGroup2.FindResourceByTypeName("Network Name"))
             {
                 this.m_output.AppendLogMessage("Cluster group net name = '{0}'.", new object[]
                 {
                     amClusterResource.Name
                 });
                 LocalizedString value2 = AmClusterResourceHelper.FixUpIpAddressesForNetName(this.m_output, this.m_clusDag, (AmClusterGroup)amClusterGroup2, (AmClusterResource)amClusterResource, array);
                 this.m_output.WriteProgressSimple(Strings.DagTaskFixedUpIpResources(value2));
             }
         }
     }
 }
        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();
        }
示例#7
0
        private List <string> JoinStartedNodes(IEnumerable <Server> serversToStart)
        {
            if (serversToStart == null)
            {
                throw new ArgumentNullException("serversToStart");
            }
            List <string> list = new List <string>(1);

            using (AmCluster amCluster = AmCluster.OpenDagClus(this.m_dag))
            {
                using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup())
                {
                    try
                    {
                        using (DumpClusterTopology dumpClusterTopology = new DumpClusterTopology(amCluster, this.m_output))
                        {
                            dumpClusterTopology.Dump();
                        }
                    }
                    catch (ClusterException ex)
                    {
                        this.m_output.AppendLogMessage("DumpClusterTopology( {0} ) failed with exception = {1}. This is OK.", new object[]
                        {
                            this.m_dag.Name,
                            ex.Message
                        });
                        this.m_output.AppendLogMessage("Ignoring previous error, as it is acceptable if the cluster does not exist yet.", new object[0]);
                    }
                    AmServerName ownerNode = amClusterGroup.OwnerNode;
                    DatabaseTasksHelper.CheckReplayServiceRunningOnNode(ownerNode, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    if (amCluster.CnoName != string.Empty)
                    {
                        using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
                        {
                            DagTaskHelper.LogCnoState(this.m_output, this.m_dag.Name, amClusterResource);
                        }
                    }
                    foreach (Server server in serversToStart)
                    {
                        bool         flag         = false;
                        AmServerName amServerName = new AmServerName(server);
                        try
                        {
                            if (amCluster.IsEvictedBasedOnMemberShip(amServerName))
                            {
                                this.m_output.WriteProgressSimple(Strings.ProgressJoinNode(amServerName.NetbiosName));
                                this.m_output.AppendLogMessage("ForceCleanup the Node {0}", new object[]
                                {
                                    server.Name
                                });
                                DatabaseAvailabilityGroupAction.ForceCleanupOneNodeLocally(this.m_dag.Name, server, TimeSpan.FromSeconds(15.0), this.m_output);
                                this.m_output.AppendLogMessage("Join the node {0} to the cluster", new object[]
                                {
                                    server.Name
                                });
                                DatabaseAvailabilityGroupAction.JoinOneNode(ownerNode, amServerName, this.m_output);
                                flag = true;
                            }
                            else
                            {
                                this.m_output.AppendLogMessage("{0} is not evicted", new object[]
                                {
                                    amServerName
                                });
                            }
                            if (!AmCluster.IsRunning(amServerName))
                            {
                                try
                                {
                                    this.m_output.AppendLogMessage("{0} cluster service is not running, try to start the service", new object[]
                                    {
                                        server.Name
                                    });
                                    this.m_output.WriteProgressSimple(Strings.ProgressStartClussvc(amServerName.NetbiosName));
                                    DatabaseAvailabilityGroupAction.TryStartClussvcOnNode(amServerName, this.m_output);
                                }
                                catch (InvalidOperationException)
                                {
                                    this.m_output.AppendLogMessage("Got an invalidOperationException, most likely the node {0} is force cleanedup", new object[]
                                    {
                                        amServerName
                                    });
                                    if (flag)
                                    {
                                        this.m_output.AppendLogMessage("STRANGE! we joined {0} but cannot start the service!", new object[]
                                        {
                                            amServerName
                                        });
                                        throw;
                                    }
                                    this.m_output.WriteProgressSimple(Strings.ProgressJoinNode(amServerName.NetbiosName));
                                    DatabaseAvailabilityGroupAction.JoinForceCleanupNode(ownerNode, amServerName, this.m_output);
                                    flag = true;
                                }
                            }
                            if (flag)
                            {
                                ICollection <AmServerName> startedMailboxServers = from server1 in this.m_dag.StartedMailboxServers
                                                                                   select new AmServerName(server1);
                                DatabaseAvailabilityGroupAction.FixIPAddress(new AmServerName(server.Fqdn), this.m_dag, startedMailboxServers, this.m_output);
                            }
                        }
                        catch (LocalizedException ex2)
                        {
                            this.m_output.WriteWarning(Strings.FailedToJoinNode(server.Name, this.m_dag.Name, ex2.Message));
                            list.Add(server.Name);
                        }
                        catch (InvalidOperationException ex3)
                        {
                            this.m_output.WriteWarning(Strings.FailedToJoinNode(server.Name, this.m_dag.Name, ex3.Message));
                            list.Add(server.Name);
                        }
                    }
                }
            }
            return(list);
        }