示例#1
0
        protected override void InternalProcessRecord()
        {
            this.m_output.WriteProgressIncrementalSimple(Strings.ProgressForceQuorum, 10);
            if (!this.m_isQuorumPresent && !this.ForceQuorumIfNecessary())
            {
                this.m_output.WriteErrorSimple(new DagTaskQuorumNotAchievedException(this.m_dag.Name));
            }
            this.m_output.WriteProgressIncrementalSimple(Strings.ProgressChangeFsw, 20);
            DatabaseAvailabilityGroupAction.EvictStoppedNodes(this.m_dag, this.m_stoppedServers.Values, this.m_output);
            this.ProcessFileShareWitness();
            IEnumerable <AmServerName> amServerNamesFromServers = RestoreDatabaseAvailabilityGroup.GetAmServerNamesFromServers(this.m_startedServers.Values);

            using (AmCluster amCluster = AmCluster.OpenByNames(amServerNamesFromServers))
            {
                bool shouldBeFsw = DagTaskHelper.ShouldBeFileShareWitness(this.m_output, this.m_dag, amCluster, false);
                DagTaskHelper.ChangeQuorumToMnsOrFswAsAppropriate(this.m_output, this, this.m_dag, amCluster, this.m_afsw, this.m_afsw, shouldBeFsw, !this.UsePrimaryWitnessServer);
                this.DeleteLastLogGenerationTimeStamps(amCluster, this.m_stoppedServers.Values, this.m_output);
            }
            this.m_output.WriteProgressIncrementalSimple(Strings.ProgressTaskComplete, 100);
            base.InternalProcessRecord();
        }
示例#2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     this.m_output.WriteProgressSimple(Strings.DagTaskRemovingServerFromDag(this.m_mailboxServerName, this.m_dagName));
     if (!this.m_configurationOnly)
     {
         if (this.m_removeNode)
         {
             this.MovePamIfNeeded();
             bool flag = DagTaskHelper.ShouldBeFileShareWitness(this.m_output, this.m_dag, this.m_clusDag, true);
             if (flag)
             {
                 try
                 {
                     this.m_fsw.Create();
                 }
                 catch (LocalizedException ex)
                 {
                     this.m_output.WriteWarning(ex.LocalizedString);
                 }
                 if (this.m_afsw != null && this.m_afsw.IsInitialized && !this.m_afsw.Equals(this.m_fsw))
                 {
                     try
                     {
                         this.m_afsw.Create();
                     }
                     catch (LocalizedException ex2)
                     {
                         this.m_output.WriteWarning(ex2.LocalizedString);
                     }
                 }
             }
             bool flag2 = DagTaskHelper.IsQuorumTypeFileShareWitness(this.m_output, this.m_clusDag);
             this.m_output.AppendLogMessage("SkipDagValidation = {0}; IsQuorumTypeFSW = {1}; ShouldbeFSW = {2}", new object[]
             {
                 this.m_skipDagValidation,
                 flag2,
                 flag
             });
             if (!this.m_skipDagValidation || (flag && !flag2))
             {
                 DagTaskHelper.ChangeQuorumToMnsOrFswAsAppropriate(this.m_output, this, this.m_dag, this.m_clusDag, this.m_fsw, this.m_afsw, flag, false);
             }
             else
             {
                 this.m_output.AppendLogMessage("Skip setting Quorum type", new object[0]);
             }
             this.RemoveNodeFromCluster();
         }
         else if (this.m_destroyCluster)
         {
             this.DestroyCluster();
             try
             {
                 this.m_fsw.Delete();
             }
             catch (LocalizedException ex3)
             {
                 this.m_output.WriteWarning(ex3.LocalizedString);
             }
             if (this.m_afsw != null && this.m_afsw.IsInitialized && !this.m_afsw.Equals(this.m_fsw))
             {
                 try
                 {
                     this.m_afsw.Delete();
                 }
                 catch (LocalizedException ex4)
                 {
                     this.m_output.WriteWarning(ex4.LocalizedString);
                 }
             }
         }
     }
     this.m_output.WriteProgressSimple(Strings.DagTaskUpdatingAdDagMembership(this.m_mailboxServerName, this.m_dagName));
     base.InternalProcessRecord();
     this.UpdateAdSettings();
     this.m_output.WriteProgressSimple(Strings.DagTaskUpdatedAdDagMembership(this.m_mailboxServerName, this.m_dagName));
     this.m_output.WriteProgressSimple(Strings.DagTaskRemovedServerFromDag(this.m_mailboxServerName, this.m_dagName));
     if (!this.m_configurationOnly)
     {
         this.m_output.WriteProgressSimple(Strings.DagTaskSleepAfterNodeRemoval(60, this.m_dagName, this.m_mailboxServerName));
         Thread.Sleep(60000);
     }
     if (this.m_destroyCluster)
     {
         ITopologyConfigurationSession configSession = (ITopologyConfigurationSession)base.DataSession;
         string dagName = this.m_dagName;
         DagTaskHelper.DisableComputerAccount(this.m_output, configSession, dagName);
     }
     DagTaskHelper.NotifyServerOfConfigChange(this.m_mailboxAmServerName);
     TaskLogger.LogExit();
 }
        private void UpdateFileShareWitness()
        {
            if (this.m_allServers.Count == 0)
            {
                this.m_output.WriteErrorSimple(new DagTaskNoServersAreStartedException(this.m_dag.Name));
            }
            IEnumerable <AmServerName> amServerNamesFromServers = RestoreDatabaseAvailabilityGroup.GetAmServerNamesFromServers(this.m_allServers.Values);

            using (AmCluster amCluster = AmCluster.OpenByNames(amServerNamesFromServers))
            {
                bool   flag            = DagTaskHelper.IsQuorumTypeFileShareWitness(this.m_output, amCluster);
                bool   flag2           = DagTaskHelper.ShouldBeFileShareWitness(this.m_output, this.m_dag, amCluster, false);
                string fswShareCurrent = string.Empty;
                if (flag)
                {
                    using (AmClusterResource amClusterResource = amCluster.OpenQuorumResource())
                    {
                        if (amClusterResource != null)
                        {
                            fswShareCurrent = amClusterResource.GetPrivateProperty <string>("SharePath");
                        }
                    }
                }
                if (flag2)
                {
                    if (this.m_fsw != null)
                    {
                        try
                        {
                            this.m_output.AppendLogMessage("Creating/modififying the primary FSW, if needed.", new object[0]);
                            this.m_fsw.Create();
                            if (this.m_dag.Servers.Count == 0 && this.m_fsw.IsJustCreated)
                            {
                                this.m_fsw.Delete();
                            }
                        }
                        catch (LocalizedException ex)
                        {
                            if (this.m_fsw.GetExceptionType(ex) != FileShareWitnessExceptionType.FswDeleteError)
                            {
                                this.m_output.WriteWarning(ex.LocalizedString);
                            }
                        }
                    }
                    if (this.m_afsw != null && !this.m_afsw.Equals(this.m_fsw))
                    {
                        try
                        {
                            this.m_output.AppendLogMessage("Creating/modififying the alternate FSW, if needed.", new object[0]);
                            this.m_afsw.Create();
                            if (this.m_dag.Servers.Count == 0 && this.m_afsw.IsJustCreated)
                            {
                                this.m_afsw.Delete();
                            }
                        }
                        catch (LocalizedException ex2)
                        {
                            if (this.m_afsw.GetExceptionType(ex2) != FileShareWitnessExceptionType.FswDeleteError)
                            {
                                this.m_output.WriteWarning(ex2.LocalizedString);
                            }
                        }
                    }
                    bool useAlternateWitnessServer = this.m_useAlternateWitnessServer;
                    if (!this.m_skipDagValidation || (flag2 && !flag))
                    {
                        DagTaskHelper.ChangeQuorumToMnsOrFswAsAppropriate(this.m_output, this, this.m_dag, amCluster, this.m_fsw, this.m_afsw, flag2, this.m_useAlternateWitnessServer);
                    }
                }
                else if (!this.m_skipDagValidation && flag)
                {
                    DagTaskHelper.RevertToMnsQuorum(this.m_output, amCluster, fswShareCurrent);
                }
            }
        }