Ejemplo n.º 1
0
        private bool RequestBlockModeInStore()
        {
            Exception ex = null;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(this.LocalNodeName))
            {
                try
                {
                    newStoreControllerInstance.StartBlockModeReplicationToPassive(this.Database.DatabaseGuid, this.m_clientNodeName, (uint)this.m_currentLogGeneration);
                    this.EnteredBlockMode = true;
                    LogCopyServerContext.Tracer.TraceDebug <string, long>((long)this.GetHashCode(), "BlockMode entered for copy '{0}' at 0x{1:X}", this.PassiveCopyName, this.m_currentLogGeneration);
                    return(true);
                }
                catch (MapiPermanentException ex2)
                {
                    ex = ex2;
                }
                catch (MapiRetryableException ex3)
                {
                    ex = ex3;
                }
                if (ex != null)
                {
                    LogCopyServerContext.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "EnterBlockMode({0}) failed from store: {1}", this.PassiveCopyName, ex);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        private Exception ListMdbStatus(IStoreRpc rpcAdmin, Guid[] dbGuids, out MdbStatus[] status)
        {
            Exception result = null;

            status = null;
            TDataObject dataObject = base.DataObject;

            try
            {
                status = rpcAdmin.ListMdbStatus(dbGuids);
            }
            catch (MapiExceptionNetworkError mapiExceptionNetworkError)
            {
                result = mapiExceptionNetworkError;
            }
            catch (MapiExceptionNotFound mapiExceptionNotFound)
            {
                result = mapiExceptionNotFound;
            }
            catch (MapiRetryableException ex)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorFailedToUnmountDatabase(dataObject.Identity.ToString(), ex.Message)), ErrorCategory.InvalidOperation, dataObject.Identity);
            }
            catch (MapiPermanentException ex2)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorFailedToUnmountDatabase(dataObject.Identity.ToString(), ex2.Message)), ErrorCategory.InvalidOperation, dataObject.Identity);
            }
            return(result);
        }
Ejemplo n.º 3
0
        protected void CheckDatabaseStatus()
        {
            TDataObject dataObject = base.DataObject;

            this.server = dataObject.GetServer();
            if (this.server == null)
            {
                TDataObject dataObject2 = base.DataObject;
                this.WriteWarning(Strings.ErrorDBOwningServerNotFound(dataObject2.Identity.ToString()));
                return;
            }
            TDataObject dataObject3 = base.DataObject;

            base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(this.server.Fqdn));
            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(this.server.Fqdn))
            {
                base.WriteVerbose(Strings.VerboseCheckDatabaseStatus(dataObject3.Identity.ToString()));
                Guid[] dbGuids = new Guid[]
                {
                    dataObject3.Guid
                };
                MdbStatus[] array;
                if (this.ListMdbStatus(newStoreControllerInstance, dbGuids, out array) == null)
                {
                    if (array.Length == 0)
                    {
                        TaskLogger.Trace("The database being removed does not have storage", new object[0]);
                    }
                    else if (MdbStatusFlags.Backup == (array[0].Status & MdbStatusFlags.Backup))
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorBackupInProgress(dataObject3.Name)), ErrorCategory.InvalidOperation, dataObject3.Identity);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        // Token: 0x0600049F RID: 1183 RVA: 0x00018E14 File Offset: 0x00017014
        public static Exception IsDatabaseMounted(Guid dbGuid, string activeNode, TimeSpan timeout, out bool isMounted)
        {
            isMounted = false;
            Exception result = null;
            bool      flag   = false;

            try
            {
                using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(activeNode))
                {
                    Guid[] dbGuids = new Guid[]
                    {
                        dbGuid
                    };
                    MdbStatus[] array = newStoreControllerInstance.ListMdbStatus(dbGuids);
                    if (array == null || array.Length == 0)
                    {
                        AmTrace.Error("IsDatabaseMounted got an empty result", new object[0]);
                    }
                    else if (array[0].Status.HasFlag(MdbStatusFlags.Online))
                    {
                        flag = true;
                    }
                    else
                    {
                        AmTrace.Error("IsDatabaseMounted got an non-online status for db {0} : {1}", new object[]
                        {
                            dbGuid,
                            array[0].Status
                        });
                    }
                }
                isMounted = flag;
            }
            catch (MapiPermanentException ex)
            {
                result = ex;
            }
            catch (MapiRetryableException ex2)
            {
                result = ex2;
            }
            return(result);
        }
Ejemplo n.º 5
0
        // Token: 0x060004A0 RID: 1184 RVA: 0x00018F04 File Offset: 0x00017104
        internal static bool IsStoreRunning(AmServerName serverName)
        {
            bool   flag = false;
            string text = AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(text))
            {
                LocalizedException ex;
                flag = newStoreControllerInstance.TestStoreConnectivity(newStoreControllerInstance.ConnectivityTimeout, out ex);
                if (!flag)
                {
                    AmTrace.Error("Ignoring exception in IsStoreRunning({0}): {1}", new object[]
                    {
                        text,
                        ex.Message
                    });
                }
            }
            return(flag);
        }
Ejemplo n.º 6
0
        // Token: 0x060001B2 RID: 434 RVA: 0x0000B0E0 File Offset: 0x000092E0
        private void DetermineWorkerProcessId(Guid mdbGuid)
        {
            Exception ex = null;

            try
            {
                using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(null))
                {
                    int processId;
                    int num;
                    int num2;
                    int num3;
                    newStoreControllerInstance.GetDatabaseProcessInfo(mdbGuid, out processId, out num, out num2, out num3);
                    ((ReplicaInstanceManager)this.m_replicaInstanceManager).SetWorkerProcessId(mdbGuid, processId);
                }
            }
            catch (MapiRetryableException ex2)
            {
                ex = ex2;
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
            }
            finally
            {
                if (ex != null)
                {
                    AmTrace.Error("DetermineWorkerProcessId caught {0}", new object[]
                    {
                        ex
                    });
                    ReplayEventLogConstants.Tuple_DetermineWorkerProcessIdFailed.LogEvent(Environment.MachineName, new object[]
                    {
                        mdbGuid,
                        ex
                    });
                }
            }
        }
Ejemplo n.º 7
0
        // Token: 0x06000495 RID: 1173 RVA: 0x00018778 File Offset: 0x00016978
        internal static void Mount(Guid mdbGuid, MountFlags flags)
        {
            bool flag = false;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(null))
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                bool isCheckDbStatus = true;
                bool flag2           = false;
                for (;;)
                {
                    ReplayCrimsonEvents.MountStoreRpcInitiated.Log <Guid, MountFlags>(mdbGuid, flags);
                    Exception ex = null;
                    try
                    {
                        try
                        {
                            newStoreControllerInstance.MountDatabase(Guid.Empty, mdbGuid, (int)flags);
                            AmTrace.Info("rpcAdmin.MountDatabase({0}) successful.", new object[]
                            {
                                mdbGuid
                            });
                            isCheckDbStatus = false;
                            flag2           = true;
                            break;
                        }
                        catch (MapiExceptionMountInProgress mapiExceptionMountInProgress)
                        {
                            ex = mapiExceptionMountInProgress;
                            AmTrace.Error("rpcAdmin.MountDatabase({0}) encountered {1}.", new object[]
                            {
                                mdbGuid,
                                mapiExceptionMountInProgress.Message
                            });
                            if (!flag)
                            {
                                ReplayCrimsonEvents.MountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, mapiExceptionMountInProgress.Message);
                                flag = true;
                            }
                            if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                            {
                                throw;
                            }
                            if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                            {
                                AmTrace.Debug("shutdown requested - hence not retrying mount for database {0}", new object[]
                                {
                                    mdbGuid
                                });
                                throw;
                            }
                        }
                        catch (MapiPermanentException ex2)
                        {
                            ex = ex2;
                            throw;
                        }
                        catch (MapiRetryableException ex3)
                        {
                            ex = ex3;
                            throw;
                        }
                        continue;
                    }
                    finally
                    {
                        if (flag2)
                        {
                            ReplayCrimsonEvents.MountStoreRpcSucceeded.Log <Guid>(mdbGuid);
                        }
                        else if (ex == null || !(ex is MapiExceptionMountInProgress))
                        {
                            ReplayCrimsonEvents.MountStoreRpcFailed.Log <Guid, string, Exception>(mdbGuid, (ex != null) ? ex.Message : null, ex);
                        }
                        AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, flag2, isCheckDbStatus);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 8
0
        protected void DismountDatabase()
        {
            TDataObject dataObject = base.DataObject;

            base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(this.server.Fqdn));
            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(this.server.Fqdn))
            {
                base.WriteVerbose(Strings.VerboseCheckDatabaseStatus(dataObject.Identity.ToString()));
                Guid[] dbGuids = new Guid[]
                {
                    dataObject.Guid
                };
                bool        flag = false;
                MdbStatus[] array;
                if (this.ListMdbStatus(newStoreControllerInstance, dbGuids, out array) == null)
                {
                    if (array == null || array.Length == 0)
                    {
                        TaskLogger.Trace("The database being removed does not have storage", new object[0]);
                        return;
                    }
                    if (MdbStatusFlags.Backup == (array[0].Status & MdbStatusFlags.Backup))
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorBackupInProgress(dataObject.Name)), ErrorCategory.InvalidOperation, dataObject.Identity);
                    }
                    else if (MdbStatusFlags.Online == (array[0].Status & MdbStatusFlags.Online))
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    base.WriteVerbose(Strings.VerboseUnmountDatabase(this.Identity.ToString()));
                    TDataObject dataObject2 = base.DataObject;
                    if (dataObject2.IsExchange2009OrLater)
                    {
                        try
                        {
                            AmRpcClientHelper.DismountDatabase(ADObjectWrapperFactory.CreateWrapper(base.DataObject), 0);
                            goto IL_300;
                        }
                        catch (AmServerException ex)
                        {
                            Exception ex2;
                            if (ex.TryGetExceptionOrInnerOfType(out ex2))
                            {
                                TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[]
                                {
                                    ex2.Message
                                });
                            }
                            else if (ex.TryGetExceptionOrInnerOfType(out ex2))
                            {
                                TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[]
                                {
                                    ex2.Message
                                });
                            }
                            else if (ex.TryGetExceptionOrInnerOfType(out ex2))
                            {
                                TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[]
                                {
                                    ex2.Message
                                });
                            }
                            else if (ex.TryGetExceptionOrInnerOfType(out ex2))
                            {
                                TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[]
                                {
                                    ex2.Message
                                });
                            }
                            else if (ex.TryGetExceptionOrInnerOfType(out ex2))
                            {
                                TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[]
                                {
                                    ex2.Message
                                });
                            }
                            else
                            {
                                TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[]
                                {
                                    ex.Message
                                });
                                Exception     exception   = ex;
                                ErrorCategory category    = ErrorCategory.InvalidOperation;
                                TDataObject   dataObject3 = base.DataObject;
                                base.WriteError(exception, category, dataObject3.Identity);
                            }
                            goto IL_300;
                        }
                        catch (AmServerTransientException ex3)
                        {
                            TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while dismounting database: {0}", new object[]
                            {
                                ex3.Message
                            });
                            Exception     exception2  = ex3;
                            ErrorCategory category2   = ErrorCategory.InvalidOperation;
                            TDataObject   dataObject4 = base.DataObject;
                            base.WriteError(exception2, category2, dataObject4.Identity);
                            goto IL_300;
                        }
                    }
                    IConfigDataProvider        dataSession = base.DataSession;
                    TDataObject                dataObject5 = base.DataObject;
                    LegacyPublicFolderDatabase legacyPublicFolderDatabase = (LegacyPublicFolderDatabase)dataSession.Read <LegacyPublicFolderDatabase>(dataObject5.Identity);
                    StorageGroup               storageGroup = (StorageGroup)base.DataSession.Read <StorageGroup>(legacyPublicFolderDatabase.StorageGroup);
                    newStoreControllerInstance.UnmountDatabase(storageGroup.Guid, legacyPublicFolderDatabase.Guid, 0);
                }
                IL_300 :;
            }
        }