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); } } } } }
private void DeleteLastLogGenerationTimeStamps(AmCluster cluster, IEnumerable <Server> stoppedServers, HaTaskOutputHelper output) { output.AppendLogMessage("Deleting last log generation time stamps of all databases on stopped servers...", new object[0]); List <Database> list = new List <Database>(100); foreach (Server server in stoppedServers) { output.AppendLogMessage("Finding all databases on stopped server '{0}'...", new object[] { server.Fqdn }); new AmServerName(server); Database[] databases = server.GetDatabases(); list.AddRange(databases); } if (list.Count == 0) { output.AppendLogMessage("No databases were found on the stopped servers. Skipping time stamp deletion.", new object[0]); return; } output.AppendLogMessage("Found {0} databases on the stopped servers.", new object[] { list.Count }); ClusterBatchLastLogGenDeleter clusterBatchLastLogGenDeleter = new ClusterBatchLastLogGenDeleter(cluster, list, output); clusterBatchLastLogGenDeleter.DeleteTimeStamps(); output.AppendLogMessage("Finished deleting last log generation time stamps on stopped servers.", new object[0]); }
internal static bool IsClusterUp(DatabaseAvailabilityGroup dag, HaTaskOutputHelper output) { try { using (AmCluster amCluster = AmCluster.OpenDagClus(dag)) { using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup()) { IEnumerable <AmServerName> source = amCluster.EnumerateNodeNames(); output.AppendLogMessage("Cluster is up, there are {0} nodes in the cluster, group owner:{1}", new object[] { source.Count <AmServerName>(), amClusterGroup.OwnerNode.NetbiosName }); } } } catch (AmCoreGroupRegNotFound amCoreGroupRegNotFound) { output.AppendLogMessage("Cluster is down, got AmCoreGroupRegNotFound:{0} when trying to open the cluster", new object[] { amCoreGroupRegNotFound.ToString() }); return(false); } return(true); }
// Token: 0x06001BDB RID: 7131 RVA: 0x0007858C File Offset: 0x0007678C private void UpdateClusdbInternal(Dictionary <string, string> tmpClusdbUpdates, out string lastAttemptedOperationName) { lastAttemptedOperationName = "Preparing"; Dictionary <string, string> clusdbUpdates = this.PrepareUpdates(tmpClusdbUpdates); lastAttemptedOperationName = "OpenCluster"; using (AmCluster amCluster = AmCluster.Open()) { lastAttemptedOperationName = "GetClusterKey"; using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(amCluster.Handle, null, null, DxStoreKeyAccessMode.Write, false)) { lastAttemptedOperationName = "OpenAmRootKey"; using (IDistributedStoreKey distributedStoreKey = clusterKey.OpenKey("ExchangeActiveManager", DxStoreKeyAccessMode.Write, false, null)) { lastAttemptedOperationName = "OpenAmRootKey"; using (IDistributedStoreKey distributedStoreKey2 = distributedStoreKey.OpenKey("LastLog", DxStoreKeyAccessMode.CreateIfNotExist, false, null)) { lastAttemptedOperationName = "CreateBatch"; using (IDistributedStoreBatchRequest distributedStoreBatchRequest = distributedStoreKey2.CreateBatchUpdateRequest()) { lastAttemptedOperationName = "PopulateBatch"; this.PopulateBatch(distributedStoreKey2, distributedStoreBatchRequest, clusdbUpdates); lastAttemptedOperationName = "ExecuteBatch"; distributedStoreBatchRequest.Execute(null); } } } } } }
internal bool IsKeyExist(string keyName, AmCluster cluster = null) { bool result = false; bool flag = false; if (cluster == null) { cluster = AmCluster.Open(); flag = true; } try { using (IDistributedStoreKey clusterKey = this.GetClusterKey(cluster.Handle, null, null, DxStoreKeyAccessMode.Read, true)) { if (clusterKey != null) { using (IDistributedStoreKey distributedStoreKey = clusterKey.OpenKey(keyName, DxStoreKeyAccessMode.Read, true, null)) { result = (distributedStoreKey != null); } } } } finally { if (flag && cluster != null) { cluster.Dispose(); } } return(result); }
private void ReopenClusterIfNecessary() { if (this.m_removeNode) { this.m_clusDag.Dispose(); this.CheckServerDagAdSettings(); IEnumerable <AmServerName> enumerable = from server in this.m_serversInDag where !SharedHelper.StringIEquals(server.Fqdn, this.m_mailboxAmServerName.Fqdn) select new AmServerName(server.Fqdn); try { IEnumerable <string> source = from serverName in enumerable select serverName.NetbiosName; this.m_output.AppendLogMessage("Reopening a handle to the cluster using the names [{0}].", new object[] { string.Join(", ", source.ToArray <string>()) }); this.m_clusDag = AmCluster.OpenByNames(enumerable); } catch (ClusterException) { this.m_output.WriteErrorSimple(new DagTaskClusteringMustBeInstalledAndRunningException(this.m_mailboxServerName)); } } }
public static HungNodesInfo GetNodesHungInClusDbUpdate() { HungNodesInfo result = null; TimeSpan timeout = TimeSpan.FromSeconds((double)RegistryParameters.OpenClusterTimeoutInSec); using (AmCluster amCluster = AmCluster.OpenByName(AmServerName.LocalComputerName, timeout, string.Empty)) { int num = 0; AmServerName currentGumLockOwnerInfo = amCluster.GetCurrentGumLockOwnerInfo(out num); if (!AmServerName.IsNullOrEmpty(currentGumLockOwnerInfo)) { Thread.Sleep(RegistryParameters.ClusdbHungNodesConfirmDurationInMSec); string context = string.Format("GUM={0}", num); using (AmCluster amCluster2 = AmCluster.OpenByName(currentGumLockOwnerInfo, timeout, context)) { using (IAmClusterNode amClusterNode = amCluster2.OpenNode(currentGumLockOwnerInfo)) { int num2 = 0; long hungNodesMask = amClusterNode.GetHungNodesMask(out num2); if (num != num2) { throw new HungDetectionGumIdChangedException(num, num2, currentGumLockOwnerInfo.ToString(), hungNodesMask); } result = new HungNodesInfo(num, currentGumLockOwnerInfo, hungNodesMask); } } } } return(result); }
internal static Dictionary <string, AmNodeState> QueryClusterNodeStatus(TimeSpan timeout, bool logEvent = true) { Dictionary <string, AmNodeState> states = new Dictionary <string, AmNodeState>(StringComparer.OrdinalIgnoreCase); Task task = new Task(delegate() { try { using (AmCluster amCluster = AmCluster.Open()) { if (amCluster != null && amCluster.Nodes != null && amCluster.Nodes.Count <IAmClusterNode>() > 0) { foreach (IAmClusterNode amClusterNode in amCluster.Nodes) { states[amClusterNode.Name.NetbiosName] = amClusterNode.GetState(false); } } } } catch (Exception ex) { ExTraceGlobals.LatencyCheckerTracer.TraceDebug <string>(0L, "Exception caught in QueryClusterNodeStatus, ex={0}", ex.ToString()); } }); if (logEvent) { ReplayCrimsonEvents.HungNodeClusterInfoGatherStart.Log <string>(AmServerName.LocalComputerName.NetbiosName); } task.Start(); task.Wait(timeout); return(states); }
public DumpClusterTopology(AmCluster cluster, ITaskOutputHelper output) { this.m_ownsClusterHandle = true; base..ctor(); this.m_nodeNameToConnect = "<existing cluster handle>"; this.m_output = output; this.m_indentlevel = 0U; this.m_cluster = cluster; this.m_ownsClusterHandle = false; }
public DumpClusterTopology(string nameCluster, ITaskOutputHelper output) { this.m_ownsClusterHandle = true; base..ctor(); this.m_nodeNameToConnect = nameCluster; this.m_output = output; this.m_indentlevel = 0U; Exception ex = null; try { if (string.IsNullOrEmpty(nameCluster)) { this.WriteLine("DumpClusterTopology: Opening local cluster.", new object[0]); this.m_cluster = AmCluster.Open(); } else { this.WriteLine("DumpClusterTopology: Opening remote cluster {0}.", new object[] { nameCluster }); AmServerName serverName = new AmServerName(nameCluster); this.m_cluster = AmCluster.OpenByName(serverName); } } catch (ClusterException ex2) { ex = ex2; } catch (AmCommonTransientException ex3) { ex = ex3; } catch (AmCommonException ex4) { ex = ex4; } catch (TransientException ex5) { ex = ex5; } if (ex != null) { this.WriteLine("DumpClusterTopology: Failed opening with {0}", new object[] { ex }); } }
private ClusterDB(AmServerName serverName) { using (DisposeGuard disposeGuard = default(DisposeGuard)) { disposeGuard.Add <ClusterDB>(this); this.isInstalled = AmCluster.IsInstalled(serverName); if (AmCluster.IsRunning(serverName)) { this.amCluster = AmCluster.OpenByName(serverName); this.rootHandle = DistributedStore.Instance.GetClusterKey(this.amCluster.Handle, null, serverName.Fqdn, DxStoreKeyAccessMode.Read, false); this.openWriteBatches = new List <ClusterDB.WriteBatch>(10); } disposeGuard.Success(); } }
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(); }
protected override void InternalRun() { AmServerName serverName = new AmServerName(base.ServerName); if (DagHelper.IsNodeClustered(serverName)) { try { this.m_Cluster = AmCluster.OpenByName(serverName); if (this.m_Cluster == null) { base.Fail(Strings.CouldNotConnectToCluster(base.ServerName)); } return; } catch (ClusterException ex) { base.Fail(Strings.CouldNotConnectToClusterError(base.ServerName, ex.Message)); return; } } ExTraceGlobals.HealthChecksTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Server {1} is not clustered! Skipping check {0}.", base.Title, base.ServerName); base.Skip(); }
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)); } } } }
public IAmCluster OpenByName(AmServerName serverName) { return(AmCluster.OpenByName(serverName)); }
private void CheckClusterStateForDagServerRemoval() { this.m_output.AppendLogMessage("CheckClusterStateForDagServerRemoval entered. m_removeNode={0}, m_destroyCluster={1}", new object[] { this.m_removeNode, this.m_destroyCluster }); try { this.m_clusDag = AmCluster.OpenDagClus(this.m_dag); } catch (AmClusterException ex) { this.m_output.AppendLogMessage("Trying to open the cluster on the servers in the DAG '{0}' failed with exception {1}", new object[] { this.m_dagName, ex }); this.m_output.WriteErrorSimple(new DagTaskRemoveDagServerMustHaveQuorumException(this.m_dagName)); } using (DumpClusterTopology dumpClusterTopology = new DumpClusterTopology(this.m_clusDag, this.m_output)) { dumpClusterTopology.Dump(); } this.m_output.AppendLogMessage("Trying to open the node on the cluster.", new object[0]); IAmClusterNode amClusterNode = null; try { amClusterNode = this.m_clusDag.OpenNode(this.m_mailboxAmServerName); } catch (ClusterException ex2) { this.m_output.AppendLogMessage("OpenNode threw an exception. It's probably because the server is no longer clustered. Proceeding with -configurationonly.", new object[0]); this.m_output.AppendLogMessage("For the records, the exception was {0}.", new object[] { ex2 }); this.m_configurationOnly = true; this.m_mailboxServerIsDown = true; return; } using (amClusterNode) { AmNodeState state = amClusterNode.GetState(false); this.m_output.AppendLogMessage("Node.GetState( {0} ) reports that it is {1}.", new object[] { this.m_mailboxAmServerName, state }); if (!AmClusterNode.IsNodeUp(state)) { this.m_mailboxServerIsDown = true; } } if (!this.m_skipDagValidation) { try { DagTaskHelper.ValidateDagClusterMembership(this.m_output, this.m_dag, this.m_clusDag, this.m_mailboxAmServerName); } catch (ClusterException ex3) { this.DagTrace("ValidateDagClusterMembership() for the mailbox server failed possibly with error {0}, ex = {1}. This is OK.", new object[] { LocalizedException.GenerateErrorCode(ex3.InnerException).ToString(), ex3.Message }); } } int num = this.m_clusDag.EnumerateNodeNames().Count <AmServerName>(); this.DagTrace(string.Format("There are {0} nodes in the cluster.", num), new object[0]); if (num == 1) { this.m_destroyCluster = true; } else { this.m_removeNode = true; } bool destroyCluster = this.m_destroyCluster; this.ReopenClusterIfNecessary(); if ((this.m_removeNode || this.m_destroyCluster) && this.m_dag.DatacenterActivationMode != DatacenterActivationModeOption.Off) { DagTaskHelper.CheckDagCanBeActivatedInDatacenter(this.m_output, this.m_dag, (ADObjectId)this.m_mailboxServer.Identity, (ITopologyConfigurationSession)base.DataSession); } this.DagTrace("CheckClusterStateForDagServerRemoval left. m_removeNode={0}, m_destroyCluster={1}.", new object[] { this.m_removeNode, this.m_destroyCluster }); }
// Token: 0x0600075F RID: 1887 RVA: 0x000240C5 File Offset: 0x000222C5 public IAmCluster Open() { return(AmCluster.Open()); }
protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(new object[] { dataObject.Identity, dataObject }); DatabaseAvailabilityGroup databaseAvailabilityGroup = (DatabaseAvailabilityGroup)dataObject; if (this.Status && !databaseAvailabilityGroup.IsDagEmpty()) { List <ADObjectId> list = new List <ADObjectId>(8); List <ADObjectId> list2 = new List <ADObjectId>(8); AmCluster amCluster = null; try { amCluster = AmCluster.OpenDagClus(databaseAvailabilityGroup); } catch (ClusterException exception) { base.WriteError(exception, ErrorCategory.InvalidArgument, null); } if (amCluster != null) { using (amCluster) { foreach (IAmClusterNode amClusterNode in amCluster.EnumerateNodes()) { using (amClusterNode) { AmNodeState state = amClusterNode.GetState(false); if (AmClusterNode.IsNodeUp(state)) { ADObjectId adobjectId = DagTaskHelper.FindServerAdObjectIdInDag(databaseAvailabilityGroup, amClusterNode.Name); if (adobjectId != null) { list.Add(adobjectId); if (state == AmNodeState.Paused) { list2.Add(adobjectId); } } else { this.WriteWarning(Strings.WarningClusterNodeNotFoundInDag(amClusterNode.Name.Fqdn, databaseAvailabilityGroup.Name)); } } } } databaseAvailabilityGroup.OperationalServers = list.ToArray(); databaseAvailabilityGroup.ServersInMaintenance = list2.ToArray(); DagNetworkConfiguration dagNetworkConfig = DagNetworkRpc.GetDagNetworkConfig(databaseAvailabilityGroup); databaseAvailabilityGroup.ReplicationPort = dagNetworkConfig.ReplicationPort; foreach (DatabaseAvailabilityGroupNetwork databaseAvailabilityGroupNetwork in dagNetworkConfig.Networks) { databaseAvailabilityGroup.NetworkNames.Add(databaseAvailabilityGroupNetwork.Name); } if (DagHelper.IsQuorumTypeFileShareWitness(amCluster)) { IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup(); if (amClusterGroup == null) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningClusterGroupNotFormed(databaseAvailabilityGroup.Name)); goto IL_306; } using (amClusterGroup) { IEnumerable <AmClusterResource> enumerable = null; try { enumerable = amClusterGroup.EnumerateResourcesOfType("File Share Witness"); AmClusterResource amClusterResource = enumerable.ElementAtOrDefault(0); if (amClusterResource == null) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswNotFound(databaseAvailabilityGroup.Name)); } else if (amClusterResource.GetState() == AmResourceState.Failed) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswFailed(databaseAvailabilityGroup.Name)); } else { string privateProperty = amClusterResource.GetPrivateProperty <string>("SharePath"); UncFileSharePath a; if (UncFileSharePath.TryParse(privateProperty, out a)) { if (a == databaseAvailabilityGroup.FileShareWitness) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.Primary); } else if (a == databaseAvailabilityGroup.AlternateFileShareWitness) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.Alternate); } else { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswNotPrimaryOrAlternate(databaseAvailabilityGroup.Name)); } } else { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswNotValidPath(databaseAvailabilityGroup.Name, privateProperty)); } } } finally { if (enumerable != null) { foreach (AmClusterResource amClusterResource2 in enumerable) { using (amClusterResource2) { } } } } goto IL_306; } } databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.None); IL_306:; } this.UpdatePam(databaseAvailabilityGroup); try { DeferredFailoverEntry[] serversInDeferredRecovery = DagTaskHelper.GetServersInDeferredRecovery(databaseAvailabilityGroup); databaseAvailabilityGroup.ServersInDeferredRecovery = serversInDeferredRecovery; } catch (AmServerException ex) { this.WriteWarning(Strings.PAMOtherError(ex.Message)); } } } base.WriteResult(databaseAvailabilityGroup); TaskLogger.LogExit(); }
// Token: 0x06000760 RID: 1888 RVA: 0x000240CC File Offset: 0x000222CC IAmCluster IMockableCluster.OpenByName(AmServerName serverName) { return(AmCluster.OpenByName(serverName)); }
// Token: 0x06000763 RID: 1891 RVA: 0x000240E4 File Offset: 0x000222E4 public bool IsRunning() { return(AmCluster.IsRunning()); }
internal static void EvictStoppedNodes(DatabaseAvailabilityGroup dag, IEnumerable <Server> stoppedServers, HaTaskOutputHelper output) { if (dag == null) { throw new ArgumentNullException("dag"); } if (stoppedServers == null) { throw new ArgumentNullException("stoppedServers"); } if (output == null) { throw new ArgumentNullException("output"); } string error = null; List <string> list = new List <string>(1); string verboseLog = null; using (AmCluster amCluster = AmCluster.OpenDagClus(dag)) { using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup()) { output.AppendLogMessage("EvictStoppedNodes has been called. Dumping current cluster state.", new object[0]); try { using (DumpClusterTopology dumpClusterTopology = new DumpClusterTopology(amCluster, output)) { dumpClusterTopology.Dump(); } } catch (ClusterException ex) { output.AppendLogMessage("DumpClusterTopology( {0} ) failed with exception = {1}. This is OK.", new object[] { dag.Name, ex.Message }); output.AppendLogMessage("Ignoring previous error, as it is acceptable if the cluster does not exist yet.", new object[0]); } IEnumerable <AmServerName> source = amCluster.EnumerateNodeNames(); AmServerName ownerNode = amClusterGroup.OwnerNode; int num = stoppedServers.Count <Server>(); foreach (Server server in stoppedServers) { AmServerName amServerName = new AmServerName(server); if (source.Contains(amServerName)) { output.AppendLogMessage("Server '{0}' is still a node in the cluster, and will have to be evicted.", new object[] { amServerName.NetbiosName }); try { try { output.WriteProgressIncrementalSimple(Strings.ProgressForceCleanupNode(server.Name), 20 / num); output.AppendLogMessage("Running the eviction operation by issuing an RPC to the replay service on '{0}'...", new object[] { ownerNode.Fqdn }); ReplayRpcClientWrapper.RunEvictNodeFromCluster(ownerNode, amServerName, out verboseLog); } finally { DagTaskHelper.LogRemoteVerboseLog(output, ownerNode.Fqdn, verboseLog); } } catch (DagTaskOperationFailedException ex2) { output.AppendLogMessage("An exception was thrown! ex={0}", new object[] { ex2.Message }); Exception ex3; if (ex2.TryGetInnerExceptionOfType(out ex3)) { output.AppendLogMessage("Ignore it. It was AmClusterEvictWithoutCleanupException, which is acceptable. It could be completed with cluster node /forcecleanp, but that isn't necessary.", new object[0]); } else if (ex2.TryGetInnerExceptionOfType(out ex3)) { output.AppendLogMessage("That exception is fine. It means that the server has already been evicted from the cluster.", new object[0]); } else { error = ex2.Message; output.WriteWarning(Strings.FailedToEvictNode(server.Name, dag.Name, error)); list.Add(server.Name); } } catch (LocalizedException ex4) { error = ex4.Message; output.WriteWarning(Strings.FailedToEvictNode(server.Name, dag.Name, error)); list.Add(server.Name); } } else { output.AppendLogMessage("Server '{0}' is not in the cluster anymore. It must have already been evicted.", new object[] { amServerName.NetbiosName }); } } } } if (list.Count != 0) { output.WriteErrorSimple(new FailedToEvictNodeException(string.Join(",", list.ToArray <string>()), dag.Name, error)); } }
// Token: 0x06000765 RID: 1893 RVA: 0x000240F3 File Offset: 0x000222F3 public IAmCluster CreateExchangeCluster(string clusterName, AmServerName firstNodeName, string[] ipAddress, uint[] ipPrefixLength, IClusterSetupProgress setupProgress, IntPtr context, out Exception failureException, bool throwExceptionOnFailure) { return(AmCluster.CreateExchangeCluster(clusterName, firstNodeName, ipAddress, ipPrefixLength, setupProgress, context, out failureException, throwExceptionOnFailure)); }
// Token: 0x06000764 RID: 1892 RVA: 0x000240EB File Offset: 0x000222EB public bool IsEvicted(AmServerName machineName) { return(AmCluster.IsEvicted(machineName)); }
// Token: 0x060001B9 RID: 441 RVA: 0x0000806D File Offset: 0x0000626D internal IEnumerable <AmClusterNetInterface> EnumerateNetworkInterfaces() { return(AmCluster.EvaluateAllElements <AmClusterNetInterface>(this.LazyEnumerateNetworkInterfaces())); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); this.m_output = new HaTaskOutputHelper("set-databaseavailabilitygroup", new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskProgressLoggingDelegate(base.WriteProgress), this.GetHashCode()); this.m_dag = this.DataObject; this.m_skipDagValidation = this.SkipDagValidation; DagTaskHelper.VerifyDagAndServersAreWithinScopes <DatabaseAvailabilityGroup>(this, this.m_dag, true); if (this.DatabaseAvailabilityGroupIpAddresses != null) { if (!this.m_dag.IsDagEmpty()) { this.PrepareServersInDagIfRequired(); foreach (AmServerName amServerName in this.m_serverNamesInDag) { DagTaskHelper.ValidateIPAddressList(this.m_output, amServerName.NetbiosName, this.DatabaseAvailabilityGroupIpAddresses, this.m_dag.Name); DagTaskHelper.ValidateIPAddressList(this.m_output, amServerName.Fqdn, this.DatabaseAvailabilityGroupIpAddresses, this.m_dag.Name); } } foreach (IPAddress ipaddress in this.DatabaseAvailabilityGroupIpAddresses) { if (ipaddress.AddressFamily == AddressFamily.InterNetworkV6) { this.m_output.WriteErrorSimple(new DagTaskDagIpAddressesMustBeIpv4Exception()); } } } this.m_useAlternateWitnessServer = (this.m_dag.AlternateWitnessServer != null && DagTaskHelper.IsDagFailedOverToOtherSite(this.m_output, this.m_dag)); if (!this.m_useAlternateWitnessServer) { this.m_fsw = new FileShareWitness((ITopologyConfigurationSession)base.DataSession, this.m_dag.Name, this.WitnessServer ?? this.m_dag.WitnessServer, this.WitnessDirectory ?? this.m_dag.WitnessDirectory); try { this.m_fsw.Initialize(); } catch (LocalizedException error) { this.m_output.WriteErrorSimple(error); } this.CheckFsw(this.m_fsw.WitnessServerFqdn); } if (this.AlternateWitnessServer != null || this.AlternateWitnessDirectory != null || (this.m_dag.AlternateWitnessServer != null && this.m_dag.AlternateWitnessDirectory != null && !this.m_alternateWitnessServerParameterSpecified) || this.m_useAlternateWitnessServer) { this.m_afsw = new FileShareWitness((ITopologyConfigurationSession)base.DataSession, this.m_dag.Name, this.AlternateWitnessServer ?? this.m_dag.AlternateWitnessServer, this.AlternateWitnessDirectory ?? this.m_dag.AlternateWitnessDirectory); try { this.m_afsw.Initialize(); } catch (LocalizedException error2) { this.m_output.WriteErrorSimple(error2); } if (this.m_fsw != null && SharedHelper.StringIEquals(this.m_afsw.WitnessServerFqdn, this.m_fsw.WitnessServerFqdn) && this.m_fsw.WitnessDirectory != this.m_afsw.WitnessDirectory) { this.m_output.WriteErrorSimple(new DagFswAndAlternateFswOnSameWitnessServerButPointToDifferentDirectoriesException(this.m_fsw.WitnessServer.ToString(), this.m_fsw.WitnessDirectory.ToString(), this.m_afsw.WitnessDirectory.ToString())); } this.CheckFsw(this.m_afsw.WitnessServerFqdn); } Dictionary <AmServerName, Server> startedServers = new Dictionary <AmServerName, Server>(); DatabaseAvailabilityGroupAction.ResolveServers(this.m_output, this.m_dag, this.m_allServers, startedServers, this.m_stoppedServers); if (!this.m_dag.IsDagEmpty()) { this.PrepareServersInDagIfRequired(); List <AmServerName> list = new List <AmServerName>(this.m_stoppedServers.Count); IEnumerable <AmServerName> serversInCluster = null; foreach (Server server in this.m_stoppedServers.Values) { list.Add(new AmServerName(server.Id)); } using (AmCluster amCluster = AmCluster.OpenDagClus(this.m_dag)) { serversInCluster = amCluster.EnumerateNodeNames(); } if (!this.m_skipDagValidation) { DagTaskHelper.CompareDagClusterMembership(this.m_output, this.m_dag.Name, this.m_serverNamesInDag, serversInCluster, list); } } if (base.Fields["DatacenterActivationMode"] != null && this.DatacenterActivationMode != DatacenterActivationModeOption.Off) { DagTaskHelper.CheckDagCanBeActivatedInDatacenter(this.m_output, this.m_dag, null, (ITopologyConfigurationSession)base.DataSession); } if (base.Fields["DatacenterActivationMode"] != null && this.DatacenterActivationMode == DatacenterActivationModeOption.Off) { this.DataObject.StartedMailboxServers = null; this.DataObject.StoppedMailboxServers = null; } TaskLogger.LogExit(); }
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(); }
// Token: 0x0600023E RID: 574 RVA: 0x0000A68A File Offset: 0x0000888A internal IEnumerable <IAmClusterNode> EnumeratePossibleOwnerNodes() { return(AmCluster.EvaluateAllElements <IAmClusterNode>(this.LazyEnumeratePossibleOwnerNodes())); }
// Token: 0x06000761 RID: 1889 RVA: 0x000240D4 File Offset: 0x000222D4 IAmCluster IClusterFactory.OpenByName(AmServerName serverName) { return(AmCluster.OpenByName(serverName)); }
// Token: 0x06000240 RID: 576 RVA: 0x0000A6A5 File Offset: 0x000088A5 internal IEnumerable <AmClusterResource> EnumerateDependents() { return(AmCluster.EvaluateAllElements <AmClusterResource>(this.LazyEnumerateDependents())); }
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); } } }