static Canary15DataSegment() { Canary15Trace.TraceDateTime(Canary15DataSegment.UtcNow, 0, "Canary15DataSegment().UtcNow."); Canary15Trace.TraceTimeSpan(Canary15DataSegment.defaultRefreshPeriod, 1, "Canary15DataSegment().defaultRefreshPeriod."); Canary15Trace.TraceTimeSpan(Canary15DataSegment.ReplicationDuration, 2, "Canary15DataSegment().ReplicationDuration."); Canary15DataSegment.topoConfigSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 119, ".cctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\common\\Canary15DataSegment.cs"); Canary15DataSegment.adClientAccessObjectId = Canary15DataSegment.topoConfigSession.GetClientAccessContainerId(); Canary15DataSegment.LoadClientAccessADObject(); byte[] array = ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest().ObjectGuid.ToByteArray(); byte[] array2 = Canary15DataSegment.topoConfigSession.GetDatabasesContainerId().ObjectGuid.ToByteArray(); Canary15DataSegment.adObjectIdsBinary = new byte[array.Length + array2.Length]; array.CopyTo(Canary15DataSegment.adObjectIdsBinary, 0); array2.CopyTo(Canary15DataSegment.adObjectIdsBinary, array.Length); if (Canary15Trace.IsTraceEnabled(TraceType.DebugTrace)) { using (SHA256Cng sha256Cng = new SHA256Cng()) { byte[] bytes = sha256Cng.ComputeHash(Canary15DataSegment.adObjectIdsBinary); Canary15Trace.TraceDebug(2L, "adObjectIdsBinaryHash:{0}", new object[] { Canary15DataSegment.GetHexString(bytes) }); sha256Cng.Clear(); } } }
private static void CheckAndUpdateSegment() { Canary15DataSegment.SampleUtcNow(); if (Canary15DataSegment.UtcNow >= Canary15DataManager.NextRefreshTime) { Canary15DataManager.ResetNextRefreshTime(); Canary15DataManager.RecalculateState(); if (Canary15DataManager.pendingSegment != null) { Canary15DataManager.pendingSegment.Trace(8, "CheckAndUpdateSegment()"); if (Canary15DataManager.pendingSegment.State == Canary15DataSegment.SegmentState.Pending && Canary15DataManager.pendingSegment.NextRefreshTime < Canary15DataSegment.UtcNow) { Canary15DataSegment.LoadClientAccessADObject(); Canary15DataManager.pendingSegment.ReadSegmentFromAD(); Canary15DataManager.NextRefreshTime = Canary15DataManager.pendingSegment.NextRefreshTime; Canary15DataManager.pendingSegment.Trace(8, "CheckAndUpdateSegment()"); Canary15DataManager.pendingSegment.LogToIIS(8); return; } } else if (Canary15DataManager.oldSegment != null) { Canary15DataManager.oldSegment.Trace(8, "CheckAndUpdateSegment()"); Canary15DataManager.oldSegment.LogToIIS(8); Canary15DataManager.activeSegment.Trace(8, "CheckAndUpdateSegment()"); Canary15DataManager.activeSegment.LogToIIS(8); Canary15DataManager.oldSegment.CloneFromSegment(Canary15DataManager.activeSegment); Canary15DataManager.oldSegment.Trace(8, "CheckAndUpdateSegment()"); Canary15DataManager.oldSegment.LogToIIS(8); Canary15DataManager.oldSegment.SaveSegmentToAD(); Canary15DataManager.NextRefreshTime = Canary15DataManager.oldSegment.NextRefreshTime; } } }
internal static Canary15DataSegment Create(int index, long startTime, long period, int numberOfEntries) { Canary15DataSegment canary15DataSegment = new Canary15DataSegment(index); canary15DataSegment.Init(startTime, period, numberOfEntries, Canary15DataSegment.ReplicationDuration.Ticks); canary15DataSegment.LogToIIS(7); return(canary15DataSegment); }
internal static Canary15DataSegment CreateFromADData(int index) { Canary15DataSegment canary15DataSegment = new Canary15DataSegment(index); canary15DataSegment.ReadSegmentFromAD(); canary15DataSegment.Trace(0, "CreateFromADData()"); return(canary15DataSegment); }
private static void Create(int index) { long utcNowTicks = Canary15DataSegment.UtcNowTicks; long ticks = Canary15DataManager.defaultPeriod.Ticks; Canary15DataManager.segments[index] = Canary15DataSegment.Create(index, utcNowTicks, ticks, Canary15DataManager.initialDefaultNumberOfEntries); Canary15DataManager.segments[index].LogToIIS(1); Canary15DataManager.segments[index].SaveSegmentToAD(); }
internal static Canary15DataSegment CreateFromLegacyData(int index, long startTime, long period, long replicationDuration) { Canary15DataSegment canary15DataSegment = new Canary15DataSegment(index); int num = Canary15DataSegment.adObjectIdsBinary.Length; canary15DataSegment.header = new Canary15DataSegment.DataSegmentHeader(startTime, startTime, startTime, period, 1, num, replicationDuration); canary15DataSegment.data = new byte[1][]; canary15DataSegment.data[0] = new byte[num]; Canary15DataSegment.adObjectIdsBinary.CopyTo(canary15DataSegment.data[0], 0); canary15DataSegment.header.ComputeState(canary15DataSegment.data); canary15DataSegment.Trace(0, "CreateFromLegacyData()"); return(canary15DataSegment); }
internal static void LogToIIS(this Canary15DataSegment segment, int id) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("0{0:x}.", segment.SegmentIndex); stringBuilder.AppendFormat("{0:x}.", (int)segment.State); stringBuilder.AppendFormat("{0:x}.", (int)segment.Header.Bits); stringBuilder.AppendFormat("{0:x}.", (int)segment.Header.State); stringBuilder.AppendFormat("{0:x}.", segment.Header.Period.Ticks); stringBuilder.AppendFormat("{0:x}.", segment.Header.StartTime.Ticks); stringBuilder.AppendFormat("{0:x}.", segment.Header.EndTime.Ticks); stringBuilder.AppendFormat("{0:x}.", segment.Header.ReadyTime.Ticks); stringBuilder.AppendFormat("{0:x}.", segment.Header.ReplicationDuration.Ticks); stringBuilder.AppendFormat("{0:x}.", segment.Header.ReadTime.Ticks); stringBuilder.AppendFormat("{0:x}.", segment.NextRefreshTime.Ticks); stringBuilder.AppendFormat("{0:x}", Canary15DataSegment.UtcNowTicks); Canary15Trace.LogToIIS(string.Format("Canary.S{0}=", id), stringBuilder.ToString()); }
internal static void Trace(this Canary15DataSegment segment, int id, string message) { if (Canary15Trace.SkipTrace) { return; } string text = string.Format("S.H={0},", segment.GetHashCode()); text += string.Format("S.I={0},", segment.SegmentIndex); text += string.Format("S.R={0},", segment.NextRefreshTime.ToUniversalSortable()); text += string.Format("S.S={0}", segment.State.ToString()); Canary15Trace.TraceDebug((long)id, "{0}{1}", new object[] { message ?? string.Empty, text }); segment.Header.Trace(id, message); }
static Canary15DataManager() { Canary15Trace.TraceVersion(); Canary15Trace.TraceTimeSpan(Canary15DataManager.defaultPeriod, 0, "Canary15DataManager().DefaultPeriod."); Canary15DataSegment.SampleUtcNow(); Canary15DataManager.NextRefreshTime = Canary15DataSegment.UtcNow; Canary15DataManager.segments = new Canary15DataSegment[3]; for (int i = 0; i < 3; i++) { Canary15DataManager.segments[i] = Canary15DataSegment.CreateFromADData(i); } bool flag = Canary15DataManager.segments[0].IsNull || Canary15DataManager.segments[1].IsNull || Canary15DataManager.segments[2].IsNull; if (Canary15DataManager.segments[0].IsNull || (Canary15DataManager.segments[1].IsNull && !Canary15DataManager.segments[2].IsNull)) { Canary15DataManager.segments[1].MarkADSegmentForDeletion(); Canary15DataManager.segments[2].MarkADSegmentForDeletion(); Canary15DataManager.Create(0); } if (flag) { long num = 36000000000L; long ticks = Canary15DataManager.segments[0].Header.ReplicationDuration.Ticks; if (ticks == 0L) { ticks = Canary15DataSegment.ReplicationDuration.Ticks; } long num2 = Canary15DataManager.segments[0].Header.StartTime.Ticks - ticks; if (num2 > Canary15DataSegment.UtcNow.Ticks) { num2 = Canary15DataSegment.UtcNow.Ticks; } Canary15DataManager.CreateFromLegacyData(2, num2 - num, ticks + num, ticks); Canary15DataManager.segments[2].LogToIIS(0); } }
internal void CloneFromSegment(Canary15DataSegment segment) { long startTime = segment.header.EndTime.Ticks + 1L; this.Init(startTime, segment.header.Period.Ticks, segment.Header.NumberOfEntries, segment.header.ReplicationDuration.Ticks); }
private static void CreateFromLegacyData(int index, long startTime, long period, long replicationDuration) { Canary15DataManager.segments[index] = Canary15DataSegment.CreateFromLegacyData(index, startTime, period, replicationDuration); }