Ejemplo n.º 1
0
        internal static Exception ResumeLocalDatabaseCopy(IADDatabase database)
        {
            string    localMachineFqdn = DatabaseTasks.LocalMachineFqdn;
            Exception ex = null;

            try
            {
                DatabaseCopyActionFlags flags = DatabaseCopyActionFlags.Replication | DatabaseCopyActionFlags.Activation;
                Dependencies.ReplayRpcClientWrapper.RequestResume2(localMachineFqdn, database.Guid, (uint)flags);
            }
            catch (TaskServerException ex2)
            {
                ex = ex2;
            }
            catch (TaskServerTransientException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                DatabaseTasks.Trace("ResumeLocalDatabaseCopy(): Failed with exception: {0}", new object[]
                {
                    ex
                });
                return(ex);
            }
            return(null);
        }
Ejemplo n.º 2
0
        internal static void WaitUntilDatabaseIsNotMounted(IADDatabase database, int seconds)
        {
            bool flag = true;

            DatabaseTasks.Trace("Waiting for database {0} to reach dismounted/dismounting state for {1} seconds", new object[]
            {
                database.Name,
                seconds
            });
            for (int i = 0; i < seconds; i++)
            {
                if (!AmStoreHelper.IsMounted(null, database.Guid))
                {
                    flag = false;
                    break;
                }
                Thread.Sleep(1000);
            }
            if (flag)
            {
                DatabaseTasks.Trace("Database is still mounted {0} after {1} seconds", new object[]
                {
                    database.Name,
                    seconds
                });
            }
        }
Ejemplo n.º 3
0
        internal static void Remount(IADDatabase database, string from)
        {
            Exception ex = null;

            DatabaseTasks.Trace("Database '{0}' is attempting to remount on '{1}'", new object[]
            {
                database.Name,
                from
            });
            try
            {
                DatabaseTasks.WaitUntilDatabaseIsNotMounted(database, 5);
                AmRpcClientHelper.RemountDatabase(database, 0, -1, from);
            }
            catch (AmServerException ex2)
            {
                DatabaseTasks.Trace("RemountDatabase() failed with {0}", new object[]
                {
                    ex2
                });
                ex = ex2;
            }
            catch (AmServerTransientException ex3)
            {
                DatabaseTasks.Trace("RemountDatabase() failed with {0}", new object[]
                {
                    ex3
                });
                ex = ex3;
            }
            if (ex != null)
            {
                throw new DatabaseRemountFailedException(database.Name, ex.ToString(), ex);
            }
        }
Ejemplo n.º 4
0
        internal static void SuspendLocalDatabaseCopy(IADDatabase database, string suspendMsg)
        {
            string    serverNameFqdn = DatabaseTasks.LocalMachineFqdn;
            Exception ex             = null;

            try
            {
                Action invokableAction = delegate()
                {
                    DatabaseCopyActionFlags flags = DatabaseCopyActionFlags.Replication | DatabaseCopyActionFlags.Activation;
                    Dependencies.ReplayRpcClientWrapper.RequestSuspend3(serverNameFqdn, database.Guid, suspendMsg, (uint)flags, 1U);
                };
                InvokeWithTimeout.Invoke(invokableAction, TimeSpan.FromSeconds((double)RegistryParameters.FailureItemLocalDatabaseOperationTimeoutInSec));
            }
            catch (ReplayServiceSuspendCommentException ex2)
            {
                DatabaseTasks.Trace("SuspendLocalDatabaseCopy(): Catching and ignoring exception: {0}", new object[]
                {
                    ex2
                });
            }
            catch (TimeoutException ex3)
            {
                DatabaseTasks.Trace("SuspendLocalDatabaseCopy(): Failed on timeout: {0}", new object[]
                {
                    ex3
                });
                ex = ex3;
            }
            catch (TaskServerException ex4)
            {
                ex = ex4;
            }
            catch (TaskServerTransientException ex5)
            {
                ex = ex5;
            }
            if (ex != null)
            {
                DatabaseTasks.Trace("SuspendLocalDatabaseCopy(): Failed with exception: {0}", new object[]
                {
                    ex
                });
                throw new DatabaseCopySuspendException(database.Name, Environment.MachineName, ex.ToString(), ex);
            }
        }
Ejemplo n.º 5
0
        internal static Exception SuspendAndFailLocalDatabaseCopy(IADDatabase database, string suspendMsg, string errorMsg, uint errorEventId, bool blockResume, bool blockReseed, bool blockInPlaceReseed)
        {
            Exception ex = null;

            try
            {
                Action invokableAction = delegate()
                {
                    ReplicaInstanceManager replicaInstanceManager = Dependencies.ReplayCoreManager.ReplicaInstanceManager;
                    replicaInstanceManager.RequestSuspendAndFail(database.Guid, errorEventId, errorMsg, suspendMsg, true, blockResume, blockReseed, blockInPlaceReseed);
                };
                InvokeWithTimeout.Invoke(invokableAction, TimeSpan.FromSeconds((double)RegistryParameters.FailureItemLocalDatabaseOperationTimeoutInSec));
            }
            catch (TimeoutException ex2)
            {
                DatabaseTasks.Trace("SuspendLocalDatabaseCopy(): Failed on timeout: {0}", new object[]
                {
                    ex2
                });
                ex = ex2;
            }
            catch (TaskServerException ex3)
            {
                ex = ex3;
            }
            catch (TaskServerTransientException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                DatabaseTasks.Trace("SuspendAndFailLocalDatabaseCopy failed to suspend: {0}", new object[]
                {
                    ex
                });
                return(new DatabaseCopySuspendException(database.Name, Environment.MachineName, ex.ToString(), ex));
            }
            return(null);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
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);
            }
        }