Beispiel #1
0
        // Token: 0x06001AC6 RID: 6854 RVA: 0x00072EDC File Offset: 0x000710DC
        public void SendDatabaseFile()
        {
            ReplayStopwatch replayStopwatch = new ReplayStopwatch();

            replayStopwatch.Start();
            bool           flag           = false;
            SafeFileHandle safeFileHandle = null;

            try
            {
                this.TraceDebug("PassiveSeedDatabaseFileRequest. Opening up the backup context for {0}.", new object[]
                {
                    this.DatabaseGuid
                });
                MonitoredDatabase monitoredDatabase = this.GetMonitoredDatabase();
                string            databaseFullPath  = monitoredDatabase.GetDatabaseFullPath();
                int num = 0;
                for (;;)
                {
                    this.CheckSeedingCancelled();
                    try
                    {
                        using (IStoreMountDismount storeMountDismountInstance = Dependencies.GetStoreMountDismountInstance(null))
                        {
                            storeMountDismountInstance.UnmountDatabase(Guid.Empty, monitoredDatabase.Config.IdentityGuid, 16);
                            this.TraceDebug("dismounted the replayer database", new object[0]);
                        }
                    }
                    catch (MapiExceptionNotFound)
                    {
                        this.TraceDebug("replay database is not mounted", new object[0]);
                    }
                    catch (MapiExceptionTimeout mapiExceptionTimeout)
                    {
                        this.TraceError("Rethrowing timeout exception: {0}", new object[]
                        {
                            mapiExceptionTimeout
                        });
                        throw;
                    }
                    catch (MapiRetryableException ex)
                    {
                        if (num++ < 3)
                        {
                            this.TraceDebug("got {0}, but we will keep retrying for 3 times", new object[]
                            {
                                ex.ToString()
                            });
                            Thread.Sleep(1000);
                            continue;
                        }
                        throw;
                    }
                    catch (MapiPermanentException ex2)
                    {
                        if (num++ < 3)
                        {
                            this.TraceDebug("got {0}, but we will keep retrying for 3 times", new object[]
                            {
                                ex2.ToString()
                            });
                            Thread.Sleep(1000);
                            continue;
                        }
                        throw;
                    }
                    break;
                }
                safeFileHandle = this.OpenFile(databaseFullPath, true);
                this.m_passiveDatabaseStream = SeederServerContext.OpenFileStream(safeFileHandle, true);
                SeedDatabaseFileReply seedDatabaseFileReply = new SeedDatabaseFileReply(this.m_channel);
                seedDatabaseFileReply.FileSize     = new FileInfo(databaseFullPath).Length;
                seedDatabaseFileReply.LastWriteUtc = DateTime.UtcNow;
                seedDatabaseFileReply.Send();
                ExTraceGlobals.SeederServerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "PassiveSeedDatabaseFileRequest. Sending the data for {0}.", this.DatabaseGuid);
                this.m_channel.SendSeedingDataTransferReply(seedDatabaseFileReply, new ReadDatabaseCallback(this.ReadDbCallback));
                flag = true;
            }
            finally
            {
                if (this.m_passiveDatabaseStream != null)
                {
                    this.m_passiveDatabaseStream.Dispose();
                }
                ExTraceGlobals.SeederServerTracer.TraceDebug <long, string>((long)this.GetHashCode(), "PassiveSeedDatabaseFile finished streaming after {0} sec. Operation successful: {1}", replayStopwatch.ElapsedMilliseconds / 1000L, flag.ToString());
                if (safeFileHandle != null)
                {
                    safeFileHandle.Dispose();
                }
            }
        }
Beispiel #2
0
        public override void Execute()
        {
            string databaseName    = base.Channel.MonitoredDatabase.DatabaseName;
            string partnerNodeName = base.Channel.PartnerNodeName;

            ExTraceGlobals.SeederServerTracer.TraceDebug <string, uint>((long)this.GetHashCode(), "SeedDatabaseFileRequest({0}): readHintSize ({1}).", databaseName, this.m_readHintSize);
            bool flag = false;

            base.Channel.IsSeeding = true;
            Exception ex = null;

            try
            {
                base.Channel.CreateSeederServerContext(base.DatabaseGuid, null, SeedType.Database);
                ExTraceGlobals.SeederServerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "SeedDatabaseFileRequest. Opening up the backup context for {0}.", base.DatabaseGuid);
                long fileSize;
                this.m_backupHandle = SeedDatabaseFileRequest.OpenSeedStreamer(base.DatabaseGuid, this.m_readHintSize, out fileSize);
                SeedDatabaseFileReply seedDatabaseFileReply = new SeedDatabaseFileReply(base.Channel);
                seedDatabaseFileReply.FileSize     = fileSize;
                seedDatabaseFileReply.LastWriteUtc = DateTime.UtcNow;
                seedDatabaseFileReply.Send();
                ExTraceGlobals.SeederServerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "SeedDatabaseFileRequest. Sending the data for {0}.", base.DatabaseGuid);
                ExTraceGlobals.FaultInjectionTracer.TraceTest(3343265085U);
                base.Channel.SendSeedingDataTransferReply(seedDatabaseFileReply, new ReadDatabaseCallback(this.ReadDbCallback));
                flag = true;
            }
            catch (OperationCanceledException ex2)
            {
                ex = ex2;
            }
            catch (SeedingChannelIsClosedException ex3)
            {
                ex = ex3;
            }
            catch (SeedingSourceReplicaInstanceNotFoundException ex4)
            {
                ex = ex4;
            }
            catch (IOException ex5)
            {
                ex = ex5;
            }
            catch (FailedToOpenBackupFileHandleException ex6)
            {
                ex = ex6;
            }
            catch (FileIOonSourceException ex7)
            {
                ex = ex7;
            }
            catch (NetworkTransportException ex8)
            {
                ex = ex8;
            }
            catch (ADExternalException ex9)
            {
                ex = ex9;
            }
            catch (ADOperationException ex10)
            {
                ex = ex10;
            }
            catch (ADTransientException ex11)
            {
                ex = ex11;
            }
            catch (TaskServerException ex12)
            {
                ex = ex12;
            }
            catch (TransientException ex13)
            {
                ex = ex13;
            }
            finally
            {
                if (ex != null)
                {
                    ExTraceGlobals.SeederServerTracer.TraceError <string, Exception>((long)this.GetHashCode(), "SeedDatabaseFileRequest({0}): Failed: {1}", databaseName, ex);
                    ReplayCrimsonEvents.ActiveSeedSourceFailedToSendEDB.Log <string, string, string, string>(databaseName, Environment.MachineName, partnerNodeName, ex.ToString());
                }
                if (this.m_backupHandle != null)
                {
                    int lastError = flag ? 0 : 42;
                    this.m_backupHandle.SetLastError(lastError);
                    this.m_backupHandle.Close();
                    this.m_backupHandle = null;
                }
                if (ex != null)
                {
                    if (ex is NetworkTransportException)
                    {
                        base.Channel.KeepAlive = false;
                    }
                    else
                    {
                        base.Channel.SendException(ex);
                    }
                }
            }
        }