Example #1
0
 public byte[] ToByteArray()
 {
     byte[] result = null;
     using (BackSyncCookieWriter backSyncCookieWriter = BackSyncCookieWriter.Create(typeof(ObjectFullSyncPageToken)))
     {
         backSyncCookieWriter.WriteNextAttributeValue(this.Version);
         backSyncCookieWriter.WriteNextAttributeValue(this.ServiceInstanceId.InstanceId);
         backSyncCookieWriter.WriteNextAttributeValue(this.Timestamp.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.LastReadFailureStartTime.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.InvocationId);
         backSyncCookieWriter.WriteNextAttributeValue((int)this.SyncOptions);
         List <string> list = new List <string>();
         foreach (SyncObjectId syncObjectId in this.ObjectIds)
         {
             list.Add(syncObjectId.ToString());
         }
         backSyncCookieWriter.WriteNextAttributeValue(list.ToArray());
         if (this.ObjectCookie != null)
         {
             backSyncCookieWriter.WriteNextAttributeValue(this.ObjectCookie.ToByteArray());
         }
         else
         {
             backSyncCookieWriter.WriteNextAttributeValue(null);
         }
         string[] attributeValue = BackSyncCookie.ConvertErrorObjectsAndFailureCountsToArray(this.ErrorObjectsAndFailureCounts);
         backSyncCookieWriter.WriteNextAttributeValue(attributeValue);
         backSyncCookieWriter.WriteNextAttributeValue(this.SequenceStartTimestamp.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.SequenceId);
         result = backSyncCookieWriter.GetBinaryCookie();
     }
     return(result);
 }
        protected virtual void PrepareCookieForFailure()
        {
            DateTime utcNow = DateTime.UtcNow;
            DateTime lastReadFailureStartTime = base.IsSubsequentFailedAttempt() ? this.GetLastReadFailureStartTime() : utcNow;
            Guid     guid = this.syncCookie.InvocationId;
            DateTime sequenceStartTimestamp = this.syncCookie.SequenceStartTimestamp;
            Guid     sequenceId             = this.syncCookie.SequenceId;

            if (base.IsSubsequentFailedAttempt() && base.IsFailoverTimeoutExceeded(utcNow))
            {
                guid                   = Guid.Empty;
                sequenceId             = Guid.NewGuid();
                sequenceStartTimestamp = DateTime.UtcNow;
            }
            bool moreData = this.syncCookie.MoreDirSyncData;

            byte[] rawCookie = this.syncCookie.DirSyncCookie;
            if (guid == Guid.Empty && this.syncCookie.LastDirSyncCookieWithReplicationVectors != null)
            {
                moreData  = true;
                rawCookie = this.syncCookie.LastDirSyncCookieWithReplicationVectors;
            }
            this.NewCookie = new BackSyncCookie(utcNow, lastReadFailureStartTime, this.GetLastWhenChanged(), guid, moreData, rawCookie, this.syncCookie.ErrorObjectsAndFailureCounts, this.syncCookie.LastDirSyncCookieWithReplicationVectors, this.syncCookie.ServiceInstanceId, sequenceId, sequenceStartTimestamp);
            base.UpdateSyncCookieErrorObjectsAndFailureCounts(this.NewCookie);
            this.CheckForFullSyncFallback();
        }
 public virtual byte[] ToByteArray()
 {
     byte[] result = null;
     using (BackSyncCookieWriter backSyncCookieWriter = BackSyncCookieWriter.Create(typeof(TenantFullSyncPageToken)))
     {
         backSyncCookieWriter.WriteNextAttributeValue(this.Version);
         backSyncCookieWriter.WriteNextAttributeValue(this.ServiceInstanceId.InstanceId);
         backSyncCookieWriter.WriteNextAttributeValue(this.Timestamp.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.LastReadFailureStartTime.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.InvocationId);
         backSyncCookieWriter.WriteNextAttributeValue(this.TenantExternalDirectoryId);
         backSyncCookieWriter.WriteNextAttributeValue(this.TenantObjectGuid);
         backSyncCookieWriter.WriteNextAttributeValue((int)this.State);
         backSyncCookieWriter.WriteNextAttributeValue(this.ObjectUpdateSequenceNumber);
         backSyncCookieWriter.WriteNextAttributeValue(this.TombstoneUpdateSequenceNumber);
         if (this.PendingWatermarks == null)
         {
             backSyncCookieWriter.WriteNextAttributeValue(null);
         }
         else
         {
             byte[] attributeValue = this.PendingWatermarks.SerializeToBytes();
             backSyncCookieWriter.WriteNextAttributeValue(attributeValue);
         }
         backSyncCookieWriter.WriteNextAttributeValue(this.PendingWatermarksInvocationId);
         if (this.Watermarks == null)
         {
             backSyncCookieWriter.WriteNextAttributeValue(null);
         }
         else
         {
             byte[] attributeValue2 = this.Watermarks.SerializeToBytes();
             backSyncCookieWriter.WriteNextAttributeValue(attributeValue2);
         }
         backSyncCookieWriter.WriteNextAttributeValue(this.WatermarksInvocationId);
         backSyncCookieWriter.WriteNextAttributeValue(this.LinkPageStart);
         backSyncCookieWriter.WriteNextAttributeValue(this.LinkPageEnd);
         backSyncCookieWriter.WriteNextAttributeValue(this.LinkRangeStart);
         backSyncCookieWriter.WriteNextAttributeValue(this.ObjectsInLinkPage);
         string[] attributeValue3 = BackSyncCookie.ConvertErrorObjectsAndFailureCountsToArray(this.ErrorObjectsAndFailureCounts);
         backSyncCookieWriter.WriteNextAttributeValue(attributeValue3);
         backSyncCookieWriter.WriteNextAttributeValue(this.SequenceStartTimestamp.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.SequenceId);
         if (this.TenantScopedBackSyncCookie == null)
         {
             backSyncCookieWriter.WriteNextAttributeValue(null);
         }
         else
         {
             byte[] attributeValue4 = this.TenantScopedBackSyncCookie.ToByteArray();
             backSyncCookieWriter.WriteNextAttributeValue(attributeValue4);
         }
         backSyncCookieWriter.WriteNextAttributeValue(this.UseContainerizedUsnChangedIndex);
         backSyncCookieWriter.WriteNextAttributeValue(this.SoftDeletedObjectUpdateSequenceNumber);
         backSyncCookieWriter.WriteNextAttributeValue((int)this.PreviousState);
         result = backSyncCookieWriter.GetBinaryCookie();
     }
     return(result);
 }
Example #4
0
 public override byte[] GetResultCookie()
 {
     byte[] resultCookie = base.GetResultCookie();
     if (resultCookie != null)
     {
         this.FullSyncPageToken.TenantScopedBackSyncCookie = BackSyncCookie.Parse(resultCookie);
     }
     return(this.FullSyncPageToken.ToByteArray());
 }
Example #5
0
        internal static ObjectFullSyncPageToken Parse(byte[] tokenBytes)
        {
            if (tokenBytes == null)
            {
                throw new ArgumentNullException("tokenBytes");
            }
            Exception innerException;

            try
            {
                using (BackSyncCookieReader backSyncCookieReader = BackSyncCookieReader.Create(tokenBytes, typeof(ObjectFullSyncPageToken)))
                {
                    int num = (int)backSyncCookieReader.GetNextAttributeValue();
                    ServiceInstanceId serviceInstanceId             = new ServiceInstanceId((string)backSyncCookieReader.GetNextAttributeValue());
                    long                     dateData               = (long)backSyncCookieReader.GetNextAttributeValue();
                    long                     dateData2              = (long)backSyncCookieReader.GetNextAttributeValue();
                    Guid                     invocationId           = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    BackSyncOptions          syncOptions            = (BackSyncOptions)((int)backSyncCookieReader.GetNextAttributeValue());
                    string[]                 array                  = (string[])backSyncCookieReader.GetNextAttributeValue();
                    byte[]                   array2                 = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    string[]                 errorObjects           = (string[])backSyncCookieReader.GetNextAttributeValue();
                    Dictionary <string, int> errorObjectsAndCount   = BackSyncCookie.ParseErrorObjectsAndFailureCounts(errorObjects);
                    DateTime                 sequenceStartTimestamp = DateTime.FromBinary((long)backSyncCookieReader.GetNextAttributeValue());
                    Guid                     sequenceId             = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    HashSet <SyncObjectId>   hashSet                = new HashSet <SyncObjectId>();
                    if (array != null)
                    {
                        foreach (string identity in array)
                        {
                            hashSet.Add(SyncObjectId.Parse(identity));
                        }
                    }
                    FullSyncObjectCookie objectCookie = (array2 == null) ? null : FullSyncObjectCookie.Parse(array2);
                    return(new ObjectFullSyncPageToken(invocationId, hashSet, syncOptions, DateTime.FromBinary(dateData), DateTime.FromBinary(dateData2), objectCookie, errorObjectsAndCount, serviceInstanceId, sequenceId, sequenceStartTimestamp));
                }
            }
            catch (ArgumentException ex)
            {
                innerException = ex;
            }
            catch (IOException ex2)
            {
                innerException = ex2;
            }
            catch (FormatException ex3)
            {
                innerException = ex3;
            }
            catch (InvalidCookieException ex4)
            {
                innerException = ex4;
            }
            throw new InvalidCookieException(innerException);
        }
        // Token: 0x060061E2 RID: 25058 RVA: 0x0014E6C0 File Offset: 0x0014C8C0
        public static BackSyncCookie Parse(byte[] binaryCookie)
        {
            if (binaryCookie == null)
            {
                ExTraceGlobals.BackSyncTracer.TraceError((long)SyncConfiguration.TraceId, "BackSyncCookie.Parse input binaryCookie is NULL");
                throw new ArgumentNullException("binaryCookie");
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "BackSyncCookie.Parse Read BackSync binary cookie \"{0}\"", Convert.ToBase64String(binaryCookie));
            Exception ex2;

            try
            {
                using (BackSyncCookieReader backSyncCookieReader = BackSyncCookieReader.Create(binaryCookie, typeof(BackSyncCookie)))
                {
                    int num = (int)backSyncCookieReader.GetNextAttributeValue();
                    ServiceInstanceId serviceInstanceId = new ServiceInstanceId((string)backSyncCookieReader.GetNextAttributeValue());
                    long   dateData     = (long)backSyncCookieReader.GetNextAttributeValue();
                    long   dateData2    = (long)backSyncCookieReader.GetNextAttributeValue();
                    Guid   invocationId = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    bool   moreData     = (bool)backSyncCookieReader.GetNextAttributeValue();
                    byte[] array        = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    if (array != null)
                    {
                        ADDirSyncCookie.Parse(array);
                    }
                    string[] errorObjects = (string[])backSyncCookieReader.GetNextAttributeValue();
                    Dictionary <string, int> errorObjects2 = BackSyncCookie.ParseErrorObjectsAndFailureCounts(errorObjects);
                    long   dateData3 = (long)backSyncCookieReader.GetNextAttributeValue();
                    byte[] lastDirSyncCookieWithReplicationVectors = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    long   dateData4  = (long)backSyncCookieReader.GetNextAttributeValue();
                    Guid   sequenceId = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    return(new BackSyncCookie(DateTime.FromBinary(dateData), DateTime.FromBinary(dateData2), DateTime.FromBinary(dateData3), invocationId, moreData, array, errorObjects2, lastDirSyncCookieWithReplicationVectors, serviceInstanceId, sequenceId, DateTime.FromBinary(dateData4)));
                }
            }
            catch (ArgumentException ex)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "BackSyncCookie.Parse ArgumentException {0}", ex.ToString());
                ex2 = ex;
            }
            catch (IOException ex3)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "BackSyncCookie.Parse IOException {0}", ex3.ToString());
                ex2 = ex3;
            }
            catch (FormatException ex4)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "BackSyncCookie.Parse FormatException {0}", ex4.ToString());
                ex2 = ex4;
            }
            ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "BackSyncCookie.Parse throw InvalidCookieException {0}", ex2.ToString());
            throw new InvalidCookieException(ex2);
        }
        public override IEnumerable <ADRawEntry> GetDataPage()
        {
            this.NewCookie = this.syncCookie;
            Guid invocationId;
            bool flag;

            byte[]       array;
            ADRawEntry[] dirSyncData = this.GetDirSyncData(out invocationId, out flag, out array);
            ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "IncrementalSyncConfiguration.GetDataPage result count = {0}", (dirSyncData != null) ? dirSyncData.Length : 0);
            byte[] lastDirSyncCookieWithReplicationVectors = (this.syncCookie != null) ? this.syncCookie.LastDirSyncCookieWithReplicationVectors : null;
            if (!flag)
            {
                lastDirSyncCookieWithReplicationVectors = array;
            }
            this.NewCookie = new BackSyncCookie(DateTime.UtcNow, DateTime.MinValue, DateTime.MinValue, invocationId, flag, array, null, lastDirSyncCookieWithReplicationVectors, this.NewCookie.ServiceInstanceId, this.NewCookie.SequenceId, this.NewCookie.SequenceStartTimestamp);
            return(dirSyncData);
        }
Example #8
0
 private MergePageToken(MergeState mergeState, byte[] tenantFullSyncPageTokenBytes, byte[] incrementalSyncCookieBytes, Dictionary <string, int> errorObjectsAndFailureCounts) : base(tenantFullSyncPageTokenBytes)
 {
     ExTraceGlobals.MergeTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "New MergePageToken");
     this.MergeState = mergeState;
     ExTraceGlobals.MergeTracer.TraceDebug <string>((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken this.MergeState = {0}", this.MergeState.ToString());
     this.BackSyncCookie = BackSyncCookie.Parse(incrementalSyncCookieBytes);
     if (!this.BackSyncCookie.ServiceInstanceId.Equals(base.ServiceInstanceId))
     {
         ExTraceGlobals.MergeTracer.TraceError((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken serviceInstanceId != tenantFullSyncPageTokenBytes.ServiceInstanceId");
         throw new InvalidCookieException(new ArgumentException("serviceInstanceId"));
     }
     this.MergeVersion = 2;
     ExTraceGlobals.MergeTracer.TraceDebug <int>((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken this.MergeVersion = {0}", this.MergeVersion);
     this.dirSyncCookie = ADDirSyncCookie.Parse(this.BackSyncCookie.DirSyncCookie);
     base.ErrorObjectsAndFailureCounts = (errorObjectsAndFailureCounts ?? new Dictionary <string, int>());
     if (!this.BackSyncCookie.ReadyToMerge || this.dirSyncCookie.MoreData)
     {
         ExTraceGlobals.MergeTracer.TraceError((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken !this.BackSyncCookie.ReadyToMerge || dirSyncCookie.MoreData");
         throw new InvalidCookieException(new ArgumentException("incrementalSyncCookieBytes"));
     }
 }
 // Token: 0x060061E3 RID: 25059 RVA: 0x0014E900 File Offset: 0x0014CB00
 public byte[] ToByteArray()
 {
     ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "BackSyncCookie.ToByteArray entering");
     byte[] result = null;
     using (BackSyncCookieWriter backSyncCookieWriter = BackSyncCookieWriter.Create(typeof(BackSyncCookie)))
     {
         backSyncCookieWriter.WriteNextAttributeValue(this.Version);
         backSyncCookieWriter.WriteNextAttributeValue(this.ServiceInstanceId.InstanceId);
         backSyncCookieWriter.WriteNextAttributeValue(this.Timestamp.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.LastReadFailureStartTime.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.InvocationId);
         backSyncCookieWriter.WriteNextAttributeValue(this.MoreDirSyncData);
         backSyncCookieWriter.WriteNextAttributeValue(this.DirSyncCookie);
         string[] attributeValue = BackSyncCookie.ConvertErrorObjectsAndFailureCountsToArray(this.ErrorObjectsAndFailureCounts);
         backSyncCookieWriter.WriteNextAttributeValue(attributeValue);
         backSyncCookieWriter.WriteNextAttributeValue(this.LastWhenChanged.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.LastDirSyncCookieWithReplicationVectors);
         backSyncCookieWriter.WriteNextAttributeValue(this.SequenceStartTimestamp.ToBinary());
         backSyncCookieWriter.WriteNextAttributeValue(this.SequenceId);
         result = backSyncCookieWriter.GetBinaryCookie();
     }
     return(result);
 }
 public IncrementalSyncConfiguration(BackSyncCookie syncCookie, Guid invocationId, OutputResultDelegate writeResult, ISyncEventLogger eventLogger, IExcludedObjectReporter excludedObjectReporter) : base(invocationId, writeResult, eventLogger, excludedObjectReporter)
 {
     ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "New IncrementalSyncConfiguration");
     this.syncCookie = syncCookie;
 }
        protected TenantFullSyncPageToken(byte[] tokenBytes)
        {
            Exception ex = null;

            try
            {
                using (BackSyncCookieReader backSyncCookieReader = BackSyncCookieReader.Create(tokenBytes, typeof(TenantFullSyncPageToken)))
                {
                    this.Version                   = (int)backSyncCookieReader.GetNextAttributeValue();
                    this.ServiceInstanceId         = new ServiceInstanceId((string)backSyncCookieReader.GetNextAttributeValue());
                    this.Timestamp                 = DateTime.FromBinary((long)backSyncCookieReader.GetNextAttributeValue());
                    this.LastReadFailureStartTime  = DateTime.FromBinary((long)backSyncCookieReader.GetNextAttributeValue());
                    this.InvocationId              = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    this.TenantExternalDirectoryId = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    this.TenantObjectGuid          = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    this.State = (TenantFullSyncState)backSyncCookieReader.GetNextAttributeValue();
                    this.ObjectUpdateSequenceNumber    = (long)backSyncCookieReader.GetNextAttributeValue();
                    this.TombstoneUpdateSequenceNumber = (long)backSyncCookieReader.GetNextAttributeValue();
                    byte[] array = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    if (array != null)
                    {
                        this.PendingWatermarks = WatermarkMap.Parse(array);
                    }
                    this.PendingWatermarksInvocationId = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    byte[] array2 = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    if (array2 != null)
                    {
                        this.Watermarks = WatermarkMap.Parse(array2);
                    }
                    this.WatermarksInvocationId = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    this.LinkPageStart          = (long)backSyncCookieReader.GetNextAttributeValue();
                    this.LinkPageEnd            = (long)backSyncCookieReader.GetNextAttributeValue();
                    this.LinkRangeStart         = (int)backSyncCookieReader.GetNextAttributeValue();
                    this.ObjectsInLinkPage      = (int)backSyncCookieReader.GetNextAttributeValue();
                    string[] array3 = (string[])backSyncCookieReader.GetNextAttributeValue();
                    this.ErrorObjectsAndFailureCounts = ((array3 != null) ? BackSyncCookie.ParseErrorObjectsAndFailureCounts(array3) : new Dictionary <string, int>());
                    this.SequenceStartTimestamp       = DateTime.FromBinary((long)backSyncCookieReader.GetNextAttributeValue());
                    this.SequenceId = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    byte[] array4 = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    if (array4 != null)
                    {
                        this.TenantScopedBackSyncCookie = BackSyncCookie.Parse(array4);
                        this.InvocationId = this.TenantScopedBackSyncCookie.InvocationId;
                    }
                    this.UseContainerizedUsnChangedIndex       = (bool)backSyncCookieReader.GetNextAttributeValue();
                    this.SoftDeletedObjectUpdateSequenceNumber = (long)backSyncCookieReader.GetNextAttributeValue();
                    this.PreviousState = (TenantFullSyncState)backSyncCookieReader.GetNextAttributeValue();
                }
            }
            catch (ArgumentException ex2)
            {
                ExTraceGlobals.TenantFullSyncTracer.TraceError <string>((long)this.TenantExternalDirectoryId.GetHashCode(), "TenantFullSyncPageToken ArgumentException {0}", ex2.ToString());
                ex = ex2;
            }
            catch (IOException ex3)
            {
                ExTraceGlobals.TenantFullSyncTracer.TraceError <string>((long)this.TenantExternalDirectoryId.GetHashCode(), "TenantFullSyncPageToken IOException {0}", ex3.ToString());
                ex = ex3;
            }
            catch (FormatException ex4)
            {
                ExTraceGlobals.TenantFullSyncTracer.TraceError <string>((long)this.TenantExternalDirectoryId.GetHashCode(), "TenantFullSyncPageToken FormatException {0}", ex4.ToString());
                ex = ex4;
            }
            catch (InvalidCookieException ex5)
            {
                ExTraceGlobals.TenantFullSyncTracer.TraceError <string>((long)this.TenantExternalDirectoryId.GetHashCode(), "TenantFullSyncPageToken InvalidCookieException {0}", ex5.ToString());
                ex = ex5;
            }
            if (ex != null)
            {
                ExTraceGlobals.TenantFullSyncTracer.TraceError <string>((long)this.TenantExternalDirectoryId.GetHashCode(), "TenantFullSyncPageToken throw InvalidCookieException {0}", ex.ToString());
                throw new InvalidCookieException(ex);
            }
        }