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); }
// Token: 0x06000144 RID: 324 RVA: 0x00007834 File Offset: 0x00005A34 internal AmNodeState GetNodeState(AmServerName nodeName) { AmNodeState result = AmNodeState.Unknown; try { IAmClusterNode amClusterNode2; IAmClusterNode amClusterNode = amClusterNode2 = this.Cluster.OpenNode(nodeName); try { result = amClusterNode.State; } finally { if (amClusterNode2 != null) { amClusterNode2.Dispose(); } } } catch (ClusterException ex) { AmTrace.Error("Failed to open cluster node {0} (error={1})", new object[] { nodeName, ex.Message }); } return(result); }
protected override bool RunIndividualCheck(IAmClusterNode node) { base.InstanceIdentity = node.Name.NetbiosName; AmNodeState state = node.GetState(false); if (state == AmNodeState.Paused) { base.FailContinue(Strings.DagMemberPausedFailed(node.Name.NetbiosName, this.m_dag.Name)); return(false); } return(true); }
protected override bool RunIndividualCheck(IAmClusterNode node) { base.InstanceIdentity = node.Name.NetbiosName; AmNodeState state = node.GetState(false); if ((state == AmNodeState.Down || state == AmNodeState.Joining || state == AmNodeState.Unknown) && !base.IsNodeStopped(node.Name)) { base.FailContinue(Strings.DagMemberUpCheckFailed(node.Name.NetbiosName, this.m_dag.Name)); return(false); } return(true); }
protected override void InternalRun() { AmServerName serverName = new AmServerName(base.ServerName); if (DagHelper.IsNodeClustered(serverName)) { if (!IgnoreTransientErrors.HasPassed(base.GetDefaultErrorKey(typeof(ClusterRpcCheck)))) { ExTraceGlobals.HealthChecksTracer.TraceDebug <string>((long)this.GetHashCode(), "ClusterRpcCheck didn't pass! Skipping check {0}.", base.Title); base.Skip(); } if (this.m_fClusterLevelCheck) { this.RunCheck(); return; } using (IEnumerator <AmServerName> enumerator = this.Cluster.EnumerateNodeNames().GetEnumerator()) { while (enumerator.MoveNext()) { AmServerName amServerName = enumerator.Current; try { if (this.IsNodeMemberOfDag(amServerName, this.m_dag)) { using (IAmClusterNode amClusterNode = this.Cluster.OpenNode(amServerName)) { if (this.RunIndividualCheck(amClusterNode)) { base.ReportPassedInstance(); } continue; } } ExTraceGlobals.HealthChecksTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Cluster node {0} is not a member of DAG {1} so check will not run here.", amServerName.NetbiosName, this.m_dag.Name); } finally { base.InstanceIdentity = null; } } return; } } ExTraceGlobals.HealthChecksTracer.TraceDebug <string>((long)this.GetHashCode(), "Local machine is not clustered! Skipping check {0}.", base.Title); base.Skip(); }
public void MoveGroup(TimeSpan timeout, AmServerName destinationNode) { DateTime t = DateTime.UtcNow.Add(timeout); uint num = 0U; AmGroupState amGroupState; AmServerName amServerName; this.GetStateAndOwningNode(out amGroupState, out amServerName); using (IAmClusterNode amClusterNode = this.OwningCluster.OpenNode(destinationNode)) { num = ClusapiMethods.MoveClusterGroup(this.Handle, amClusterNode.Handle); goto IL_87; } IL_4B: AmGroupState amGroupState2; AmServerName amServerName2; this.GetStateAndOwningNode(out amGroupState2, out amServerName2); if (amGroupState == amGroupState2) { num = 0U; goto IL_9C; } ExTraceGlobals.ClusterTracer.TraceDebug <string, AmGroupState, AmGroupState>((long)this.GetHashCode(), "MoveGroup: {0} is in progress (initial={1}, current={2}), waiting and polling again.", this.Name, amGroupState, amGroupState2); Thread.Sleep(1000); IL_87: if (num == 997U && DateTime.UtcNow < t) { goto IL_4B; } IL_9C: if (num != 0U) { throw AmExceptionHelper.ConstructClusterApiException((int)num, "MoveClusterGroup( name={0}, dest={1})", new object[] { this.Name, destinationNode.NetbiosName }); } }
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)); } } } }
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 }); }
public ClusterNode(IAmClusterNode clusNode) { this.Name = clusNode.Name; this.ClusterState = clusNode.GetState(false); }
private void RecalculateAccessRules() { if (this.m_accessRules == null) { this.m_accessRules = new List <FileSystemAccessRule>(); } string text = NativeHelpers.GetDomainName(); int num = text.IndexOf('.'); if (num > -1) { text = text.Substring(0, num); } ComparisonFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseAvailabilityGroupSchema.Name, this.m_dagName); DatabaseAvailabilityGroup[] array = this.m_adSession.Find <DatabaseAvailabilityGroup>(null, QueryScope.SubTree, filter, null, 1); if (array == null || array.Length == 0) { this.m_accessRules.Clear(); TaskLogger.Trace("Account {0}$ for witness share \\\\{1}\\{2} does not exist yet, assuming we are working with empty dag, fsw will be created with current user {3} permissions and removed.", new object[] { this.m_dagName, this.WitnessServer, this.ShareName, WindowsIdentity.GetCurrent().User }); FileSystemAccessRule item = new FileSystemAccessRule(WindowsIdentity.GetCurrent().User.Translate(typeof(NTAccount)) as NTAccount, FileSystemRights.FullControl, AccessControlType.Allow); this.m_accessRules.Add(item); return; } MultiValuedProperty <IPAddress> databaseAvailabilityGroupIpAddresses = array[0].DatabaseAvailabilityGroupIpAddresses; bool flag = databaseAvailabilityGroupIpAddresses == null || databaseAvailabilityGroupIpAddresses.Count != 1 || !IPAddress.None.Equals(databaseAvailabilityGroupIpAddresses[0]); if (flag) { bool flag2 = true; if (this.m_accessRules.Count == 1) { if (this.m_accessRules[0].IdentityReference.Value.Contains(this.m_dagName)) { flag2 = false; } else { this.m_accessRules.Clear(); } } if (flag2) { ITopologyConfigurationSession topologyConfigurationSession = this.CreateRootSession(); DateTime t = DateTime.UtcNow.AddMinutes(6.0); ADComputer adcomputer; for (adcomputer = topologyConfigurationSession.FindComputerByHostName(this.m_dagName); adcomputer == null; adcomputer = topologyConfigurationSession.FindComputerByHostName(this.m_dagName)) { if (DateTime.UtcNow > t) { throw new DagUnableToFindCnoException(this.m_dagName); } Thread.Sleep(TimeSpan.FromSeconds(20.0)); } IdentityReference identity = adcomputer.Sid.Translate(typeof(NTAccount)); FileSystemAccessRule item2 = new FileSystemAccessRule(identity, FileSystemRights.FullControl, AccessControlType.Allow); this.m_accessRules.Add(item2); return; } } else { bool flag3 = false; IAmCluster amCluster = null; DatabaseAvailabilityGroup databaseAvailabilityGroup = array[0]; List <AmServerName> list = new List <AmServerName>(); try { if (!this.m_clusterReference.TryGetTarget(out amCluster) || (amCluster is AmCluster && ((AmCluster)amCluster).IsDisposed)) { amCluster = null; foreach (ADObjectId adobjectId in databaseAvailabilityGroup.Servers) { AmServerName amServerName = new AmServerName(adobjectId); if (!databaseAvailabilityGroup.StoppedMailboxServers.Contains(amServerName.Fqdn) && (databaseAvailabilityGroup.ServersInMaintenance == null || !databaseAvailabilityGroup.ServersInMaintenance.Contains(adobjectId))) { amCluster = ClusterFactory.Instance.OpenByName(amServerName); if (amCluster != null) { flag3 = true; break; } } } } if (amCluster != null) { using (IEnumerator <IAmClusterNode> enumerator2 = amCluster.EnumerateNodes().GetEnumerator()) { while (enumerator2.MoveNext()) { IAmClusterNode amClusterNode = enumerator2.Current; list.Add(amClusterNode.Name); } goto IL_352; } } foreach (ADObjectId serverId in databaseAvailabilityGroup.Servers) { list.Add(new AmServerName(serverId)); } IL_352 :; } finally { if (flag3 && amCluster != null) { amCluster.Dispose(); } } this.m_accessRules.Clear(); ITopologyConfigurationSession topologyConfigurationSession2 = this.CreateRootSession(); foreach (AmServerName amServerName2 in list) { ADComputer adcomputer2 = topologyConfigurationSession2.FindComputerByHostName(amServerName2.NetbiosName); IdentityReference identity2 = adcomputer2.Sid.Translate(typeof(NTAccount)); FileSystemAccessRule item3 = new FileSystemAccessRule(identity2, FileSystemRights.FullControl, AccessControlType.Allow); this.m_accessRules.Add(item3); } } }
protected virtual bool RunIndividualCheck(IAmClusterNode node) { return(true); }