Exemplo n.º 1
0
        // Token: 0x060001A2 RID: 418 RVA: 0x0000A078 File Offset: 0x00008278
        internal static bool AttemptServerSwitchoverOnShutdown()
        {
            AmTrace.Entering("ActiveManagerCore.AttemptServerSwitchoverOnShutdown", new object[0]);
            ExDateTime utcNow = ExDateTime.UtcNow;

            ReplayEventLogConstants.Tuple_PreShutdownStart.LogEvent(null, new object[0]);
            Exception ex     = null;
            bool      result = false;

            try
            {
                AmConfig config = AmSystemManager.Instance.Config;
                if (config.IsPamOrSam)
                {
                    string fqdn = config.DagConfig.CurrentPAM.Fqdn;
                    AmTrace.Debug("{0} Trying to mount all the databases on other servers", new object[]
                    {
                        ExDateTime.Now
                    });
                    AmRpcClientHelper.ServerSwitchOver(fqdn, AmServerName.LocalComputerName.Fqdn);
                    if (config.IsPAM)
                    {
                        AmTrace.Debug("{0} Trying to move PAM off this node", new object[]
                        {
                            ExDateTime.Now
                        });
                        using (IAmCluster amCluster = ClusterFactory.Instance.Open())
                        {
                            using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup())
                            {
                                TimeSpan ts       = ExDateTime.UtcNow.Subtract(utcNow);
                                TimeSpan timeSpan = TimeSpan.FromSeconds(115.0).Subtract(ts);
                                if (!(timeSpan <= TimeSpan.Zero))
                                {
                                    if (amClusterGroup.MoveGroupToReplayEnabledNode((string targetNode) => AmHelper.IsReplayRunning(targetNode), "Network Name", timeSpan, out fqdn))
                                    {
                                        ReplayEventLogConstants.Tuple_SuccMovePAM.LogEvent(null, new object[]
                                        {
                                            Environment.MachineName,
                                            fqdn
                                        });
                                        AmTrace.Debug("{0} Moved PAM to another node", new object[]
                                        {
                                            ExDateTime.Now
                                        });
                                        goto IL_197;
                                    }
                                }
                                ReplayEventLogConstants.Tuple_FailedMovePAM.LogEvent(null, new object[]
                                {
                                    Environment.MachineName
                                });
                                IL_197 :;
                            }
                        }
                    }
                    result = true;
                    ReplayEventLogConstants.Tuple_PreShutdownOK.LogEvent(null, new object[0]);
                }
            }
            catch (ClusterException ex2)
            {
                ex = ex2;
            }
            catch (AmRpcException ex3)
            {
                ex = ex3;
            }
            catch (AmServerTransientException ex4)
            {
                ex = ex4;
            }
            catch (AmServerException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    ReplayEventLogConstants.Tuple_PreShutdownFailed.LogEvent(null, new object[]
                    {
                        ex.Message
                    });
                }
                AmTrace.Leaving("ActiveManagerCore.AttemptServerSwitchoverOnShutdown", new object[0]);
            }
            return(result);
        }