Exemplo n.º 1
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);
        }
        // Token: 0x06001A2C RID: 6700 RVA: 0x0006DC38 File Offset: 0x0006BE38
        protected override bool ReleaseHandle()
        {
            bool result = true;

            if (!this.IsInvalid)
            {
                if (this.m_backupFileHandle != IntPtr.Zero)
                {
                    int num = CReplicaSeederInterop.CloseBackupFileHandle(this.handle, this.m_backupFileHandle);
                    this.m_backupFileHandle = IntPtr.Zero;
                    if (num != 0)
                    {
                        ExTraceGlobals.SeederServerTracer.TraceError <string, int>((long)this.GetHashCode(), "CloseBackupFileHandle() for database '{0}' failed with error code {1}", base.DatabaseName, num);
                        ReplayCrimsonEvents.BackupHandleCloseFailed.Log <Guid, string, string>(base.DatabaseGuid, base.DatabaseName, string.Format("CloseBackupFileHandle() failed with error code {0}", num));
                    }
                }
                result = base.ReleaseHandle();
                base.SetHandleAsInvalid();
                EseDatabaseBackupReader.CleanupNativeLogger();
            }
            return(result);
        }
        // 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);
        }