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(); }
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); } } }