public void CancelSeedingIfAppropriate(SourceSeedTable.CancelReason reason, Guid dbGuid) { SeederServerContext seederServerContext = null; lock (this.locker) { if (this.activeSeeds.TryGetValue(dbGuid, out seederServerContext) && seederServerContext != null) { SourceSeedTable.Tracer.TraceDebug <string, SourceSeedTable.CancelReason>((long)this.GetHashCode(), "CancelSeeding {0} : {1}", seederServerContext.DatabaseName, reason); if (reason == SourceSeedTable.CancelReason.ConfigChanged && seederServerContext.IsCatalogSeed) { SourceSeedTable.Tracer.TraceDebug <string>((long)this.GetHashCode(), "CancelSeeding skipped for {0} because catalog is seeding", seederServerContext.DatabaseName); return; } this.activeSeeds[seederServerContext.DatabaseGuid] = null; } } if (seederServerContext != null) { LocalizedString message; if (reason == SourceSeedTable.CancelReason.CopyFailed) { message = ReplayStrings.CancelSeedingDueToFailed(seederServerContext.DatabaseName, Environment.MachineName); } else { message = ReplayStrings.CancelSeedingDueToConfigChangeOrServiceShutdown(seederServerContext.DatabaseName, Environment.MachineName, reason.ToString()); } seederServerContext.CancelSeeding(message); } }
public void InitializeContext(ReplicaInstance instance) { this.m_instance = instance; this.m_replayState = instance.Configuration.ReplayState; this.m_identity = instance.Configuration.Identity; this.m_databaseName = instance.Configuration.DatabaseName; this.m_displayName = instance.Configuration.DisplayName; this.m_guid = instance.Configuration.IdentityGuid; this.m_perfmonCounters = instance.PerfmonCounters; this.ExternalStatus = new ExternalReplicaInstanceStatus(this, this.m_instance.PreviousContext, this.m_instance.Configuration.Type, this.m_perfmonCounters, this.m_replayState); if (instance.IsThirdPartyReplicationEnabled && instance.IsTarget) { this.m_progressStage = ReplicaInstanceStage.Running; } SeederServerContext seederServerContext = SourceSeedTable.Instance.TryGetContext(this.m_guid); if (seederServerContext != null) { if (instance.Configuration.IsPassiveCopy) { seederServerContext.LinkWithNewPassiveRIStatus(this); } else { seederServerContext.LinkWithNewActiveRIStatus(this); } } this.m_countLogsThreshold = (long)RegistryParameters.ReplicaProgressNumberOfLogsThreshold; }
// Token: 0x06001A5B RID: 6747 RVA: 0x0006F224 File Offset: 0x0006D424 public override void Execute() { string databaseName = base.Channel.MonitoredDatabase.DatabaseName; string partnerNodeName = base.Channel.PartnerNodeName; ExTraceGlobals.SeederServerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "PassiveSeedDatabaseFileRequest: databaseGuid ({0}).", base.DatabaseGuid); Exception ex = null; try { SeederServerContext seederServerContext = base.Channel.CreateSeederServerContext(base.DatabaseGuid, new Guid?(this.m_serverGuid), SeedType.Database); seederServerContext.SendDatabaseFile(); } catch (OperationCanceledException ex2) { ex = ex2; } catch (SeedingChannelIsClosedException ex3) { ex = ex3; } catch (SeedingSourceReplicaInstanceNotFoundException ex4) { ex = ex4; } catch (IOException ex5) { ex = ex5; } catch (FileIOonSourceException ex6) { ex = ex6; } catch (NetworkTransportException ex7) { ex = ex7; } catch (MapiPermanentException ex8) { ex = ex8; } catch (TaskServerException ex9) { ex = ex9; } catch (TransientException ex10) { ex = ex10; } if (ex != null) { ExTraceGlobals.SeederServerTracer.TraceError <string, Exception>((long)this.GetHashCode(), "PassiveSeedDatabaseFileRequest({0}): Failed: {1}", databaseName, ex); ReplayCrimsonEvents.PassiveSeedSourceFailedToSendEDB.Log <string, string, string, string>(databaseName, Environment.MachineName, partnerNodeName, ex.ToString()); if (!(ex is NetworkTransportException)) { base.Channel.SendException(ex); } } }
public SeederServerContext TryGetContext(Guid guid) { SeederServerContext result = null; lock (this.locker) { if (this.activeSeeds.TryGetValue(guid, out result)) { return(result); } } return(null); }
// Token: 0x060019EB RID: 6635 RVA: 0x0006C678 File Offset: 0x0006A878 public override void Execute() { Exception ex = SeederServerContext.RunSeedSourceAction(delegate { SeederServerContext seederServerContext = base.Channel.GetSeederServerContext(base.DatabaseGuid); seederServerContext.HandleCancelCiFileRequest(null); }); if (ex != null) { ReplayCrimsonEvents.CISeedingSourceError.Log <Guid, string, string, string>(base.DatabaseGuid, string.Empty, string.Empty, ex.ToString()); SeederServerContext.ProcessSourceSideException(ex, base.Channel); } }
// Token: 0x06001A5F RID: 6751 RVA: 0x0006F3E8 File Offset: 0x0006D5E8 public override void Execute() { Exception ex = SeederServerContext.RunSeedSourceAction(delegate { SeederServerContext seederServerContext = base.Channel.GetSeederServerContext(base.DatabaseGuid); seederServerContext.SendLogFiles(); }); if (ex != null) { ReplayCrimsonEvents.LogSeedingSourceError.Log <Guid, string, string, string>(base.DatabaseGuid, string.Empty, base.Channel.PartnerNodeName, ex.ToString()); SeederServerContext.ProcessSourceSideException(ex, base.Channel); } }
// Token: 0x060019D5 RID: 6613 RVA: 0x0006C37C File Offset: 0x0006A57C public override void Execute() { Exception ex = SeederServerContext.RunSeedSourceAction(delegate { SeederServerContext seederServerContext = base.Channel.CreateSeederServerContext(base.DatabaseGuid, null, SeedType.Catalog); seederServerContext.SeedToEndpoint(this.endpoint, this.reason); ReplayCrimsonEvents.CISeedingSourceBeginSucceeded.Log <Guid, string, string, string>(base.DatabaseGuid, seederServerContext.DatabaseName, this.endpoint, string.Empty); }); if (ex != null) { ReplayCrimsonEvents.CISeedingSourceBeginFailed.Log <Guid, string, string, string>(base.DatabaseGuid, string.Empty, this.endpoint, ex.ToString()); SeederServerContext.ProcessSourceSideException(ex, base.Channel); } }
internal SeedCiFileRequest2(NetworkChannel channel, byte[] packetContent) : base(channel, NetworkChannelMessage.MessageType.SeedCiFileRequest2, packetContent) { string xml = base.Packet.ExtractString(); SeedCiFileRequestPayload seedCiFileRequestPayload; Exception ex = DataContractSerializeHelper.DeserializeFromXmlString <SeedCiFileRequestPayload>(xml, out seedCiFileRequestPayload); if (ex != null) { ReplayCrimsonEvents.CISeedingSourceBeginFailed.Log <Guid, string, string, Exception>(base.DatabaseGuid, string.Empty, base.Channel.PartnerNodeName, ex); SeederServerContext.ProcessSourceSideException(ex, base.Channel); return; } this.endpoint = seedCiFileRequestPayload.Endpoint; this.reason = seedCiFileRequestPayload.Reason; }
public void RegisterSeed(SeederServerContext newCtx) { SeederServerContext seederServerContext = null; lock (this.locker) { SourceSeedTable.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "RegisterSeed {0}", newCtx.DatabaseGuid); if (this.activeSeeds.TryGetValue(newCtx.DatabaseGuid, out seederServerContext) && seederServerContext != null) { ReplayCrimsonEvents.SeedingSourceError.Log <Guid, string, string, string>(newCtx.DatabaseGuid, string.Empty, seederServerContext.TargetServerName, "RegisterSeed:SeedCtx already exists"); throw new SeedingAnotherServerException(seederServerContext.TargetServerName, newCtx.TargetServerName); } this.activeSeeds[newCtx.DatabaseGuid] = newCtx; } }
public void DeregisterSeed(SeederServerContext oldCtx) { SeederServerContext seederServerContext = null; SourceSeedTable.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "DeregisterSeed {0}", oldCtx.DatabaseGuid); lock (this.locker) { if (this.activeSeeds.TryGetValue(oldCtx.DatabaseGuid, out seederServerContext)) { if (seederServerContext == oldCtx) { this.activeSeeds[oldCtx.DatabaseGuid] = null; SourceSeedTable.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "DeregisterSeed {0} successful.", oldCtx.DatabaseGuid); } else { SourceSeedTable.Tracer.TraceError <Guid>((long)this.GetHashCode(), "DeregisterSeed {0} ignored mismatached ctx.", oldCtx.DatabaseGuid); } } } }
// 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(); } } }
// Token: 0x06001ABE RID: 6846 RVA: 0x00072650 File Offset: 0x00070850 internal bool IsFromSameTargetServer(SeederServerContext context) { return(this.m_targetServerGuid == null || context.TargetServerGuid == null || this.m_targetServerGuid.Equals(context.TargetServerGuid)); }