// Token: 0x0600062F RID: 1583 RVA: 0x0001E864 File Offset: 0x0001CA64
        internal static bool CheckIfMajorityNodesReachable(AmServerName[] members, out int totalServersCount, out int successfulReplyCount)
        {
            bool flag = false;

            totalServersCount    = 0;
            successfulReplyCount = 0;
            if (members == null)
            {
                AmLastKnownGoodConfig lastKnownGoodConfig = AmSystemManager.Instance.LastKnownGoodConfig;
                if (lastKnownGoodConfig != null && (lastKnownGoodConfig.Role == AmRole.PAM || lastKnownGoodConfig.Role == AmRole.SAM))
                {
                    members = lastKnownGoodConfig.Members;
                }
            }
            if (members != null && members.Length > 0)
            {
                totalServersCount = members.Length;
                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    stopwatch.Start();
                    AmMultiNodeRoleFetcher amMultiNodeRoleFetcher = new AmMultiNodeRoleFetcher(members.ToList <AmServerName>(), TimeSpan.FromSeconds((double)RegistryParameters.MajorityDecisionRpcTimeoutInSec), true);
                    amMultiNodeRoleFetcher.Run();
                    return(amMultiNodeRoleFetcher.IsMajoritySuccessfulRepliesReceived(out totalServersCount, out successfulReplyCount));
                }
                finally
                {
                    ReplayCrimsonEvents.MajorityNodeCheckCompleted.Log <TimeSpan, bool, int, int>(stopwatch.Elapsed, flag, totalServersCount, successfulReplyCount);
                }
            }
            ReplayCrimsonEvents.MajorityNodeNotAttemptedSinceNoMembersAvailable.Log();
            return(flag);
        }
        // Token: 0x060003FD RID: 1021 RVA: 0x0001596C File Offset: 0x00013B6C
        private void PerformRecoveryInternal()
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsSAM)
            {
                AmServerName currentPAM = config.DagConfig.CurrentPAM;
                if (!AmServerName.IsEqual(this.pamServerInVerificationPhase, currentPAM))
                {
                    ReplayCrimsonEvents.PamMonitorMoveSkippedSinceServerChanged.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, currentPAM);
                    return;
                }
                List <AmServerName>    list = config.DagConfig.MemberServers.ToList <AmServerName>();
                AmMultiNodeRoleFetcher amMultiNodeRoleFetcher = new AmMultiNodeRoleFetcher(list, TimeSpan.FromSeconds((double)RegistryParameters.PamMonitorRoleCheckTimeoutInSec), false);
                amMultiNodeRoleFetcher.Run();
                Dictionary <AmServerName, AmRole> roleMap = amMultiNodeRoleFetcher.RoleMap;
                string text = string.Join("\n", (from kvp in roleMap
                                                 select string.Format("[{0}] => {1}", kvp.Key, kvp.Value)).ToArray <string>());
                ReplayCrimsonEvents.PamMonitorServerRolesView.Log <string>(text);
                int count = list.Count;
                int num   = roleMap.Count((KeyValuePair <AmServerName, AmRole> kvp) => kvp.Value == AmRole.SAM);
                int num2  = count / 2 + 1;
                if (num < num2)
                {
                    ReplayCrimsonEvents.PamMonitorMoveCancelledSinceMinimumRequiredNotMet.Log <int, int, int>(count, num, num2);
                    return;
                }
                List <AmServerName> list2 = new List <AmServerName>(roleMap.Count);
                List <AmServerName> list3 = new List <AmServerName>(roleMap.Count);
                foreach (KeyValuePair <AmServerName, AmRole> keyValuePair in roleMap)
                {
                    if (!this.IsServerDisabled(keyValuePair.Key))
                    {
                        if (keyValuePair.Value == AmRole.PAM)
                        {
                            ReplayCrimsonEvents.PamMonitorMoveSkippedDueToValidResponseFromPAM.Log <AmServerName>(keyValuePair.Key);
                            return;
                        }
                        if (keyValuePair.Value == AmRole.SAM)
                        {
                            if (keyValuePair.Key.CompareTo(currentPAM) > 0)
                            {
                                list2.Add(keyValuePair.Key);
                            }
                            else
                            {
                                list3.Add(keyValuePair.Key);
                            }
                        }
                    }
                }
                list2.Sort();
                list3.Sort();
                AmServerName[] array = new AmServerName[list2.Count + list3.Count];
                list2.CopyTo(array);
                list3.CopyTo(array, list2.Count);
                bool flag = false;
                foreach (AmServerName amServerName in array)
                {
                    if (flag)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(5.0));
                        currentPAM = config.DagConfig.CurrentPAM;
                        if (!AmServerName.IsEqual(this.pamServerInVerificationPhase, currentPAM))
                        {
                            ReplayCrimsonEvents.PamMonitorMoveSkippedSinceServerChanged.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, currentPAM);
                            return;
                        }
                    }
                    try
                    {
                        ReplayCrimsonEvents.PamMonitorBeginsToMovePAM.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, amServerName);
                        AmClusterGroup.MoveClusterGroupWithTimeout(AmServerName.LocalComputerName, amServerName, TimeSpan.FromSeconds((double)RegistryParameters.PamMonitorMoveClusterGroupTimeout));
                        ReplayCrimsonEvents.PamMonitorSuccessfulyMovedPAM.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, amServerName);
                        return;
                    }
                    catch (ClusterException ex)
                    {
                        flag = true;
                        AmTrace.Error("PAM election failed for {0} : {1}", new object[]
                        {
                            amServerName,
                            ex
                        });
                        ReplayCrimsonEvents.PamMonitorEncounteredException.Log <string, string>(ex.Message, "MoveClusterGroup");
                    }
                }
                ReplayCrimsonEvents.PamMonitorCouldNotFindValidServerToMovePAM.Log();
            }
        }