Пример #1
0
        // Token: 0x06001A47 RID: 6727 RVA: 0x0006EA10 File Offset: 0x0006CC10
        public void BeginServerLevelSeed(bool fDeleteExistingLogs, bool fSafeDeleteExistingFiles, int maxSeedsInParallel, bool fAutoSuspend, bool fManualResume, bool fSeedDatabase, bool fSeedCiFiles, bool?compressOverride, bool?encryptOverride, SeederRpcFlags flags = SeederRpcFlags.None)
        {
            RpcSeederArgs args = new RpcSeederArgs(Guid.Empty, fDeleteExistingLogs, fAutoSuspend, null, null, string.Empty, false, string.Empty, null, fManualResume, fSeedDatabase, fSeedCiFiles, compressOverride, encryptOverride, maxSeedsInParallel, fSafeDeleteExistingFiles, flags);

            this.ValidateArgs(args);
            ExTraceGlobals.SeederClientTracer.TraceDebug <RpcSeederArgs>((long)this.GetHashCode(), "BeginServerLevelSeed(): Constructed RpcSeederArgs: {0}", args);
            RpcErrorExceptionInfo errorInfo  = null;
            RpcSeederStatus       seedStatus = null;
            ServerVersion         version    = this.GetTestHookServerVersion();

            SeederRpcExceptionWrapper.Instance.ClientRetryableOperation(this.m_serverName, delegate
            {
                if (ReplayRpcVersionControl.IsSeedRpcV5Supported(version))
                {
                    errorInfo = this.m_client.RpccPrepareDatabaseSeedAndBegin5(args, ref seedStatus);
                    return;
                }
                if (ReplayRpcVersionControl.IsSeedRpcSafeDeleteSupported(version))
                {
                    errorInfo = this.m_client.RpccPrepareDatabaseSeedAndBegin4(args, ref seedStatus);
                    return;
                }
                ExTraceGlobals.SeederClientTracer.TraceError <string, ServerVersion, ServerVersion>((long)this.GetHashCode(), "BeginServerLevelSeed(): Server '{0}' does not support server-level reseed RPC. Server version: {1}. Minimum supported version: {2}", this.m_serverName, version, ReplayRpcVersionControl.SeedRpcSafeDeleteSupportVersion);
                throw new SeederRpcServerLevelUnsupportedException(this.m_serverName, version.ToString(), ReplayRpcVersionControl.SeedRpcSafeDeleteSupportVersion.ToString());
            });
            SeederRpcExceptionWrapper.Instance.ClientRethrowIfFailed(this.m_databaseName, this.m_serverName, errorInfo);
        }
Пример #2
0
 public static bool IsReportSystemEventRpcSupported(ServerVersion serverVersion, AmSystemEventCode eventCode)
 {
     if (eventCode == AmSystemEventCode.StoreServiceStarted || eventCode == AmSystemEventCode.StoreServiceStopped)
     {
         return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.ReportSystemEventRpcSupportedVersion));
     }
     return(eventCode == AmSystemEventCode.StoreServiceUnexpectedlyStopped && ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.UnexpectedStoreStopEventCodeSupportedVersion));
 }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         ExTraceGlobals.CmdletsTracer.TraceDebug <string, DatabaseCopyIdParameter>((long)this.GetHashCode(), "DatabaseCopyStateAction: enter InternalValidate(DB,ident): {0}, {1}", base.DatabaseName, this.Identity);
         base.InternalValidate();
         if (base.HasErrors)
         {
             TaskLogger.LogExit();
         }
         else
         {
             Database database = this.DataObject.GetDatabase <Database>();
             DatabaseAvailabilityGroup dagForDatabase = DagTaskHelper.GetDagForDatabase(database, base.DataSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
             DagTaskHelper.PreventTaskWhenTPREnabled(dagForDatabase, this);
             this.m_UseRpc = ReplayRpcVersionControl.IsSuspendRpcSupported(this.Server.AdminDisplayVersion);
             ServerVersion serverVersion = this.IsReplayLagManagementOperation ? ReplayRpcVersionControl.GetCopyStatusEx4RpcSupportVersion : ReplayRpcVersionControl.SuspendRpcSupportVersion;
             if (this.m_UseRpc)
             {
                 if (this.IsSuspendOperation)
                 {
                     base.WriteVerbose(Strings.SuspendSgcUseRpc(this.Server.AdminDisplayVersion.ToString(), serverVersion.ToString()));
                 }
                 else
                 {
                     base.WriteVerbose(Strings.ResumeSgcUseRpc(this.Server.AdminDisplayVersion.ToString(), serverVersion.ToString()));
                 }
             }
             else if (this.IsReplayLagManagementOperation)
             {
                 base.WriteError(new ReplayLagRpcUnsupportedException(this.Server.Name, this.Server.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx4RpcSupportVersion.ToString()), ExchangeErrorCategory.ServerOperation, this.Server);
             }
             else if (this.IsSuspendOperation)
             {
                 base.WriteVerbose(Strings.SuspendSgcUseState(this.Server.Name, this.Server.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.SuspendRpcSupportVersion.ToString()));
             }
             else
             {
                 base.WriteVerbose(Strings.ResumeSgcUseState(this.Server.Name, this.Server.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.SuspendRpcSupportVersion.ToString()));
             }
             this.IsActivationRpcSupported      = ReplayRpcVersionControl.IsActivationRpcSupported(this.Server.AdminDisplayVersion);
             this.IsRequestSuspend3RpcSupported = ReplayRpcVersionControl.IsRequestSuspend3RpcSupported(this.Server.AdminDisplayVersion);
             this.IsOperationRunOnSource        = false;
             DatabaseLocationInfo databaseLocationInfo;
             if (database.ReplicationType == ReplicationType.Remote && RemoteReplayConfiguration.IsServerRcrSource(ADObjectWrapperFactory.CreateWrapper(database), ADObjectWrapperFactory.CreateWrapper(this.Server), out databaseLocationInfo))
             {
                 this.IsOperationRunOnSource = true;
             }
             ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "DatabaseCopyStateAction: leave InternalValidate: {0}", base.DatabaseName);
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
 public void NotifyChangedReplayConfiguration(string serverName, Guid dbGuid, ServerVersion serverVersion, bool waitForCompletion, bool isHighPriority, ReplayConfigChangeHints changeHint)
 {
     if (ReplayRpcVersionControl.IsNotifyChangedReplayConfigurationRpcSupported(serverVersion))
     {
         ReplayRpcClientWrapper.NotifyChangedReplayConfiguration(serverName, dbGuid, waitForCompletion, !waitForCompletion, isHighPriority, changeHint, 10000);
         return;
     }
     ReplayRpcClientWrapper.RunConfigurationUpdater(serverName, 10000);
 }
 public RpcDatabaseCopyStatus2[] GetCopyStatus(string serverName, RpcGetDatabaseCopyStatusFlags2 collectionFlags2, Guid[] dbGuids, int timeoutMs)
 {
     if (dbGuids == null || dbGuids.Length == 0)
     {
         dbGuids = new Guid[]
         {
             Guid.Empty
         };
     }
     RpcDatabaseCopyStatus2[] statusResults = null;
     ReplayRpcClientWrapper.RunRpcOperation(serverName, null, timeoutMs, TasksRpcExceptionWrapper.Instance, delegate(ReplayRpcClient rpcClient)
     {
         RpcErrorExceptionInfo result;
         try
         {
             if (ReplayRpcVersionControl.IsGetCopyStatusEx4RpcSupported(ReplayRpcClientWrapper.GetServerVersion(serverName)))
             {
                 ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string>(0L, "GetCopyStatus(): Now making RpccGetCopyStatusEx4() RPC to server {0}.", serverName);
                 RpcErrorExceptionInfo rpcErrorExceptionInfo = rpcClient.RpccGetCopyStatusEx4(collectionFlags2, dbGuids, ref statusResults);
                 if (!rpcErrorExceptionInfo.IsFailed())
                 {
                     ReplayRpcClientWrapper.DeserializeExtendedErrorInfo(statusResults);
                 }
                 result = rpcErrorExceptionInfo;
             }
             else
             {
                 RpcDatabaseCopyStatus[] array = null;
                 ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string>(0L, "GetCopyStatus(): Now making GetCopyStatusEx2() RPC to server {0}.", serverName);
                 RpcErrorExceptionInfo copyStatusEx = rpcClient.GetCopyStatusEx2(ReplayRpcClientWrapper.ConvertToLegacyCopyStatusFlags(collectionFlags2), dbGuids, ref array);
                 if (!copyStatusEx.IsFailed() && array != null)
                 {
                     statusResults = ReplayRpcClientWrapper.ConvertLegacyCopyStatusArray(array);
                 }
                 result = copyStatusEx;
             }
         }
         catch (RpcException ex)
         {
             if (ReplayRpcErrorCode.IsRpcTimeoutError(ex.ErrorCode))
             {
                 throw new ReplayServiceDownException(serverName, ex.Message, ex);
             }
             throw;
         }
         return(result);
     });
     return(statusResults);
 }
Пример #6
0
        // Token: 0x06001A41 RID: 6721 RVA: 0x0006E618 File Offset: 0x0006C818
        public static SeederClient Create(string serverName, string databaseName, string sourceName, ServerVersion serverVersion)
        {
            if (!ReplayRpcVersionControl.IsSeedRpcSupported(serverVersion))
            {
                throw new SeederRpcUnsupportedException(serverName, serverVersion.ToString(), ReplayRpcVersionControl.SeedRpcSupportVersion.ToString());
            }
            ExTraceGlobals.SeederClientTracer.TraceDebug <string, ServerVersion>(0L, "SeederClient is now being created for server '{0}' with version '0x{1:x}'.", serverName, serverVersion);
            ReplayRpcClient rpcClient = null;

            SeederRpcExceptionWrapper.Instance.ClientRetryableOperation(serverName, delegate
            {
                rpcClient = new ReplayRpcClient(serverName);
            });
            return(new SeederClient(serverName, serverVersion, databaseName, sourceName, rpcClient));
        }
        public RpcCopyStatusContainer GetCopyStatusWithHealthState(string serverName, RpcGetDatabaseCopyStatusFlags2 collectionFlags2, Guid[] dbGuids, int timeoutMs)
        {
            if (dbGuids == null || dbGuids.Length == 0)
            {
                dbGuids = new Guid[]
                {
                    Guid.Empty
                };
            }
            RpcCopyStatusContainer container = null;

            if (ReplayRpcVersionControl.IsGetCopyStatusWithHealthStateRpcSupported(ReplayRpcClientWrapper.GetServerVersion(serverName)))
            {
                ReplayRpcClientWrapper.RunRpcOperation(serverName, null, timeoutMs, TasksRpcExceptionWrapper.Instance, delegate(ReplayRpcClient rpcClient)
                {
                    RpcErrorExceptionInfo result;
                    try
                    {
                        ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string>(0L, "GetCopyStatusWithHealthState(): Now making RpccGetCopyStatusWithHealthState() RPC to server {0}.", serverName);
                        RpcErrorExceptionInfo rpcErrorExceptionInfo = rpcClient.RpccGetCopyStatusWithHealthState(collectionFlags2, dbGuids, ref container);
                        if (!rpcErrorExceptionInfo.IsFailed())
                        {
                            ReplayRpcClientWrapper.DeserializeExtendedErrorInfo(container.CopyStatuses);
                        }
                        result = rpcErrorExceptionInfo;
                    }
                    catch (RpcException ex)
                    {
                        if (ReplayRpcErrorCode.IsRpcTimeoutError(ex.ErrorCode))
                        {
                            throw new ReplayServiceDownException(serverName, ex.Message, ex);
                        }
                        throw;
                    }
                    return(result);
                });
            }
            else
            {
                container = new RpcCopyStatusContainer();
                container.HealthStates = null;
                container.CopyStatuses = this.GetCopyStatus(serverName, collectionFlags2, dbGuids, timeoutMs);
            }
            return(container);
        }
        public void RpccEnableReplayLag(string serverName, Guid dbGuid, ActionInitiatorType actionInitiator)
        {
            ServerVersion serverVersion = ReplayRpcClientWrapper.GetServerVersion(serverName);

            if (!ReplayRpcVersionControl.IsDisableReplayLagRpcSupported(serverVersion))
            {
                ExTraceGlobals.ReplayServiceRpcTracer.TraceError <string, ServerVersion, ServerVersion>(0L, "RpccEnableReplayLag(): RPC to server '{0}' not supported. Server version: {1:x}. Supported version: {2:x}.", serverName, serverVersion, ReplayRpcVersionControl.GetCopyStatusEx4RpcSupportVersion);
                throw new ReplayLagRpcUnsupportedException(serverName, serverVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx4RpcSupportVersion.ToString());
            }
            ReplayRpcClientWrapper.RunRpcOperation(serverName, new Guid?(dbGuid), TasksRpcExceptionWrapper.Instance, delegate(ReplayRpcClient rpcClient)
            {
                if (ReplayRpcVersionControl.IsDisableReplayLagRpcV2Supported(serverVersion))
                {
                    ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string, Guid, ActionInitiatorType>(0L, "RpccEnableReplayLag(): Now making RpccEnableReplayLag2 RPC to server {0} for guid {1} (actionInitiator = {2}).", serverName, dbGuid, actionInitiator);
                    return(rpcClient.RpccEnableReplayLag2(dbGuid, (uint)actionInitiator));
                }
                ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string, Guid, ActionInitiatorType>(0L, "RpccEnableReplayLag(): Now making RpccEnableReplayLag RPC to server {0} for guid {1} (actionInitiator = {2}).", serverName, dbGuid, actionInitiator);
                return(rpcClient.RpccEnableReplayLag(dbGuid));
            });
        }
Пример #9
0
        public static void RunConfigurationUpdaterRpc(string serverFqdn, Database database, ServerVersion serverVersion, ReplayConfigChangeHints changeHint, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskWarningLoggingDelegate writeWarning)
        {
            string name = database.Name;

            if (ReplayRpcVersionControl.IsRunConfigUpdaterRpcSupported(serverVersion))
            {
                writeVerbose(Strings.RunConfigUpdaterRpcVerbose(serverFqdn, name));
                try
                {
                    ReplayRpcClientHelper.NotifyChangedReplayConfiguration(serverFqdn, database.Guid, serverVersion, true, false, changeHint);
                }
                catch (TaskServerTransientException ex)
                {
                    writeWarning(Strings.RunConfigUpdaterRpcFailedWarning(serverFqdn, name, ex.Message));
                }
                catch (TaskServerException ex2)
                {
                    writeWarning(Strings.RunConfigUpdaterRpcFailedWarning(serverFqdn, name, ex2.Message));
                }
            }
        }
Пример #10
0
        // Token: 0x06001A46 RID: 6726 RVA: 0x0006E83C File Offset: 0x0006CA3C
        public void PrepareDbSeedAndBegin(Guid dbGuid, bool fDeleteExistingLogs, bool fSafeDeleteExistingFiles, bool fAutoSuspend, bool fManualResume, bool fSeedDatabase, bool fSeedCiFiles, string networkId, string seedingPath, string sourceName, bool?compressOverride, bool?encryptOverride, SeederRpcFlags flags = SeederRpcFlags.None)
        {
            if (dbGuid == Guid.Empty)
            {
                throw new ArgumentException("An invalid Database Guid was specified.", "dbGuid");
            }
            RpcSeederArgs args = new RpcSeederArgs(dbGuid, fDeleteExistingLogs, fAutoSuspend, seedingPath, null, networkId, false, sourceName, null, fManualResume, fSeedDatabase, fSeedCiFiles, compressOverride, encryptOverride, 0, fSafeDeleteExistingFiles, flags);

            this.ValidateArgs(args);
            ExTraceGlobals.SeederClientTracer.TraceDebug <RpcSeederArgs>((long)this.GetHashCode(), "PrepareDbSeedAndBegin(): Constructed RpcSeederArgs: {0}", args);
            RpcErrorExceptionInfo errorInfo  = null;
            RpcSeederStatus       seedStatus = null;
            ServerVersion         version    = this.GetTestHookServerVersion();
            bool isSafeDeleteSupported       = ReplayRpcVersionControl.IsSeedRpcSafeDeleteSupported(version);
            bool isSeedV5Supported           = ReplayRpcVersionControl.IsSeedRpcV5Supported(version);

            SeederRpcExceptionWrapper.Instance.ClientRetryableOperation(this.m_serverName, delegate
            {
                if (isSeedV5Supported)
                {
                    errorInfo = this.m_client.RpccPrepareDatabaseSeedAndBegin5(args, ref seedStatus);
                    return;
                }
                if (isSafeDeleteSupported)
                {
                    errorInfo = this.m_client.RpccPrepareDatabaseSeedAndBegin4(args, ref seedStatus);
                    return;
                }
                if (!fSafeDeleteExistingFiles)
                {
                    errorInfo = this.m_client.RpccPrepareDatabaseSeedAndBegin(args, ref seedStatus);
                    return;
                }
                ExTraceGlobals.SeederClientTracer.TraceError <string, ServerVersion, ServerVersion>((long)this.GetHashCode(), "PrepareDbSeedAndBegin(): Server '{0}' does not support SafeDeleteExistingFiles RPC. Server version: {1}. Minimum supported version: {2}", this.m_serverName, version, ReplayRpcVersionControl.SeedRpcSafeDeleteSupportVersion);
                throw new SeederRpcSafeDeleteUnsupportedException(this.m_serverName, version.ToString(), ReplayRpcVersionControl.SeedRpcSafeDeleteSupportVersion.ToString());
            });
            SeederRpcExceptionWrapper.Instance.ClientRethrowIfFailed(this.m_databaseName, this.m_serverName, errorInfo);
        }
Пример #11
0
 public static bool IsServerMoveBackDatabasesRpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.AmServerMoveBackDatabasesRpcSupportedVersion));
 }
Пример #12
0
 public static bool IsGetDeferredRecoveryEntriesRpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.GetDeferredRecoveryEntriesRpcSupportedSupportedVersion));
 }
Пример #13
0
 public static bool IsReportServiceKillRpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.ReportServiceKillSupportedVersion));
 }
Пример #14
0
 public static bool IsMoveWithCatalogFailureReasonCodeSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.MoveWithCatalogFailureReasonCodeVersion));
 }
Пример #15
0
 public static bool IsMountWithAmFlagsRpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.MountWithAmFlagsSupportedVersion));
 }
Пример #16
0
 public static bool IsAttemptCopyLastLogsDirect3RpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.AttemptCopyLastLogsDirect3SupportVersion));
 }
Пример #17
0
 public static bool IsAmRefreshConfigurationSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.AmRefreshConfigurationRpcSupportVersion));
 }
Пример #18
0
 public static bool IsCheckThirdPartyListenerSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.ThirdPartyReplListenerSupportedVersion));
 }
Пример #19
0
 public static bool IsMoveDatabaseEx3RpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.MoveDatabaseEx3RpcSupportVersion));
 }
Пример #20
0
 public static bool IsGetAmRoleRpcSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.GetAMRoleSupportVersion));
 }
Пример #21
0
 public static bool IsSwitchOverSupported(ServerVersion serverVersion)
 {
     return(ReplayRpcVersionControl.IsVersionGreater(serverVersion, AmRpcVersionControl.SwitchOverSupportVersion));
 }
        protected override void WriteResult <T>(IEnumerable <T> dataObjects)
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObjects
            });
            Dictionary <string, Collection <DatabaseCopy> > dictionary = new Dictionary <string, Collection <DatabaseCopy> >();

            foreach (T t in dataObjects)
            {
                IConfigurable configurable = t;
                DatabaseCopy  databaseCopy = configurable as DatabaseCopy;
                string        key;
                if (this.m_server != null)
                {
                    key = this.m_server.Name;
                }
                else
                {
                    key = databaseCopy.HostServerName;
                }
                Collection <DatabaseCopy> collection;
                if (!dictionary.TryGetValue(key, out collection))
                {
                    collection = new Collection <DatabaseCopy>();
                    dictionary.Add(key, collection);
                }
                collection.Add(databaseCopy);
            }
            using (Dictionary <string, Collection <DatabaseCopy> > .KeyCollection.Enumerator enumerator2 = dictionary.Keys.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    string dbCopyServerName = enumerator2.Current;
                    Collection <DatabaseCopy> collection2 = dictionary[dbCopyServerName];
                    Server server2;
                    if (this.m_server != null)
                    {
                        server2 = this.m_server;
                    }
                    else
                    {
                        MailboxServerIdParameter mailboxServerIdParameter = MailboxServerIdParameter.Parse(dbCopyServerName);
                        IEnumerable <Server>     objects = mailboxServerIdParameter.GetObjects <Server>(this.RootId, this.ConfigurationSession);
                        server2 = objects.FirstOrDefault((Server server) => server.Name.Equals(dbCopyServerName, StringComparison.OrdinalIgnoreCase));
                    }
                    if (server2 != null)
                    {
                        if (ReplayRpcVersionControl.IsGetCopyStatusEx2RpcSupported(server2.AdminDisplayVersion))
                        {
                            DatabaseCopyStatusEntry[] array = this.PrepareStatusEntryFromRpc(server2, collection2);
                            for (int i = 0; i < array.Length; i++)
                            {
                                this.WriteCopyStatusResultIfAppropriate(array[i]);
                            }
                        }
                        else
                        {
                            this.WriteError(new InvalidOperationException(Strings.GetDbcsRpcNotSupported(server2.Name, server2.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx2SupportVersion.ToString())), ErrorCategory.InvalidOperation, server2.Identity, false);
                        }
                    }
                    else
                    {
                        foreach (DatabaseCopy databaseCopy2 in collection2)
                        {
                            DatabaseCopyStatusEntry databaseCopyStatusEntry = this.ConstructNewSatusEntry(databaseCopy2);
                            this.UpdateMisconfiguredCopyStatusEntry(databaseCopyStatusEntry, databaseCopy2);
                            this.WriteCopyStatusResultIfAppropriate(databaseCopyStatusEntry);
                        }
                    }
                }
            }
            TaskLogger.LogExit();
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         this.ConfigurationSession.ServerTimeout             = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout));
         ((IDirectorySession)base.DataSession).ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout));
         if (this.Identity == null)
         {
             this.m_serverName = Environment.MachineName;
             this.Identity     = ServerIdParameter.Parse(this.m_serverName);
         }
         base.InternalValidate();
         if (base.HasErrors)
         {
             TaskLogger.LogExit();
         }
         else
         {
             ADServerWrapper server = ADObjectWrapperFactory.CreateWrapper(this.DataObject);
             ReplicationCheckGlobals.Server = server;
             this.m_serverName = this.DataObject.Name;
             ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "serverName is '{0}'.", this.m_serverName ?? "null");
             this.m_isLocal = SharedHelper.StringIEquals(this.m_serverName, Environment.MachineName);
             if (!this.m_isLocal && this.MonitoringContext)
             {
                 this.WriteErrorAndMonitoringEvent(new CannotRunMonitoringTaskRemotelyException(this.m_serverName), ErrorCategory.InvalidOperation, this.Identity, 10011, "MSExchange Monitoring ReplicationHealth");
             }
             ReplicationCheckGlobals.RunningInMonitoringContext = this.MonitoringContext;
             if (this.m_isLocal && !this.CheckLocalServerRegistryRoles())
             {
                 ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "Local server does not have Exchange 2009 Mailbox Role in the registry.");
             }
             else
             {
                 this.CheckServerObject();
                 if (this.DataObject.DatabaseAvailabilityGroup != null)
                 {
                     this.m_serverConfigBitfield |= ServerConfig.DagMember;
                     this.m_dag = this.ConfigurationSession.Read <DatabaseAvailabilityGroup>(this.DataObject.DatabaseAvailabilityGroup);
                     if (this.m_dag.StoppedMailboxServers.Contains(new AmServerName(this.m_serverName).Fqdn))
                     {
                         this.m_serverConfigBitfield |= ServerConfig.Stopped;
                     }
                 }
                 else
                 {
                     ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "{0} is a Standalone non-DAG Mailbox server.", this.DataObject.Name);
                 }
                 try
                 {
                     this.BuildReplayConfigurations(this.m_dag, server);
                 }
                 catch (ClusterException exception)
                 {
                     this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth");
                     return;
                 }
                 catch (TransientException exception2)
                 {
                     this.WriteErrorAndMonitoringEvent(exception2, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth");
                     return;
                 }
                 catch (DataSourceOperationException exception3)
                 {
                     this.WriteErrorAndMonitoringEvent(exception3, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth");
                     return;
                 }
                 catch (DataValidationException exception4)
                 {
                     this.WriteErrorAndMonitoringEvent(exception4, ErrorCategory.InvalidData, null, 10003, "MSExchange Monitoring ReplicationHealth");
                     return;
                 }
                 ReplicationCheckGlobals.ServerConfiguration = this.m_serverConfigBitfield;
                 if (this.DataObject != null)
                 {
                     this.m_useReplayRpc = ReplayRpcVersionControl.IsGetCopyStatusEx2RpcSupported(this.DataObject.AdminDisplayVersion);
                 }
                 this.CheckIfTaskCanRun();
             }
         }
     }
     finally
     {
         if (base.HasErrors)
         {
             if (this.MonitoringContext)
             {
                 this.WriteMonitoringData();
             }
             ReplicationCheckGlobals.ResetState();
         }
         TaskLogger.LogExit();
     }
 }