Exemple #1
0
        private bool TrySelectDomainController(ITopologyConfigurationSession session, string domainControllerFqdn, PartitionId partitionId, bool checkSuitability, out Guid resultInvocationId)
        {
            ExTraceGlobals.ActiveDirectoryTracer.TraceDebug <string>((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.TrySelectDomainController dc {0}", domainControllerFqdn);
            resultInvocationId = Guid.Empty;
            string          text;
            LocalizedString localizedString;

            if (checkSuitability && !SuitabilityVerifier.IsServerSuitableIgnoreExceptions(domainControllerFqdn, false, null, out text, out localizedString))
            {
                ExTraceGlobals.ActiveDirectoryTracer.TraceWarning <string, string>((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0} is not available for Tenant Full Backsync, error {1}", domainControllerFqdn, localizedString.ToString());
                return(false);
            }
            ITopologyConfigurationSession configSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainControllerFqdn, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 461, "TrySelectDomainController", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\MergePageToken.cs");
            WatermarkMap replicationCursors             = SyncConfiguration.GetReplicationCursors(configSession, false, true);

            if (replicationCursors.ContainsAllChanges(base.Watermarks))
            {
                Guid invocationIdByFqdn = session.GetInvocationIdByFqdn(domainControllerFqdn);
                long num;
                if (base.Watermarks.TryGetValue(invocationIdByFqdn, out num))
                {
                    base.ObjectUpdateSequenceNumber    = num + 1L;
                    base.TombstoneUpdateSequenceNumber = num + 1L;
                    base.InvocationId = invocationIdByFqdn;
                    if (base.UseContainerizedUsnChangedIndex)
                    {
                        base.SoftDeletedObjectUpdateSequenceNumber = num + 1L;
                    }
                    ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0}({1})has all changes reported by the Tenant Full Sync Watermarks for {2} and CAN be used. \r\nFull sync watermarks: \r\n{3}\r\nDC replication cursors: \r\n{4}", new object[]
                    {
                        domainControllerFqdn,
                        base.InvocationId,
                        base.TenantExternalDirectoryId,
                        base.Watermarks.SerializeToString(),
                        replicationCursors.SerializeToString()
                    });
                    resultInvocationId = invocationIdByFqdn;
                    return(true);
                }
                ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0}({1})has all changes reported by the Tenant Full Sync Watermarks for {2} but cannot be used since its invocationId is not part of the TFS watermarks. \r\nFull sync watermarks: \r\n{3}\r\n", new object[]
                {
                    domainControllerFqdn,
                    base.InvocationId,
                    base.TenantExternalDirectoryId,
                    base.Watermarks.SerializeToString()
                });
            }
            else
            {
                ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0} does not have all changes reported by the Tenant Full Sync Watermarks for {1} and cannot be used. \r\nFull sync watermarks: \r\n{2}\r\nDC replication cursors: \r\n{3}", new object[]
                {
                    domainControllerFqdn,
                    base.TenantExternalDirectoryId,
                    base.Watermarks.SerializeToString(),
                    replicationCursors.SerializeToString()
                });
            }
            return(false);
        }
Exemple #2
0
        private WatermarkMap FilterOutNotExistingDCs(IEnumerable <ReplicationCursor> adReplicationCursorCollection, PartitionId partitionId)
        {
            WatermarkMap watermarkMap = new WatermarkMap();
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 336, "FilterOutNotExistingDCs", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\MergePageToken.cs");
            WatermarkMap watermarkMap2 = null;
            ADServer     adserver      = topologyConfigurationSession.FindDCByInvocationId(base.WatermarksInvocationId);

            if (adserver != null)
            {
                topologyConfigurationSession.DomainController = adserver.DnsHostName;
                watermarkMap2 = SyncConfiguration.GetReplicationCursors(topologyConfigurationSession);
            }
            foreach (ReplicationCursor replicationCursor in adReplicationCursorCollection)
            {
                if (watermarkMap2 == null || watermarkMap2.ContainsKey(replicationCursor.SourceInvocationId))
                {
                    watermarkMap[replicationCursor.SourceInvocationId] = replicationCursor.UpToDatenessUsn;
                }
            }
            return(watermarkMap);
        }
        public override IEnumerable <ADRawEntry> GetDataPage()
        {
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration GetDataPage ...");
            WatermarkMap watermarks = SyncConfiguration.GetReplicationCursors(base.RootOrgConfigurationSession);
            string       dcName     = base.RootOrgConfigurationSession.DomainController;

            ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration dcName {0}", dcName);
            Guid watermarksInvocationId = base.RootOrgConfigurationSession.GetInvocationIdByFqdn(dcName);

            ExTraceGlobals.BackSyncTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration watermarksInvocationId {0}", watermarksInvocationId);
            long maxUsn = watermarks[watermarksInvocationId];

            ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration maxUsn {0}", maxUsn);
            if (this.PageToken.InvocationId == Guid.Empty)
            {
                this.PageToken.InvocationId = watermarksInvocationId;
                ExTraceGlobals.BackSyncTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration set this.PageToken.InvocationId to {0}", this.PageToken.InvocationId);
            }
            while (this.ShouldReadMoreData())
            {
                ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration this.PageToken.State = {0}", this.PageToken.State.ToString());
                switch (this.PageToken.State)
                {
                case TenantFullSyncState.EnumerateLiveObjects:
                    foreach (ADRawEntry entry in this.ReadLiveObjects())
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration EnumerateLiveObjects yield {0}", entry.Id);
                        yield return(entry);
                    }
                    this.PageToken.PendingWatermarksInvocationId = watermarksInvocationId;
                    ExTraceGlobals.BackSyncTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration EnumerateLiveObjects set this.PageToken.PendingWatermarksInvocationId to {0}", this.PageToken.PendingWatermarksInvocationId);
                    this.PageToken.PendingWatermarks = watermarks;
                    continue;

                case TenantFullSyncState.EnumerateLinksInPage:
                    foreach (ADRawEntry entry2 in this.ReadLinks())
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration EnumerateLinksInPage yield {0}", entry2.Id);
                        yield return(entry2);
                    }
                    continue;

                case TenantFullSyncState.EnumerateDeletedObjects:
                    foreach (ADRawEntry entry3 in this.ReadDeletedObjects())
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration EnumerateDeletedObjects yield {0}", entry3.Id);
                        yield return(entry3);
                    }
                    continue;

                case TenantFullSyncState.EnumerateSoftDeletedObjects:
                    foreach (ADRawEntry entry4 in this.ReadSoftDeletedObjects())
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration EnumerateSoftDeletedObjects yield {0}", entry4.Id);
                        yield return(entry4);
                    }
                    continue;
                }
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "Invalid PageToken stat {0}", this.PageToken.State.ToString());
                throw new ArgumentException(this.PageToken.State.ToString());
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration this.PageToken.ObjectUpdateSequenceNumber = {0}", this.PageToken.ObjectUpdateSequenceNumber);
            if (this.PageToken.ObjectUpdateSequenceNumber > maxUsn + 1L)
            {
                this.PageToken.ObjectUpdateSequenceNumber = maxUsn + 1L;
                ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration set this.PageToken.ObjectUpdateSequenceNumber to {0}", this.PageToken.ObjectUpdateSequenceNumber);
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration this.PageToken.TombstoneUpdateSequenceNumber = {0}", this.PageToken.TombstoneUpdateSequenceNumber);
            if (this.PageToken.TombstoneUpdateSequenceNumber > maxUsn + 1L)
            {
                this.PageToken.TombstoneUpdateSequenceNumber = maxUsn + 1L;
                ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration set this.PageToken.TombstoneUpdateSequenceNumber to {0}", this.PageToken.TombstoneUpdateSequenceNumber);
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration this.PageToken.SoftDeletedObjectUpdateSequenceNumber = {0}", this.PageToken.SoftDeletedObjectUpdateSequenceNumber);
            if (this.PageToken.SoftDeletedObjectUpdateSequenceNumber > maxUsn + 1L)
            {
                this.PageToken.SoftDeletedObjectUpdateSequenceNumber = maxUsn + 1L;
                ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration set this.PageToken.SoftDeletedObjectUpdateSequenceNumber to {0}", this.PageToken.SoftDeletedObjectUpdateSequenceNumber);
            }
            this.PageToken.LastReadFailureStartTime = DateTime.MinValue;
            ExTraceGlobals.BackSyncTracer.TraceDebug <DateTime>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration set this.PageToken.LastReadFailureStartTime to {0}", this.PageToken.LastReadFailureStartTime);
            this.PageToken.Timestamp = DateTime.UtcNow;
            ExTraceGlobals.BackSyncTracer.TraceDebug <DateTime>((long)SyncConfiguration.TraceId, "TenantFullSyncConfiguration set this.PageToken.Timestamp to {0}", this.PageToken.Timestamp);
            yield break;
        }
 internal static WatermarkMap GetReplicationCursors(ITopologyConfigurationSession configSession)
 {
     return(SyncConfiguration.GetReplicationCursors(configSession, false, false));
 }