示例#1
0
        public void Initialize(long logGeneration, string logPath, string prefix, string suffix)
        {
            string text = Path.Combine(logPath, EseHelper.MakeLogfileName(prefix, suffix, logGeneration));

            this.Initialized = false;
            try
            {
                JET_LOGINFOMISC logInfo;
                UnpublishedApi.JetGetLogFileInfo(text, out logInfo, JET_LogInfo.Misc2);
                LocalizedString localizedString;
                this.Examine(logInfo, text, out localizedString);
            }
            catch (EsentErrorException ex)
            {
                LogContinuityChecker.Tracer.TraceError <string, EsentErrorException>((long)this.GetHashCode(), "LogContinuityChecker failed to init with '{0}': {1}", text, ex);
                throw new LogInspectorFailedGeneralException(text, ex.Message, ex);
            }
        }
示例#2
0
        public static Exception Verify(string fileName, string logFilePrefix, long expectedGen, JET_SIGNATURE?expectedLogSignature)
        {
            LogVerifier         logVerifier = new LogVerifier(logFilePrefix);
            EsentErrorException ex          = logVerifier.Verify(fileName);

            if (ex != null)
            {
                return(ex);
            }
            JET_LOGINFOMISC jet_LOGINFOMISC;

            UnpublishedApi.JetGetLogFileInfo(fileName, out jet_LOGINFOMISC, JET_LogInfo.Misc2);
            if ((long)jet_LOGINFOMISC.ulGeneration != expectedGen)
            {
                return(new FileCheckLogfileGenerationException(fileName, (long)jet_LOGINFOMISC.ulGeneration, expectedGen));
            }
            if (expectedLogSignature != null && !jet_LOGINFOMISC.signLog.Equals(expectedLogSignature))
            {
                return(new FileCheckLogfileSignatureException(fileName, jet_LOGINFOMISC.signLog.ToString(), expectedLogSignature.ToString()));
            }
            return(null);
        }
        internal void SendLog(long logGen, NetworkChannel channel, SourceDatabasePerformanceCountersInstance perfCounters)
        {
            ReplayStopwatch replayStopwatch = new ReplayStopwatch();

            replayStopwatch.Start();
            string    text = this.BuildLogFileName(logGen);
            Exception ex   = null;

            try
            {
                using (SafeFileHandle safeFileHandle = LogCopy.OpenLogForRead(text))
                {
                    try
                    {
                        JET_LOGINFOMISC jet_LOGINFOMISC;
                        UnpublishedApi.JetGetLogFileInfo(text, out jet_LOGINFOMISC, JET_LogInfo.Misc2);
                        if (logGen != 0L && (long)jet_LOGINFOMISC.ulGeneration != logGen)
                        {
                            FileCheckLogfileGenerationException ex2 = new FileCheckLogfileGenerationException(text, (long)jet_LOGINFOMISC.ulGeneration, logGen);
                            CorruptLogDetectedException         ex3 = new CorruptLogDetectedException(text, ex2.Message, ex2);
                            throw new FileIOonSourceException(Environment.MachineName, text, ex3.Message, ex3);
                        }
                        JET_SIGNATURE?jet_SIGNATURE = null;
                        lock (this.m_sigLock)
                        {
                            if (this.m_logfileSignature == null)
                            {
                                this.m_logfileSignature = new JET_SIGNATURE?(jet_LOGINFOMISC.signLog);
                            }
                            jet_SIGNATURE = this.m_logfileSignature;
                        }
                        if (!jet_LOGINFOMISC.signLog.Equals(jet_SIGNATURE))
                        {
                            FileCheckLogfileSignatureException ex4 = new FileCheckLogfileSignatureException(text, jet_LOGINFOMISC.signLog.ToString(), jet_SIGNATURE.Value.ToString());
                            CorruptLogDetectedException        ex5 = new CorruptLogDetectedException(text, ex4.Message, ex4);
                            throw new FileIOonSourceException(Environment.MachineName, text, ex5.Message, ex5);
                        }
                    }
                    catch (EsentLogFileCorruptException ex6)
                    {
                        CorruptLogDetectedException ex7 = new CorruptLogDetectedException(text, ex6.Message, ex6);
                        throw new FileIOonSourceException(Environment.MachineName, text, ex7.Message, ex7);
                    }
                    EndOfLog     currentEndOfLog = this.CurrentEndOfLog;
                    CopyLogReply copyLogReply    = new CopyLogReply(channel);
                    copyLogReply.ThisLogGeneration  = logGen;
                    copyLogReply.EndOfLogGeneration = currentEndOfLog.Generation;
                    copyLogReply.EndOfLogUtc        = currentEndOfLog.Utc;
                    CheckSummer summer = null;
                    if (channel.ChecksumDataTransfer)
                    {
                        summer = new CheckSummer();
                    }
                    channel.SetupLogChecksummer(this.Config.LogFilePrefix);
                    channel.SendLogFileTransferReply(copyLogReply, text, safeFileHandle, perfCounters, summer);
                    MonitoredDatabase.Tracer.TracePerformance <long>((long)this.GetHashCode(), "CopyLogFile finished streaming after {0}ms.", replayStopwatch.ElapsedMilliseconds);
                }
            }
            catch (IOException ex8)
            {
                ex = ex8;
            }
            catch (UnauthorizedAccessException ex9)
            {
                ex = ex9;
            }
            catch (EsentErrorException ex10)
            {
                ex = ex10;
            }
            if (ex != null)
            {
                ExTraceGlobals.MonitoredDatabaseTracer.TraceError <string, Exception>((long)this.GetHashCode(), "SendLog({0}) failed: {1}", text, ex);
                throw new FileIOonSourceException(Environment.MachineName, text, ex.Message, ex);
            }
        }
示例#4
0
        // Token: 0x06001D67 RID: 7527 RVA: 0x00084D0C File Offset: 0x00082F0C
        private Exception VerifyLog(string fullLocalFileName, long expectedGen)
        {
            Exception ex = null;

            try
            {
                ReplayStopwatch replayStopwatch = new ReplayStopwatch();
                replayStopwatch.Start();
                using (SafeFileHandle safeFileHandle = LogCopy.OpenLogForRead(fullLocalFileName))
                {
                    long arg = replayStopwatch.ElapsedMilliseconds;
                    LogRepair.Tracer.TracePerformance <string, long>((long)this.GetHashCode(), "VerifyLog({0}): Open took: {1} ms", fullLocalFileName, arg);
                    using (FileStream fileStream = LogCopy.OpenFileStream(safeFileHandle, true))
                    {
                        FileInfo fileInfo = new FileInfo(fullLocalFileName);
                        long     elapsedMilliseconds;
                        try
                        {
                            if (fileInfo.Length != 1048576L)
                            {
                                throw new IOException(string.Format("Unexpected log file size: '{0}' has 0x{1:X} bytes.", fullLocalFileName, fileInfo.Length));
                            }
                            elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds;
                            int num = fileStream.Read(this.m_verifierLogDataBuf, 0, 1048576);
                            if (num != 1048576)
                            {
                                LogRepair.Tracer.TraceError <int, int, string>((long)this.GetHashCode(), "VerifyLog. Expected {0} but got {1} bytes from {2}", 1048576, num, fullLocalFileName);
                                throw new IOException(ReplayStrings.UnexpectedEOF(fullLocalFileName));
                            }
                            arg = replayStopwatch.ElapsedMilliseconds - elapsedMilliseconds;
                            LogRepair.Tracer.TracePerformance <string, long>((long)this.GetHashCode(), "VerifyLog({0}): Read took: {1} ms", fullLocalFileName, arg);
                        }
                        catch (IOException ex2)
                        {
                            throw new CorruptLogDetectedException(fullLocalFileName, ex2.Message, ex2);
                        }
                        elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds;
                        EsentErrorException ex3 = this.EseLogVerifier.Verify(fullLocalFileName, this.m_verifierLogDataBuf);
                        if (ex3 != null)
                        {
                            LogRepair.Tracer.TraceError <string, EsentErrorException>((long)this.GetHashCode(), "ESELogVerifier({0}) failed: {1}", fullLocalFileName, ex3);
                            if (ex3 is EsentLogFileCorruptException)
                            {
                                throw new CorruptLogDetectedException(fullLocalFileName, ex3.Message, ex3);
                            }
                            throw ex3;
                        }
                        else
                        {
                            JET_LOGINFOMISC jet_LOGINFOMISC;
                            UnpublishedApi.JetGetLogFileInfo(fullLocalFileName, out jet_LOGINFOMISC, JET_LogInfo.Misc2);
                            if ((long)jet_LOGINFOMISC.ulGeneration != expectedGen)
                            {
                                throw new FileCheckLogfileGenerationException(fullLocalFileName, (long)jet_LOGINFOMISC.ulGeneration, expectedGen);
                            }
                            if (this.m_logfileSignature == null)
                            {
                                this.m_logfileSignature = new JET_SIGNATURE?(jet_LOGINFOMISC.signLog);
                            }
                            if (!jet_LOGINFOMISC.signLog.Equals(this.m_logfileSignature))
                            {
                                throw new FileCheckLogfileSignatureException(fullLocalFileName, jet_LOGINFOMISC.signLog.ToString(), this.m_logfileSignature.ToString());
                            }
                            arg = replayStopwatch.ElapsedMilliseconds - elapsedMilliseconds;
                            LogRepair.Tracer.TracePerformance <string, long>((long)this.GetHashCode(), "VerifyLog({0}): Verify took: {1} ms", fullLocalFileName, arg);
                            return(null);
                        }
                    }
                }
            }
            catch (IOException ex4)
            {
                ex = ex4;
            }
            catch (UnauthorizedAccessException ex5)
            {
                ex = ex5;
            }
            catch (EsentErrorException ex6)
            {
                ex = ex6;
            }
            catch (CorruptLogDetectedException ex7)
            {
                ex = ex7;
            }
            catch (FileCheckException ex8)
            {
                ex = ex8;
            }
            if (ex != null)
            {
                LogRepair.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "VerifyLog({0}): failed with {1}", fullLocalFileName, ex);
            }
            return(ex);
        }
 // Token: 0x06000969 RID: 2409 RVA: 0x0002C435 File Offset: 0x0002A635
 public static long GetLogfileGeneration(string logfilePath, out JET_LOGINFOMISC logInfo)
 {
     UnpublishedApi.JetGetLogFileInfo(logfilePath, out logInfo, JET_LogInfo.Misc2);
     return((long)logInfo.ulGeneration);
 }