// Token: 0x06000BB0 RID: 2992 RVA: 0x00034350 File Offset: 0x00032550
        public void LinkWithMonitoredDatabase(MonitoredDatabase curDatabase)
        {
            if (curDatabase.IsPassiveCopy)
            {
                bool flag = false;
                NetworkChannelMessage.MessageType type = base.Type;
                if (type <= NetworkChannelMessage.MessageType.ProgressCiFileRequest)
                {
                    if (type <= NetworkChannelMessage.MessageType.SeedLogCopyRequest)
                    {
                        if (type != NetworkChannelMessage.MessageType.CancelCiFileRequest && type != NetworkChannelMessage.MessageType.SeedLogCopyRequest)
                        {
                            goto IL_7C;
                        }
                    }
                    else if (type != NetworkChannelMessage.MessageType.PassiveDatabaseFileRequest && type != NetworkChannelMessage.MessageType.ProgressCiFileRequest)
                    {
                        goto IL_7C;
                    }
                }
                else if (type <= NetworkChannelMessage.MessageType.SeedCiFileRequest2)
                {
                    if (type != NetworkChannelMessage.MessageType.SeedCiFileRequest && type != NetworkChannelMessage.MessageType.SeedCiFileRequest2)
                    {
                        goto IL_7C;
                    }
                }
                else if (type != NetworkChannelMessage.MessageType.CancelCiFileReply && type != NetworkChannelMessage.MessageType.ProgressCiFileReply && type != NetworkChannelMessage.MessageType.SeedCiFileReply)
                {
                    goto IL_7C;
                }
                flag = true;
IL_7C:
                if (!flag)
                {
                    ExTraceGlobals.NetworkChannelTracer.TraceError <NetworkChannelMessage.MessageType, string, string>((long)this.GetHashCode(), "LinkWithMonitoredDatabase rejecting request {0} from {1} for database {2}", base.Type, base.Channel.PartnerNodeName, curDatabase.DatabaseName);
                    Exception ex = new SourceDatabaseNotFoundException(this.DatabaseGuid, Environment.MachineName);
                    base.Channel.SendException(ex);
                    throw ex;
                }
            }
            if (base.Channel.MonitoredDatabase != curDatabase)
            {
                if (base.Channel.MonitoredDatabase == null)
                {
                    base.Channel.MonitoredDatabase = curDatabase;
                    return;
                }
                if (curDatabase.DatabaseGuid != this.DatabaseGuid)
                {
                    ExTraceGlobals.NetworkChannelTracer.TraceError <Guid, string>(0L, "Unexpected dbguid: got: {0}, expected:{1}", this.DatabaseGuid, curDatabase.Identity);
                    base.Channel.ThrowUnexpectedMessage(this);
                }
                base.Channel.TraceDebug("Source instance must have restarted. Relinking to database {0}", new object[]
                {
                    curDatabase.DatabaseName
                });
                base.Channel.MonitoredDatabase = curDatabase;
            }
        }
Exemplo n.º 2
0
        public static void SetCopyProperty(Guid dbGuid, string propName, string propVal)
        {
            MonitoredDatabase monitoredDatabase = MonitoredDatabase.FindMonitoredDatabase(Environment.MachineName, dbGuid);

            if (monitoredDatabase == null)
            {
                throw new ArgumentException(string.Format("Monitored database '{0}' not active", dbGuid));
            }
            if (MonitoredDatabase.StringIEquals(propName, "TestGranularReplicationExceptionDuringAcll"))
            {
                bool testGranularReplicationExceptionDuringAcll;
                if (!bool.TryParse(propVal, out testGranularReplicationExceptionDuringAcll))
                {
                    throw new ArgumentException("TestGranularReplicationExceptionDuringAcll must be a bool");
                }
                monitoredDatabase.TestGranularReplicationExceptionDuringAcll = testGranularReplicationExceptionDuringAcll;
                return;
            }
            else
            {
                if (!MonitoredDatabase.StringIEquals(propName, "TestGranularReplicationDeliveryDelay"))
                {
                    throw new ArgumentException(string.Format("'{0}' is not recognized", propName));
                }
                int testGranularReplicationDeliveryDelay;
                if (!int.TryParse(propVal, out testGranularReplicationDeliveryDelay))
                {
                    throw new ArgumentException("TestGranularReplicationDeliveryDelay must be an int");
                }
                monitoredDatabase.TestGranularReplicationDeliveryDelay = testGranularReplicationDeliveryDelay;
                return;
            }
        }
Exemplo n.º 3
0
        // Token: 0x06001AC5 RID: 6853 RVA: 0x00072DCC File Offset: 0x00070FCC
        public void SendLogFiles()
        {
            MonitoredDatabase monitoredDatabase = this.GetMonitoredDatabase();
            string            suffix            = '.' + monitoredDatabase.Config.LogExtension;
            DirectoryInfo     di = new DirectoryInfo(monitoredDatabase.Config.SourceLogPath);
            long num             = ShipControl.HighestGenerationInDirectory(di, monitoredDatabase.Config.LogFilePrefix, suffix);
            long num2            = ShipControl.LowestGenerationInDirectory(di, monitoredDatabase.Config.LogFilePrefix, suffix, false);

            for (long num3 = num2; num3 <= num; num3 += 1L)
            {
                this.CheckSeedingCancelled();
                try
                {
                    monitoredDatabase.SendLog(num3, this.m_channel, null);
                }
                catch (FileIOonSourceException ex)
                {
                    ExTraceGlobals.SeederServerTracer.TraceDebug <long, Exception>((long)this.GetHashCode(), "failed to send generation 0x{0:X} because {1}", num3, ex.InnerException);
                    this.m_channel.SendException(ex.InnerException);
                    this.CancelSeeding(ex.LocalizedString);
                    return;
                }
            }
            NotifyEndOfLogReply notifyEndOfLogReply = new NotifyEndOfLogReply(this.m_channel, NetworkChannelMessage.MessageType.NotifyEndOfLogReply, num, DateTime.UtcNow);

            this.TraceDebug("reached the end of log files", new object[0]);
            notifyEndOfLogReply.Send();
        }
Exemplo n.º 4
0
        // Token: 0x06001AB8 RID: 6840 RVA: 0x000724B0 File Offset: 0x000706B0
        internal SeederServerContext(NetworkChannel channel, MonitoredDatabase database, Guid?targetServerGuid, SeedType seedType)
        {
            this.m_channel          = channel;
            this.m_databaseGuid     = database.DatabaseGuid;
            this.DatabaseName       = database.DatabaseName;
            this.SeedType           = seedType;
            this.m_targetServerGuid = targetServerGuid;
            if (database.Config.IsPassiveCopy)
            {
                this.m_fPassiveSeeding = true;
                switch (seedType)
                {
                case SeedType.Database:
                    this.m_passiveSeedingSourceContext = PassiveSeedingSourceContextEnum.Database;
                    break;

                case SeedType.Catalog:
                    this.m_passiveSeedingSourceContext = PassiveSeedingSourceContextEnum.Catalogue;
                    break;
                }
            }
            else
            {
                this.m_passiveSeedingSourceContext = PassiveSeedingSourceContextEnum.None;
            }
            if (!TestSupport.IsCatalogSeedDisabled())
            {
                string indexSystemName = FastIndexVersion.GetIndexSystemName(this.m_databaseGuid);
                this.indexSeederSource = new IndexSeeder(indexSystemName);
            }
        }
        public override void Execute()
        {
            MonitoredDatabase   monitoredDatabase   = base.Channel.MonitoredDatabase;
            EndOfLog            currentEndOfLog     = monitoredDatabase.CurrentEndOfLog;
            NotifyEndOfLogReply notifyEndOfLogReply = new NotifyEndOfLogReply(base.Channel, NetworkChannelMessage.MessageType.NotifyEndOfLogReply, currentEndOfLog.Generation, currentEndOfLog.Utc);

            notifyEndOfLogReply.Send();
        }
Exemplo n.º 6
0
        private void SetBrokenInternal(FailureTag failureTag, ExEventLog.EventTuple setBrokenEventTuple, ExtendedErrorInfo extendedErrorInfo, params string[] setBrokenArgsPlusDb)
        {
            int       num;
            string    text             = setBrokenEventTuple.EventLogToString(out num, setBrokenArgsPlusDb);
            Exception failureException = extendedErrorInfo.FailureException;
            int       num2             = 0;

            if (failureException != null)
            {
                num2 = failureException.HResult;
            }
            ReplayCrimsonEvents.SetBroken.LogPeriodic <Guid, string, string, string, Exception, int>(this.m_databaseName, DiagCore.DefaultEventSuppressionInterval, this.m_guid, this.m_databaseName, text, Environment.StackTrace, failureException, num2);
            bool flag = false;

            lock (this.m_instance)
            {
                flag = this.IsBroken;
                this.FailureInfo.SetBroken(setBrokenEventTuple, new LocalizedString(text), extendedErrorInfo);
                if (this.m_perfmonCounters != null)
                {
                    this.m_perfmonCounters.Failed       = 1L;
                    this.m_perfmonCounters.Disconnected = 0L;
                    if (this.Suspended)
                    {
                        this.m_perfmonCounters.FailedSuspended = 1L;
                    }
                }
                bool flag3;
                setBrokenEventTuple.LogEvent(this.m_identity, out flag3, setBrokenArgsPlusDb);
                ExTraceGlobals.ReplicaInstanceTracer.TraceDebug <string, FailureTag, string>((long)this.GetHashCode(), "{0} SetBroken with tag {1} because {2}", this.m_displayName, failureTag, text);
                MonitoredDatabase monitoredDatabase = MonitoredDatabase.FindMonitoredDatabase(this.ReplicaInstance.Configuration.ServerName, this.m_guid);
                if (monitoredDatabase != null && this.PassiveSeedingSourceContext != PassiveSeedingSourceContextEnum.None)
                {
                    ExTraceGlobals.ReplicaInstanceTracer.TraceDebug <Guid>((long)this.GetHashCode(), "Cancel seeding for mdb {0}", this.m_guid);
                    SourceSeedTable.Instance.CancelSeedingIfAppropriate(SourceSeedTable.CancelReason.CopyFailed, monitoredDatabase.DatabaseGuid);
                }
                bool flag4 = false;
                if (flag3 && (!RegistryParameters.DisableSetBrokenFailureItemSuppression || this.IsSuppressableFailureTag(failureTag)) && !this.IsNonSuppressableFailureTag(failureTag))
                {
                    flag4 = true;
                }
                if (!flag4 && failureTag != FailureTag.NoOp)
                {
                    FailureItemPublisherHelper.PublishAction(failureTag, this.m_guid, this.m_databaseName);
                }
                if (!flag)
                {
                    this.FailureInfo.PersistFailure(this.m_replayState);
                }
                this.ExternalStatus.Refresh();
            }
            if (!flag)
            {
                this.m_instance.PrepareToStop();
            }
        }
Exemplo n.º 7
0
        // Token: 0x06001AC4 RID: 6852 RVA: 0x00072D8C File Offset: 0x00070F8C
        private MonitoredDatabase GetMonitoredDatabase()
        {
            MonitoredDatabase monitoredDatabase = MonitoredDatabase.FindMonitoredDatabase(this.m_channel.LocalNodeName, this.DatabaseGuid);

            if (monitoredDatabase == null)
            {
                throw new SourceDatabaseNotFoundException(this.DatabaseGuid, this.m_channel.LocalNodeName);
            }
            return(monitoredDatabase);
        }
Exemplo n.º 8
0
        public void UpdateLastLogGeneratedAndEndOfLogInfo(long highestLogGen)
        {
            ActiveManagerCore.SetLastLogGenerationNumber(this.DatabaseGuid, highestLogGen);
            MonitoredDatabase monitoredDatabase = MonitoredDatabase.FindMonitoredDatabase(this.ServerName, this.DatabaseGuid);

            if (monitoredDatabase != null)
            {
                monitoredDatabase.UpdateCurrentEndOfLog(highestLogGen, true);
            }
        }
Exemplo n.º 9
0
        // Token: 0x0600239F RID: 9119 RVA: 0x000A7414 File Offset: 0x000A5614
        public static MonitoredDatabase GetMonitoredDatabase(string dbGuid)
        {
            MonitoredDatabase result = null;

            if (!RemoteDataProvider.s_databases.TryGetInstance(dbGuid, out result))
            {
                return(null);
            }
            return(result);
        }
Exemplo n.º 10
0
        public static MonitoredDatabase FindMonitoredDatabase(string nodeName, Guid dbGuid)
        {
            MonitoredDatabase result          = null;
            IFindComponent    componentFinder = Dependencies.ComponentFinder;

            if (componentFinder != null)
            {
                result = componentFinder.FindMonitoredDatabase(nodeName, dbGuid);
            }
            return(result);
        }
Exemplo n.º 11
0
 // Token: 0x0600186E RID: 6254 RVA: 0x00064C38 File Offset: 0x00062E38
 public NetworkChannel FindSeedingChannel(MonitoredDatabase db)
 {
     lock (this.m_activeClientConnections)
     {
         foreach (NetworkChannel networkChannel in this.m_activeClientConnections)
         {
             if (networkChannel.IsSeeding && object.ReferenceEquals(networkChannel.MonitoredDatabase, db))
             {
                 return(networkChannel);
             }
         }
     }
     return(null);
 }
Exemplo n.º 12
0
        // Token: 0x06002399 RID: 9113 RVA: 0x000A7154 File Offset: 0x000A5354
        public static void StopMonitoredDatabase(string dbGuidStr)
        {
            MonitoredDatabase monitoredDatabase = null;

            lock (RemoteDataProvider.s_singletonLock)
            {
                if (RemoteDataProvider.s_databases.TryGetInstance(dbGuidStr, out monitoredDatabase) && monitoredDatabase != null)
                {
                    RemoteDataProvider.s_databases.RemoveInstance(monitoredDatabase);
                }
            }
            if (monitoredDatabase != null)
            {
                monitoredDatabase.StopMonitoring();
                return;
            }
            RemoteDataProvider.Tracer.TraceDebug <string>(0L, "StopMonitoredDatabase found no database for {0}", dbGuidStr);
        }
Exemplo n.º 13
0
 // Token: 0x0600239A RID: 9114 RVA: 0x000A71C8 File Offset: 0x000A53C8
 public static void StartMonitoredDatabase(ReplayConfiguration config)
 {
     lock (RemoteDataProvider.s_singletonLock)
     {
         MonitoredDatabase monitoredDatabase = null;
         if (RemoteDataProvider.s_databases.TryGetInstance(config.Identity, out monitoredDatabase))
         {
             throw new MonitoredDatabaseInitException(config.DatabaseName, "MonitoredDatabase should not have existed");
         }
         MonitoredDatabase monitoredDatabase2 = new MonitoredDatabase(config);
         MonitoredDatabaseInitException ex    = monitoredDatabase2.StartMonitoring();
         if (ex != null)
         {
             throw ex;
         }
         RemoteDataProvider.s_databases.AddInstance(monitoredDatabase2);
         RemoteDataProvider.Tracer.TraceDebug <string>((long)monitoredDatabase2.GetHashCode(), "StartMonitoredDatabase has activated {0}", monitoredDatabase2.DatabaseName);
     }
 }
Exemplo n.º 14
0
        private static void DirectoryChangeEvent(object source, FileSystemEventArgs eventInfo)
        {
            MonitoredDatabase.FileWatcher fileWatcher = source as MonitoredDatabase.FileWatcher;
            MonitoredDatabase             database    = fileWatcher.Database;
            long num = 0L;

            if (database.GetGenerationNumberFromFilename(eventInfo.Name, out num))
            {
                MonitoredDatabase.Tracer.TraceDebug <long, string>((long)database.GetHashCode(), "DirectoryChangeEvent: Log 0x{0:X} exists for db '{1}'", num, database.DatabaseName);
                DateTime? writeTimeUtc = null;
                Exception ex           = null;
                try
                {
                    FileInfo fileInfo = new FileInfo(eventInfo.FullPath);
                    if (!fileInfo.Exists)
                    {
                        throw new FileNotFoundException("FileNotFound");
                    }
                    writeTimeUtc = new DateTime?(fileInfo.LastWriteTimeUtc);
                }
                catch (IOException ex2)
                {
                    ex = ex2;
                }
                catch (UnauthorizedAccessException ex3)
                {
                    ex = ex3;
                }
                if (ex != null)
                {
                    MonitoredDatabase.Tracer.TraceError <string, string>((long)database.GetHashCode(), "DirectoryChangeEvent for {0} failed with exception {1}", eventInfo.FullPath, ex.Message);
                    ReplayCrimsonEvents.MonitoredDBFileNotifyFailure.Log <string, string, string, string>(database.DatabaseName, Environment.MachineName, eventInfo.FullPath, ex.ToString());
                }
                database.DetectNewEndOfLog(num, writeTimeUtc, false);
            }
        }
Exemplo n.º 15
0
        // Token: 0x06002398 RID: 9112 RVA: 0x000A6E5C File Offset: 0x000A505C
        public static void MonitorDatabases(List <string> databasesToStopMonitoring, List <string> databasesToRestartMonitoring, Dictionary <string, ReplayConfiguration> configurationsFound)
        {
            List <MonitoredDatabase> list = new List <MonitoredDatabase>(databasesToStopMonitoring.Count);

            lock (RemoteDataProvider.s_singletonLock)
            {
                if (RemoteDataProvider.s_tprEnabled)
                {
                    return;
                }
                MonitoredDatabase[] allInstances = RemoteDataProvider.s_databases.GetAllInstances();
                foreach (MonitoredDatabase monitoredDatabase in allInstances)
                {
                    if (databasesToStopMonitoring.Contains(monitoredDatabase.Identity))
                    {
                        ExTraceGlobals.MonitoredDatabaseTracer.TraceDebug <string>(0L, "Config for MonitoredDatabase is gone: {0}", monitoredDatabase.Config.DatabaseName);
                        SourceSeedTable.Instance.CancelSeedingIfAppropriate(SourceSeedTable.CancelReason.CopyRemoved, monitoredDatabase.DatabaseGuid);
                        list.Add(monitoredDatabase);
                        RemoteDataProvider.s_databases.RemoveInstance(monitoredDatabase);
                    }
                }
                foreach (KeyValuePair <string, ReplayConfiguration> keyValuePair in configurationsFound)
                {
                    ReplayConfiguration value = keyValuePair.Value;
                    bool flag2 = value.Type == ReplayConfigType.RemoteCopySource;
                    bool flag3 = flag2 || (value.Type == ReplayConfigType.RemoteCopyTarget && !value.ReplayState.Suspended);
                    MonitoredDatabase monitoredDatabase2 = null;
                    if (RemoteDataProvider.s_databases.TryGetInstance(value.Identity, out monitoredDatabase2))
                    {
                        if (flag3 && !databasesToRestartMonitoring.Contains(monitoredDatabase2.Identity))
                        {
                            RemoteDataProvider.Tracer.TraceDebug <string>((long)monitoredDatabase2.GetHashCode(), "Config not changed, or the associated RI was not restarted. Continuing to monitor: {0}", value.DatabaseName);
                            continue;
                        }
                        RemoteDataProvider.Tracer.TraceDebug <string>((long)monitoredDatabase2.GetHashCode(), "Config for MonitoredDatabase is changing or a restart was requested: {0}", value.DatabaseName);
                        SourceSeedTable.Instance.CancelSeedingIfAppropriate(SourceSeedTable.CancelReason.ConfigChanged, monitoredDatabase2.DatabaseGuid);
                        list.Add(monitoredDatabase2);
                    }
                    if (!flag2)
                    {
                        RemoteDataProvider.Tracer.TraceDebug <string>(0L, "Not starting monitor for {0}", value.DatabaseName);
                        if (monitoredDatabase2 != null)
                        {
                            RemoteDataProvider.s_databases.RemoveInstance(monitoredDatabase2);
                        }
                    }
                    else
                    {
                        if (monitoredDatabase2 != null && !monitoredDatabase2.IsPassiveCopy)
                        {
                            monitoredDatabase2.StopMonitoring();
                        }
                        MonitoredDatabase monitoredDatabase3 = new MonitoredDatabase(value);
                        if (monitoredDatabase3.StartMonitoring() == null)
                        {
                            if (monitoredDatabase2 != null)
                            {
                                RemoteDataProvider.s_databases.UpdateInstance(monitoredDatabase2, monitoredDatabase3);
                            }
                            else
                            {
                                RemoteDataProvider.s_databases.AddInstance(monitoredDatabase3);
                            }
                            RemoteDataProvider.Tracer.TraceDebug <string>((long)monitoredDatabase3.GetHashCode(), "Now monitoring: {0}", value.DatabaseName);
                        }
                        else
                        {
                            RemoteDataProvider.Tracer.TraceError <ReplayConfiguration>((long)monitoredDatabase3.GetHashCode(), "Unable to monitor remote requests for configuration {0}", value);
                            if (monitoredDatabase2 != null)
                            {
                                RemoteDataProvider.s_databases.RemoveInstance(monitoredDatabase2);
                            }
                        }
                    }
                }
            }
            foreach (MonitoredDatabase monitoredDatabase4 in list)
            {
                monitoredDatabase4.StopMonitoring();
            }
            list.Clear();
        }
Exemplo n.º 16
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();
                }
            }
        }
Exemplo n.º 17
0
 internal LogCopyServerContext(NetworkChannel channel, MonitoredDatabase database)
 {
     this.m_channel  = channel;
     this.m_database = database;
 }