Beispiel #1
0
        private static Exception MoveDatabase(FailedSuspendedCatalogRebuildWorkflow workflow)
        {
            Exception result = null;

            try
            {
                AmDatabaseMoveResult amDatabaseMoveResult = null;
                AmDbActionCode       actionCode           = new AmDbActionCode(AmDbActionInitiator.Admin, AmDbActionReason.CatalogFailureItem, AmDbActionCategory.Move);
                string serverName;
                AmRpcClientHelper.MoveDatabaseEx(workflow.Context.Database, 0, 16, 0, null, workflow.Context.TargetServerName.Fqdn, false, 2, actionCode, ReplayStrings.AutoReseedMoveActiveBeforeRebuildCatalog, out serverName, ref amDatabaseMoveResult);
                AmRpcExceptionWrapper.Instance.ClientRethrowIfFailed(amDatabaseMoveResult.DbName, serverName, amDatabaseMoveResult.ErrorInfo);
            }
            catch (AmReplayServiceDownException ex)
            {
                result = ex;
            }
            catch (AmServerException ex2)
            {
                result = ex2;
            }
            catch (AmServerTransientException ex3)
            {
                result = ex3;
            }
            return(result);
        }
        private DatabaseMoveResult PrepareResultEntryForMoveBack(AmDatabaseMoveResult result)
        {
            DatabaseMoveResult databaseMoveResult = new DatabaseMoveResult();

            databaseMoveResult.Guid = result.DbGuid;
            ConfigObjectId identity = new ConfigObjectId(result.DbName);

            databaseMoveResult.Identity            = identity;
            databaseMoveResult.ActiveServerAtStart = result.FromServerFqdn;
            databaseMoveResult.ActiveServerAtEnd   = result.FinalActiveServerFqdn;
            databaseMoveResult.Status = MoveActiveMailboxDatabase.ConvertToMoveStatus(result.MoveStatus);
            databaseMoveResult.MountStatusAtMoveStart = MoveActiveMailboxDatabase.ConvertToMountStatus(result.MountStatusAtStart);
            databaseMoveResult.MountStatusAtMoveEnd   = MoveActiveMailboxDatabase.ConvertToMountStatus(result.MountStatusAtEnd);
            if (result.AttemptedServerSubStatuses != null)
            {
                AmDbRpcOperationSubStatus amDbRpcOperationSubStatus = result.AttemptedServerSubStatuses.LastOrDefault <AmDbRpcOperationSubStatus>();
                if (amDbRpcOperationSubStatus != null)
                {
                    databaseMoveResult.NumberOfLogsLost       = MoveActiveMailboxDatabase.ToNullableLogGeneration(amDbRpcOperationSubStatus.AcllStatus.NumberOfLogsLost);
                    databaseMoveResult.RecoveryPointObjective = DumpsterStatisticsEntry.ToNullableLocalDateTime(amDbRpcOperationSubStatus.AcllStatus.LastInspectedLogTime);
                }
            }
            Exception exceptionFromMoveResult = this.GetExceptionFromMoveResult(result);

            if (exceptionFromMoveResult != null)
            {
                databaseMoveResult.Exception    = exceptionFromMoveResult;
                databaseMoveResult.ErrorMessage = exceptionFromMoveResult.Message;
            }
            return(databaseMoveResult);
        }
        internal static AmDatabaseMoveResult PerformDatabaseFailover(string componentName, string comment, Database database)
        {
            AmDbActionCode       actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, AmDbActionReason.FailureItem, AmDbActionCategory.Move);
            AmDatabaseMoveResult result     = null;
            string text;

            AmRpcClientHelper.MoveDatabaseEx(ADObjectWrapperFactory.CreateWrapper(database), 0, 16, -1, AmServerName.LocalComputerName.Fqdn, null, true, 0, actionCode, comment, out text, ref result);
            return(result);
        }
 private void WriteMoveResult(Database db, AmServerName startingServer, AmDatabaseMoveResult result, Exception ex)
 {
     if (result != null)
     {
         DatabaseMoveResult databaseMoveResult = this.ConvertToDatabaseMoveResult(db, startingServer, result, ex);
         base.WriteObject(databaseMoveResult);
         if (databaseMoveResult.Status == MoveStatus.Warning)
         {
             this.WriteWarningOrError(new LocalizedString(databaseMoveResult.ErrorMessage));
         }
     }
 }
        private Exception GetExceptionFromMoveResult(AmDatabaseMoveResult result)
        {
            Exception result2 = null;

            try
            {
                AmRpcExceptionWrapper.Instance.ClientRethrowIfFailed(result.DbName, this.m_lastServerContacted, result.ErrorInfo);
            }
            catch (AmServerException ex)
            {
                result2 = ex;
            }
            catch (AmServerTransientException ex2)
            {
                result2 = ex2;
            }
            return(result2);
        }
        private void MoveSingleDatabase()
        {
            AmDatabaseMoveResult result = null;

            try
            {
                int            mountDialOverride      = (int)this.MountDialOverride;
                bool           tryOtherHealthyServers = !this.TargetServerSpecified;
                AmDbActionCode actionCode             = new AmDbActionCode(AmDbActionInitiator.Admin, AmDbActionReason.Cmdlet, AmDbActionCategory.Move);
                AmRpcClientHelper.MoveDatabaseEx(ADObjectWrapperFactory.CreateWrapper(this.m_database), 0, 16, mountDialOverride, null, this.TargetServerSpecified ? this.m_targetServer.Fqdn : null, tryOtherHealthyServers, (int)this.GetSkipFlags(), actionCode, this.MoveComment, out this.m_lastServerContacted, ref result);
                this.m_output.WriteProgress(Strings.ProgressStatusCompleted, this.GetRpcDoneProgressString(), 100);
                this.WriteMoveResult(this.DataObject, this.m_startingServer, result, null);
            }
            catch (AmReplayServiceDownException ex)
            {
                TaskLogger.Trace("MoveMdbMaster.MoveSingleDatabase raised exception while moving database: {0}", new object[]
                {
                    ex
                });
                this.WriteMoveResult(this.DataObject, this.m_startingServer, result, ex);
                this.m_output.WriteError(new InvalidOperationException(Strings.ErrorActiveManagerIsNotReachable(ex.ServerName, ex.RpcErrorMessage)), ErrorCategory.InvalidOperation, this.m_database.Identity);
            }
            catch (AmServerException ex2)
            {
                TaskLogger.Trace("MoveMdbMaster.MoveSingleDatabase raised exception while moving database: {0}", new object[]
                {
                    ex2
                });
                this.WriteMoveResult(this.DataObject, this.m_startingServer, result, ex2);
                this.m_output.WriteError(ex2, ErrorCategory.InvalidOperation, this.m_database.Identity);
            }
            catch (AmServerTransientException ex3)
            {
                TaskLogger.Trace("MoveMdbMaster.MoveSingleDatabase raised exception while moving database: {0}", new object[]
                {
                    ex3
                });
                this.WriteMoveResult(this.DataObject, this.m_startingServer, result, ex3);
                this.m_output.WriteError(ex3, ErrorCategory.InvalidOperation, this.m_database.Identity);
            }
        }
Beispiel #7
0
        // Token: 0x0600045F RID: 1119 RVA: 0x000173AC File Offset: 0x000155AC
        public override RpcErrorExceptionInfo MoveDatabaseEx(Guid guid, int mountFlags, int dismountFlags, int mountDialOverride, string fromServer, string targetServerFqdn, bool tryOtherHealthyServers, int skipValidationChecks, int iActionCode, string moveComment, ref AmDatabaseMoveResult databaseMoveResult)
        {
            AmTrace.Debug("Moving database: {0} flags: {1} mountdialoverride: {2} targetserver: {3}", new object[]
            {
                guid,
                mountFlags,
                mountDialOverride,
                targetServerFqdn
            });
            if (ActiveManagerUtil.IsNullEncoded(fromServer))
            {
                fromServer = null;
            }
            if (ActiveManagerUtil.IsNullEncoded(targetServerFqdn))
            {
                targetServerFqdn = null;
            }
            AmDatabaseMoveResult tempMoveResult = null;

            databaseMoveResult = null;
            RpcErrorExceptionInfo result = AmRpcExceptionWrapper.Instance.RunRpcServerOperation(delegate()
            {
                AmDbActionCode actionCode;
                if (iActionCode == 4)
                {
                    actionCode = new AmDbActionCode(AmDbActionInitiator.Admin, AmDbActionReason.Cmdlet, AmDbActionCategory.Move);
                }
                else if (iActionCode == 7)
                {
                    actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, AmDbActionReason.FailureItem, AmDbActionCategory.Move);
                }
                else
                {
                    actionCode = new AmDbActionCode(iActionCode);
                }
                AmRpcServer.m_amInstance.MoveDatabase(guid, (MountFlags)mountFlags, (UnmountFlags)dismountFlags, (DatabaseMountDialOverride)mountDialOverride, new AmServerName(fromServer), new AmServerName(targetServerFqdn), tryOtherHealthyServers, (AmBcsSkipFlags)skipValidationChecks, actionCode, moveComment, ref tempMoveResult);
            });

            databaseMoveResult = tempMoveResult;
            return(result);
        }
        internal static void Move(IADDatabase database, string from, AmDbActionCode actionCode, DatabaseMountDialOverride mountDialOverride)
        {
            Exception            ex = null;
            AmDatabaseMoveResult amDatabaseMoveResult = null;

            DatabaseTasks.Trace("Database '{0}' moved from '{1}'", new object[]
            {
                database.Name,
                from
            });
            try
            {
                string text;
                AmRpcClientHelper.MoveDatabaseEx(database, 0, 16, (int)mountDialOverride, from, null, true, 0, actionCode, null, out text, ref amDatabaseMoveResult);
            }
            catch (AmServerException ex2)
            {
                DatabaseTasks.Trace("MoveDatabase() failed with {0}; Exception: {1}", new object[]
                {
                    amDatabaseMoveResult,
                    ex2
                });
                ex = ex2;
            }
            catch (AmServerTransientException ex3)
            {
                DatabaseTasks.Trace("MoveDatabase() failed with {0}; Exception: {1}", new object[]
                {
                    amDatabaseMoveResult,
                    ex3
                });
                ex = ex3;
            }
            if (ex != null)
            {
                throw new DatabaseFailoverFailedException(database.Name, ex.ToString(), ex);
            }
        }
        private DatabaseMoveResult PrepareResultEntryLegacy(Database db, AmServerName startingServer, AmDatabaseMoveResult result, Exception ex)
        {
            DatabaseMoveResult databaseMoveResult = new DatabaseMoveResult();
            bool flag = ex == null;

            databaseMoveResult.Guid                = db.Guid;
            databaseMoveResult.Identity            = db.Id;
            databaseMoveResult.ActiveServerAtStart = startingServer.NetbiosName;
            databaseMoveResult.ActiveServerAtEnd   = this.GetCurrentActiveServer(db.Guid).NetbiosName;
            if (flag)
            {
                databaseMoveResult.Status = MoveStatus.Succeeded;
            }
            else
            {
                databaseMoveResult.Status       = MoveStatus.Failed;
                databaseMoveResult.Exception    = ex;
                databaseMoveResult.ErrorMessage = ex.Message;
            }
            return(databaseMoveResult);
        }
        private DatabaseMoveResult ConvertToDatabaseMoveResult(Database db, AmServerName startingServer, AmDatabaseMoveResult result, Exception ex)
        {
            DatabaseMoveResult result2 = null;

            if (result != null)
            {
                if (result.IsLegacy)
                {
                    result2 = this.PrepareResultEntryLegacy(db, startingServer, result, ex);
                }
                else
                {
                    result2 = this.PrepareResultEntry(db, result, ex);
                }
            }
            return(result2);
        }
Beispiel #11
0
        // Token: 0x060001A8 RID: 424 RVA: 0x0000A59C File Offset: 0x0000879C
        internal void MoveDatabase(Guid mdbGuid, MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialOverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, AmDbActionCode actionCode, string moveComment, ref AmDatabaseMoveResult databaseMoveResult)
        {
            AmTrace.Debug("Task: MoveDatabase({0},{1},{2},{3},{4},{5},{6},{7},'{8}') called", new object[]
            {
                mdbGuid,
                mountFlags,
                dismountFlags,
                mountDialOverride,
                fromServer,
                targetServer,
                tryOtherHealthyServers,
                actionCode,
                moveComment
            });
            ActiveManagerCore.ValidatePamOrStandalone("MoveDatabase");
            ThirdPartyManager.PreventOperationWhenTPREnabled("MoveDatabase");
            IADDatabase iaddatabase = this.AdLookup.DatabaseLookup.FindAdObjectByGuidEx(mdbGuid, AdObjectLookupFlags.ReadThrough);

            if (iaddatabase == null)
            {
                throw new AmDatabaseNotFoundException(mdbGuid);
            }
            AmDbMoveOperation    amDbMoveOperation    = new AmDbMoveOperation(iaddatabase, actionCode);
            AmDbMoveArguments    arguments            = amDbMoveOperation.Arguments;
            AmDbCompletionReason amDbCompletionReason = AmDbCompletionReason.None;

            arguments.MountFlags             = mountFlags;
            arguments.DismountFlags          = dismountFlags;
            arguments.MountDialOverride      = mountDialOverride;
            arguments.SourceServer           = fromServer;
            arguments.TargetServer           = targetServer;
            arguments.TryOtherHealthyServers = tryOtherHealthyServers;
            arguments.SkipValidationChecks   = skipValidationChecks;
            arguments.MoveComment            = moveComment;
            amDbMoveOperation.Arguments      = arguments;
            amDbMoveOperation.Enqueue();
            try
            {
                amDbCompletionReason = amDbMoveOperation.Wait();
            }
            finally
            {
                if (amDbMoveOperation.DetailedStatus != null)
                {
                    databaseMoveResult = amDbMoveOperation.ConvertDetailedStatusToRpcMoveResult(amDbMoveOperation.DetailedStatus);
                }
            }
            AmTrace.Debug("MoveDatabase({0}) completed (reason={1})", new object[]
            {
                mdbGuid,
                amDbCompletionReason
            });
        }
Beispiel #12
0
        internal static void HandleSourceLogCorruption(IADDatabase database, string from)
        {
            Exception            ex = null;
            AmDatabaseMoveResult amDatabaseMoveResult = null;

            DatabaseTasks.Trace("HandleSourceLogCorruption for Database '{0}' from '{1}'", new object[]
            {
                database.Name,
                from
            });
            ReplayEventLogConstants.Tuple_CorruptLogRecoveryIsAttempted.LogEvent(null, new object[]
            {
                database.Name
            });
            try
            {
                AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, AmDbActionReason.FailureItem, AmDbActionCategory.Move);
                string         text;
                AmRpcClientHelper.MoveDatabaseEx(database, 0, 0, RegistryParameters.MaxAutoDatabaseMountDial, from, null, true, 0, actionCode, "HandleSourceLogCorruption", out text, ref amDatabaseMoveResult);
            }
            catch (AmServerException ex2)
            {
                ex = ex2;
            }
            catch (AmServerTransientException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                DatabaseTasks.Tracer.TraceError <Exception>(0L, "HandleSourceLogCorruption: Move failed: {0}", ex);
            }
            bool      flag = false;
            Exception ex4  = null;

            try
            {
                string text2;
                ActiveManagerCore.GetDatabaseMountStatus(database.Guid, out text2);
                if (!string.IsNullOrEmpty(text2) && !Cluster.StringIEquals(text2, Dependencies.ManagementClassHelper.LocalMachineName))
                {
                    flag = true;
                }
            }
            catch (ClusterException ex5)
            {
                ex4 = ex5;
            }
            catch (AmServerException ex6)
            {
                ex4 = ex6;
            }
            if (ex4 != null)
            {
                DatabaseTasks.Tracer.TraceError <Exception>(0L, "HandleSourceLogCorruption: Determine active failed: {0}", ex4);
                if (ex == null)
                {
                    ex = ex4;
                }
            }
            if (flag)
            {
                Exception ex7 = DatabaseTasks.ResumeLocalDatabaseCopy(database);
                if (ex7 != null)
                {
                    DatabaseTasks.Tracer.TraceError <Exception>(0L, "HandleSourceLogCorruption: Resume failed: {0}", ex7);
                    ReplayEventLogConstants.Tuple_ResumeFailedDuringFailureItemProcessing.LogEvent(database.Name, new object[]
                    {
                        database.Name,
                        ex7.Message
                    });
                }
            }
            if (ex != null)
            {
                throw new DatabaseLogCorruptRecoveryException(database.Name, ex.ToString(), ex);
            }
        }