// Token: 0x06000954 RID: 2388 RVA: 0x0002BBE8 File Offset: 0x00029DE8
        public static IEseDatabaseReader GetRemoteEseDatabaseReader(string serverName, Guid databaseGuid, bool useClassicEseback)
        {
            string text;
            string text2;

            SeedHelper.GetDatabaseNameAndPath(databaseGuid, out text, out text2);
            if (useClassicEseback)
            {
                return(EseDatabaseReader.GetEseDatabaseReader(serverName, databaseGuid, text, text2));
            }
            return(new RemoteEseDatabaseReader(serverName, databaseGuid, text, text2));
        }
        // Token: 0x06001B23 RID: 6947 RVA: 0x0007518C File Offset: 0x0007338C
        private void HandleError()
        {
            this.m_progressFailed();
            Exception exception = this.GetException();
            string    error;

            if (SeedHelper.IsPerformingFastOperationException(exception as SeederServerException, out error))
            {
                this.m_writeWarning(ReplayStrings.WarningPerformingFastOperationException(this.m_databaseName, error));
                return;
            }
            this.m_writeError(exception, ErrorCategory.InvalidOperation, null);
        }
Esempio n. 3
0
        internal static bool IsDbPendingLcrRcrTarget(Guid guid, out IADDatabaseAvailabilityGroup dag, out IADDatabase db, out IADServer server)
        {
            IADConfig adconfig = Dependencies.ADConfig;

            dag    = adconfig.GetLocalDag();
            db     = adconfig.GetDatabase(guid);
            server = adconfig.GetLocalServer();
            if (db != null && server != null && SeedHelper.IsDatabasePendingRcrTarget(db, server))
            {
                ExTraceGlobals.SeederServerTracer.TraceDebug <string, Guid>(0L, "SeedHelper.IsDbPendingLcrRcrTarget(): The Replica Instance for Database '{0}' ({1})has not yet been started, but the DB is configured as an RCR target on the local machine.", db.Name, guid);
                return(true);
            }
            ExTraceGlobals.SeederServerTracer.TraceDebug <string, Guid>(0L, "SeedHelper.IsDbPendingLcrRcrTarget(): Database '{0}' ({1}) is not a valid LCR/RCR replica target.", (db != null) ? db.Name : "<null>", guid);
            return(false);
        }
Esempio n. 4
0
        private static EseDatabaseBackupReader OpenSeedStreamer(Guid dbGuid, uint readHintSize, out long initialFileSizeBytes)
        {
            string machineName = Environment.MachineName;

            initialFileSizeBytes = 0L;
            string dbName;
            string sourceFileToBackupFullPath;

            SeedHelper.GetDatabaseNameAndPath(dbGuid, out dbName, out sourceFileToBackupFullPath);
            CReplicaSeederInterop.SetupNativeLogger();
            EseDatabaseBackupReader esedatabaseBackupReader = EseDatabaseBackupReader.GetESEDatabaseBackupReader(machineName, dbName, dbGuid, null, sourceFileToBackupFullPath, readHintSize);

            initialFileSizeBytes = esedatabaseBackupReader.SourceFileSizeBytes;
            return(esedatabaseBackupReader);
        }
Esempio n. 5
0
        internal static bool IsDbPendingLcrRcrTarget(Guid guid, out ReplayConfiguration replayConfig, out bool fSource)
        {
            replayConfig = null;
            fSource      = false;
            IADDatabaseAvailabilityGroup dag;
            IADDatabase db;
            IADServer   server;
            bool        flag = SeedHelper.IsDbPendingLcrRcrTarget(guid, out dag, out db, out server);

            if (flag)
            {
                replayConfig = RemoteReplayConfiguration.TaskGetReplayConfig(dag, db, server);
                fSource      = (replayConfig.Type == ReplayConfigType.RemoteCopySource);
            }
            return(flag);
        }
        // Token: 0x06001A2F RID: 6703 RVA: 0x0006DD74 File Offset: 0x0006BF74
        public static EseDatabaseBackupReader GetESEDatabaseBackupReader(string serverName, string dbName, Guid dbGuid, string transferAddress, string sourceFileToBackupFullPath, uint readHintSizeBytes)
        {
            bool   flag  = false;
            int    num   = 0;
            IntPtr value = new IntPtr(-1);
            EseDatabaseBackupReader eseDatabaseBackupReader = new EseDatabaseBackupReader(dbName, dbGuid);
            SafeBackupContextHandle safeBackupContextHandle = eseDatabaseBackupReader;
            EseDatabaseBackupReader result;

            try
            {
                EseDatabaseBackupReader.SetupNativeLogger();
                SafeBackupContextHandle.GetAndSetIntPtrInCER(serverName, dbName, transferAddress, ref safeBackupContextHandle);
                flag = true;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                }
                finally
                {
                    num = CReplicaSeederInterop.OpenBackupFileHandle(eseDatabaseBackupReader.handle, sourceFileToBackupFullPath, readHintSizeBytes, out eseDatabaseBackupReader.m_backupFileHandle, out eseDatabaseBackupReader.m_sourceFileSizeBytes);
                }
                if (num != 0 || eseDatabaseBackupReader.m_backupFileHandle == IntPtr.Zero || eseDatabaseBackupReader.m_backupFileHandle == value)
                {
                    eseDatabaseBackupReader.Close();
                    throw new FailedToOpenBackupFileHandleException(dbName, serverName, num, SeedHelper.TranslateSeederErrorCode((long)num, serverName));
                }
                result = eseDatabaseBackupReader;
            }
            finally
            {
                if (!flag)
                {
                    EseDatabaseBackupReader.CleanupNativeLogger();
                }
            }
            return(result);
        }
Esempio n. 7
0
        // Token: 0x0600094D RID: 2381 RVA: 0x0002B9FC File Offset: 0x00029BFC
        protected static void GetAndSetIntPtrInCER(string serverName, string dbName, string transferAddress, ref SafeBackupContextHandle backupHandle)
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr value = new IntPtr(-1);
            bool   flag  = false;
            int    num   = 0;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                num  = backupHandle.GetBackupContextIntPtr(serverName, dbName, transferAddress, out zero);
                flag = (num == 0 && zero != IntPtr.Zero && zero != value);
                if (flag)
                {
                    backupHandle.SetHandle(zero);
                }
            }
            if (!flag)
            {
                throw new FailedToOpenBackupFileHandleException(dbName, serverName, num, SeedHelper.TranslateSeederErrorCode((long)num, serverName));
            }
        }
Esempio n. 8
0
        // Token: 0x06001B19 RID: 6937 RVA: 0x00074918 File Offset: 0x00072B18
        private void CheckDbValidReplicationTarget(RpcSeederArgs seederArgs, out ReplayConfiguration replayConfig)
        {
            replayConfig = null;
            ADReplicationRetryTimer adreplicationRetryTimer = new ADReplicationRetryTimer();
            bool flag = !seederArgs.SeedDatabase && seederArgs.SeedCiFiles;

            try
            {
                bool flag2;
                while (!this.IsDBCurrentReplicaInstance(seederArgs.InstanceGuid, out replayConfig, out flag2))
                {
                    if (SeedHelper.IsDbPendingLcrRcrTarget(seederArgs.InstanceGuid, out replayConfig, out flag2))
                    {
                        if (flag2)
                        {
                            if (flag)
                            {
                                ExTraceGlobals.SeederServerTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "SeedManager: Database '{0}' ({1}) is not a valid RCR replica target but the requested seeding is CI only.", replayConfig.Name, seederArgs.InstanceGuid);
                                return;
                            }
                            this.HandleDbCopyNotTarget(seederArgs, replayConfig);
                        }
                        ExTraceGlobals.SeederServerTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "SeedManager: Database '{0}' ({1}) is a valid RCR replica target.", replayConfig.Name, seederArgs.InstanceGuid);
                        return;
                    }
                    ExTraceGlobals.SeederServerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "SeedManager: Database '{0}' is NOT a valid RCR replica target!", seederArgs.InstanceGuid);
                    if (adreplicationRetryTimer.IsExpired)
                    {
                        throw new InvalidDbForSeedSpecifiedException();
                    }
                    adreplicationRetryTimer.Sleep();
                }
                if (flag2)
                {
                    if (flag)
                    {
                        ExTraceGlobals.SeederServerTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "SeedManager: Database '{0}' ({1}) is not running as a valid RCR replica target but the requested seeding is CI only.", replayConfig.Name, seederArgs.InstanceGuid);
                        return;
                    }
                    this.HandleDbCopyNotTarget(seederArgs, replayConfig);
                }
                ExTraceGlobals.SeederServerTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "SeedManager: Database '{0}' ({1}) is currently running as a valid RCR replica target.", replayConfig.Name, seederArgs.InstanceGuid);
            }
            catch (DataSourceOperationException ex)
            {
                ExTraceGlobals.SeederServerTracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "SeedManager: CheckDBValidReplicationTarget: Exception encountered: {0}", ex);
                throw new SeedPrepareException(ex.ToString(), ex);
            }
            catch (DataValidationException ex2)
            {
                ExTraceGlobals.SeederServerTracer.TraceError <DataValidationException>((long)this.GetHashCode(), "SeedManager: CheckDBValidReplicationTarget: Exception encountered: {0}", ex2);
                throw new SeedPrepareException(ex2.ToString(), ex2);
            }
            catch (ObjectNotFoundException ex3)
            {
                ExTraceGlobals.SeederServerTracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "SeedManager: CheckDBValidReplicationTarget: Exception encountered: {0}", ex3);
                throw new SeedPrepareException(ex3.ToString(), ex3);
            }
            catch (StoragePermanentException ex4)
            {
                ExTraceGlobals.SeederServerTracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "SeedManager: CheckDBValidReplicationTarget: Exception encountered: {0}", ex4);
                throw new SeedPrepareException(ex4.ToString(), ex4);
            }
            catch (TransientException ex5)
            {
                ExTraceGlobals.SeederServerTracer.TraceError <TransientException>((long)this.GetHashCode(), "SeedManager: CheckDBValidReplicationTarget: Exception encountered: {0}", ex5);
                throw new SeedPrepareException(ex5.ToString(), ex5);
            }
        }
Esempio n. 9
0
        public static string TranslateEsebackErrorCode(long ec, long dwExtError)
        {
            uint   num     = (uint)ec;
            int    extcode = (int)dwExtError;
            string result  = null;
            uint   num2    = num;

            if (num2 <= 3355379671U)
            {
                if (num2 <= 3355378867U)
                {
                    if (num2 == 1293U)
                    {
                        return(ReplayStrings.SeederEcBackupInProgress);
                    }
                    if (num2 != 3355378867U)
                    {
                        goto IL_10C;
                    }
                }
                else
                {
                    if (num2 == 3355379665U)
                    {
                        return(ReplayStrings.FailedToOpenShipLogContextInvalidParameter);
                    }
                    if (num2 != 3355379671U)
                    {
                        goto IL_10C;
                    }
                    return(ReplayStrings.FailedToOpenShipLogContextStoreStopped);
                }
            }
            else if (num2 <= 3355381669U)
            {
                if (num2 == 3355379675U)
                {
                    return(ReplayStrings.FailedToOpenShipLogContextEseCircularLoggingEnabled);
                }
                switch (num2)
                {
                case 3355381668U:
                    return(ReplayStrings.SeederEchrInvalidCallSequence);

                case 3355381669U:
                    return(ReplayStrings.SeederEchrRestoreAtFileLevel);

                default:
                    goto IL_10C;
                }
            }
            else
            {
                if (num2 == 3355444321U)
                {
                    return(ReplayStrings.EseBackFileSystemCorruption);
                }
                if (num2 != 3355444403U)
                {
                    if (num2 != 3355444505U)
                    {
                        goto IL_10C;
                    }
                    return(ReplayStrings.JetErrorDatabaseNotFound);
                }
            }
            return(ReplayStrings.FailedToOpenShipLogContextDatabaseNotMounted);

IL_10C:
            if (!SeedHelper.EseMessageIdToString(num, extcode, out result))
            {
                result = null;
            }
            return(result);
        }