protected override void InternalProcessRecord() { Dictionary <AmServerName, Server> dictionary = new Dictionary <AmServerName, Server>(16); if (this.m_mailboxServer != null) { AmServerName serverName = new AmServerName(this.m_mailboxServer.Fqdn); if (!this.m_serversInDag.Keys.Any((AmServerName serverInDag) => serverInDag.Equals(serverName))) { this.m_output.WriteErrorSimple(new DagTaskServerIsNotInDagException(serverName.Fqdn, this.m_dag.Name)); } dictionary.Add(serverName, this.m_mailboxServer); if (base.NeedToUpdateAD) { if (!this.m_stoppedServers.ContainsKey(serverName)) { this.m_stoppedServers.Add(serverName, this.m_mailboxServer); this.m_output.AppendLogMessage("{0} added to stopped list", new object[] { serverName.NetbiosName }); } if (this.m_startedServers.ContainsKey(serverName)) { this.m_startedServers.Remove(serverName); this.m_output.AppendLogMessage("{0} removed from started list", new object[] { serverName.NetbiosName }); } } } else { dictionary = DatabaseAvailabilityGroupAction.GetServersInSite(this.m_output, this.m_serversInDag.Values, base.ActiveDirectorySite); if (base.NeedToUpdateAD) { foreach (AmServerName amServerName in dictionary.Keys) { if (!this.m_stoppedServers.ContainsKey(amServerName)) { this.m_output.AppendLogMessage("add {0} to stopped list", new object[] { amServerName.NetbiosName }); this.m_stoppedServers.Add(amServerName, this.m_serversInDag[amServerName]); } if (this.m_startedServers.ContainsKey(amServerName)) { this.m_output.AppendLogMessage("Remove {0} from started list", new object[] { amServerName.NetbiosName }); this.m_startedServers.Remove(amServerName); } } } } if (base.NeedToUpdateAD) { this.m_dag.StoppedMailboxServers = DatabaseAvailabilityGroupAction.ServerListToFqdnList(this.m_stoppedServers.Keys); this.m_dag.StartedMailboxServers = DatabaseAvailabilityGroupAction.ServerListToFqdnList(this.m_startedServers.Keys); this.m_adSession.Save(this.m_dag); this.m_output.AppendLogMessage("updated the started servers list in AD:", new object[0]); foreach (AmServerName amServerName2 in this.m_startedServers.Keys) { this.m_output.AppendLogMessage("\t{0}", new object[] { amServerName2.NetbiosName }); } this.m_output.AppendLogMessage("updated the stopped servers list in AD:", new object[0]); foreach (AmServerName amServerName3 in this.m_stoppedServers.Keys) { this.m_output.AppendLogMessage("\t{0}", new object[] { amServerName3.NetbiosName }); } base.ForceADReplication(); } if (base.NeedToUpdateCluster) { if (DatabaseAvailabilityGroupAction.IsClusterUp(this.m_dag, this.m_output)) { DatabaseAvailabilityGroupAction.EvictStoppedNodes(this.m_dag, dictionary.Values, this.m_output); } else { DatabaseAvailabilityGroupAction.ForceCleanupStoppedNodes(this.m_dag, dictionary.Values, TimeSpan.FromSeconds(15.0), this.m_output); } TimeSpan timeout = TimeSpan.FromSeconds(1.0); foreach (AmServerName amServerName4 in dictionary.Keys) { this.m_output.AppendLogMessage("notify replayservice on {0} with consensus state 0", new object[] { amServerName4.NetbiosName }); AmRpcClientHelper.RpcchSetAutomountConsensusStateBestEffort(amServerName4.Fqdn, 0, timeout); } } base.InternalProcessRecord(); }
protected override void InternalProcessRecord() { Dictionary <AmServerName, Server> dictionary = new Dictionary <AmServerName, Server>(16); if (this.m_mailboxServer != null) { AmServerName serverName = new AmServerName(this.m_mailboxServer.Fqdn); if (!this.m_serversInDag.Keys.Any((AmServerName serverInDag) => serverInDag.Equals(serverName))) { this.m_output.WriteErrorSimple(new DagTaskServerIsNotInDagException(serverName.Fqdn, this.m_dag.Name)); } dictionary.Add(serverName, this.m_mailboxServer); if (base.NeedToUpdateAD) { if (this.m_stoppedServers.ContainsKey(serverName)) { this.m_stoppedServers.Remove(serverName); this.m_output.AppendLogMessage("{0} removed from stopped list", new object[] { serverName.NetbiosName }); } if (!this.m_startedServers.ContainsKey(serverName)) { this.m_startedServers.Add(serverName, this.m_mailboxServer); this.m_output.AppendLogMessage("{0} added to started list", new object[] { serverName.NetbiosName }); } } } else { dictionary = DatabaseAvailabilityGroupAction.GetServersInSite(this.m_output, this.m_serversInDag.Values, base.ActiveDirectorySite); if (base.NeedToUpdateAD) { foreach (AmServerName amServerName in dictionary.Keys) { if (this.m_stoppedServers.ContainsKey(amServerName)) { this.m_output.AppendLogMessage("Remove {0} from stopped list", new object[] { amServerName.NetbiosName }); this.m_stoppedServers.Remove(amServerName); } if (!this.m_startedServers.ContainsKey(amServerName)) { this.m_output.AppendLogMessage("Add {0} to started list", new object[] { amServerName.NetbiosName }); this.m_startedServers.Add(amServerName, this.m_serversInDag[amServerName]); } } } } if (base.NeedToUpdateAD) { this.m_output.WriteProgressSimple(Strings.ProgressStopUpdateAD); this.m_dag.StoppedMailboxServers = DatabaseAvailabilityGroupAction.ServerListToFqdnList(this.m_stoppedServers.Keys); this.m_adSession.Save(this.m_dag); this.m_output.AppendLogMessage("Updated stopped list with :", new object[0]); foreach (AmServerName amServerName2 in this.m_stoppedServers.Keys) { this.m_output.AppendLogMessage("\t{0}", new object[] { amServerName2.NetbiosName }); } this.m_output.WriteProgressSimple(Strings.ProgressStopUpdateOtherAD); base.ForceADReplication(); } List <string> errorServers = null; if (base.NeedToUpdateCluster) { errorServers = this.JoinStartedNodes(dictionary.Values); if (base.NeedToUpdateAD) { IEnumerable <AmServerName> enumerable = new List <AmServerName>(1); enumerable = from server in this.m_startedServers.Keys where !errorServers.Contains(server.NetbiosName, StringComparer.OrdinalIgnoreCase) select server; this.m_output.WriteProgressSimple(Strings.ProgressStartUpdateAD); this.m_dag.StartedMailboxServers = DatabaseAvailabilityGroupAction.ServerListToFqdnList(enumerable); this.m_adSession.Save(this.m_dag); this.m_output.AppendLogMessage("Updated started list with :", new object[0]); foreach (AmServerName amServerName3 in enumerable) { this.m_output.AppendLogMessage("\t{0}", new object[] { amServerName3.NetbiosName }); } this.m_output.WriteProgressSimple(Strings.ProgressStartUpdateOtherAD); base.ForceADReplication(); if (errorServers.Count != 0) { this.m_output.WriteErrorSimple(new FailedToStartNodeException(string.Join(",", errorServers.ToArray <string>()), this.m_dag.Name)); } } this.SetAutomountConsensusOnStartedServers(dictionary); } base.InternalProcessRecord(); this.m_output.WriteProgressSimple(Strings.ProgressTaskComplete); }