当前位置: 首页>>代码示例>>C#>>正文


C# Etag.CompareTo方法代码示例

本文整理汇总了C#中Etag.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Etag.CompareTo方法的具体用法?C# Etag.CompareTo怎么用?C# Etag.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Etag的用法示例。


在下文中一共展示了Etag.CompareTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SeekMissingEtagsFrom

        private void SeekMissingEtagsFrom(Etag lastKnownEtag, Etag destinationEtag)
        {
            if (lastKnownEtag.CompareTo(destinationEtag) >= 0) return;

            TransactionalStorage.Batch(accessor =>
            {
                lastKnownEtag = UpdatePerCollectionEtags(
                    accessor.Documents.GetDocumentsAfter(lastKnownEtag, 1000));
            });

            if(lastKnownEtag != null)
                SeekMissingEtagsFrom(lastKnownEtag, destinationEtag);
        }
开发者ID:randacc,项目名称:ravendb,代码行数:13,代码来源:LastCollectionEtags.cs

示例2: WaitForReplicationFromServerAsync

		private async void WaitForReplicationFromServerAsync(string url, AsyncCountdownEvent countDown, Etag etag, BlockingCollection<Exception> errors)
		{
			try
			{
				while (countDown.Active)
				{
					var etags = await GetReplicatedEtagsFor(url);

					var replicated = etag.CompareTo(etags.DocumentEtag) <= 0 || etag.CompareTo(etags.AttachmentEtag) <= 0;

					if (!replicated)
					{
						if (countDown.Active)
						{
#if NET45
							await Task.Delay(100);
#else
							await TaskEx.Delay(100);
#endif
						}
						continue;
					}
					countDown.Signal();
					return;
				}
			}
			catch (Exception ex)
			{
				errors.Add(ex);
				countDown.Error();
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:32,代码来源:ReplicationBehavior.cs

示例3: CleanupDocuments

		public void CleanupDocuments(Etag lastIndexedEtag)
		{
			foreach (var docToRemove in documentsToRemove)
			{
				if (docToRemove.Value.All(etag => lastIndexedEtag.CompareTo(etag) > 0) == false)
					continue;

				HashSet<Etag> _;
				documentsToRemove.TryRemove(docToRemove.Key, out _);
			}

			updatedDocumentsLock.EnterWriteLock();
			try
			{
				updatedDocuments.RemoveSmallerOrEqual(lastIndexedEtag);
			}
			finally
			{
				updatedDocumentsLock.ExitWriteLock();
			}

			JsonDocument result;
			while (prefetchingQueue.TryPeek(out result) && lastIndexedEtag.CompareTo(result.Etag) >= 0)
			{
				prefetchingQueue.TryDequeue(out result);
			}
		}
开发者ID:Nakro,项目名称:ravendb,代码行数:27,代码来源:PrefetchingBehavior.cs

示例4: TryGetDocumentsFromQueue

		private bool TryGetDocumentsFromQueue(Etag nextDocEtag, List<JsonDocument> items)
		{
			JsonDocument result;

			nextDocEtag = HandleEtagGapsIfNeeded(nextDocEtag);
			bool hasDocs = false;

			while (items.Count < autoTuner.NumberOfItemsToIndexInSingleBatch && 
				prefetchingQueue.TryPeek(out result) && 
				// we compare to current or _smaller_ so we will remove from the queue old versions
				// of documents that we have already loaded
				nextDocEtag.CompareTo(result.Etag) >= 0)
			{
				// safe to do peek then dequeue because we are the only one doing the dequeues
				// and here we are single threaded, but still, better to check
				if (prefetchingQueue.TryDequeue(out result) == false)
					continue;

                // this shouldn't happen, but... 
                if(result == null)
                    continue;

				if (result.Etag != nextDocEtag)
					continue;

				items.Add(result);
				hasDocs = true;

				nextDocEtag = Abstractions.Util.EtagUtil.Increment(nextDocEtag, 1);
				nextDocEtag = HandleEtagGapsIfNeeded(nextDocEtag);
			}

			return hasDocs;
		}
开发者ID:Nakro,项目名称:ravendb,代码行数:34,代码来源:PrefetchingBehavior.cs

示例5: Update

		public void Update(string collectionName, Etag etag)
		{
			lastCollectionEtags.AddOrUpdate(collectionName, new Entry { Etag = etag, Updated = SystemTime.UtcNow }, (existingEntity, existingEtagEntry) =>
			{
				if (etag.CompareTo(existingEtagEntry.Etag) > 0)
				{
					existingEtagEntry.Etag = etag;
					existingEtagEntry.Updated = SystemTime.UtcNow;
				}

				return existingEtagEntry;
			});
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:13,代码来源:LastCollectionEtags.cs

示例6: RemoveOutdatedFutureIndexBatches

 private void RemoveOutdatedFutureIndexBatches(Etag etag)
 {
     foreach (FutureIndexBatch source in futureIndexBatches.Values.Where(x => etag.CompareTo(x.StartingEtag) > 0))
     {
         ObserveDiscardedTask(source);
         if (source.CancellationTokenSource != null)
             source.CancellationTokenSource.Cancel();
         FutureIndexBatch batch;
         futureIndexBatches.TryRemove(source.StartingEtag, out batch);
     }
 }
开发者ID:hero106wen,项目名称:ravendb,代码行数:11,代码来源:PrefetchingBehavior.cs

示例7: HandleCollectingDocumentsAfterCommit

        private void HandleCollectingDocumentsAfterCommit(Etag requestedEtag)
        {
            if (ShouldHandleUnusedDocumentsAddedAfterCommit == false)
                return;

            var current = lowestInMemoryDocumentAddedAfterCommit;
            if (DisableCollectingDocumentsAfterCommit)
            {
                if (current != null && requestedEtag.CompareTo(current.Etag) > 0)
                {
                    lowestInMemoryDocumentAddedAfterCommit = null;
                    DisableCollectingDocumentsAfterCommit = false;
                    numberOfTimesIngestRateWasTooHigh = 0;
                }
            }
            else if (current != null)
            {
                var oldestTimeInQueue = SystemTime.UtcNow - current.AddedAt;
                if (
                    // this can happen if we have a very long indexing time, which takes
                    // us a long while to process, so we might as might as well stop keeping
                    // stuff in memory, because we lag
                    oldestTimeInQueue > TimeSpan.FromMinutes(10)
                    )
                {
                    DisableCollectingDocumentsAfterCommit = true;
                    // If we disable in memory collection of data, we need to also remove all the
                    // items in the prefetching queue that are after the last in memory docs
                    // immediately, not wait for them to be indexed. They have already been in 
                    // memory for ten minutes
                    // But not if our time has finally been reached
                    if (requestedEtag.CompareTo(current.Etag) >= 0)
                        prefetchingQueue.RemoveAfter(current.Etag);
                }
            }
        }
开发者ID:hero106wen,项目名称:ravendb,代码行数:36,代码来源:PrefetchingBehavior.cs

示例8: Update

		public void Update(string collectionName, Etag etag)
		{
			lastCollectionEtags.AddOrUpdate(collectionName, etag, (existingEntity, existingEtag) => etag.CompareTo(existingEtag) > 0 ? etag : existingEtag);
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:4,代码来源:LastCollectionEtags.cs

示例9: Read

		public IEnumerable<ListItem> Read(string name, Etag start, Etag end, int take)
		{
			var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);

			using (var iterator = listsByName.MultiRead(Snapshot, CreateKey(name)))
			{
				if (!iterator.Seek(start.ToString()))
					yield break;

				int count = 0;

				do
				{
					var etag = Etag.Parse(iterator.CurrentKey.ToString());
					if (start.CompareTo(etag) >= 0)
						continue;

					if (end != null && end.CompareTo(etag) <= 0)
						yield break;

					count++;
					yield return ReadInternal(etag);
				}
				while (iterator.MoveNext() && count < take);
			}
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:26,代码来源:ListsStorageActions.cs

示例10: UpdateLastEtagForCollection

 private void UpdateLastEtagForCollection(string collectionName, Etag etag)
 {
     lastCollectionEtags.AddOrUpdate(collectionName, etag,
         (v, oldEtag) => etag.CompareTo(oldEtag) < 0 ? oldEtag : etag);
 }
开发者ID:randacc,项目名称:ravendb,代码行数:5,代码来源:LastCollectionEtags.cs

示例11: RemoveOutdatedFutureIndexBatches

 private void RemoveOutdatedFutureIndexBatches(Etag etag)
 {
     foreach (FutureIndexBatch source in futureIndexBatches.Values.Where(x => etag.CompareTo(x.StartingEtag) > 0))
     {
         ObserveDiscardedTask(source);
         var cts = source.CancellationTokenSource;
         if (cts != null)
         {
             try
             {
                 cts.Cancel();
             }
             catch (ObjectDisposedException)
             {
                 // this is expected with a race against the prefetching queue
                 
             }
         }
         FutureIndexBatch batch;
         futureIndexBatches.TryRemove(source.StartingEtag, out batch);
     }
 }
开发者ID:knives-out,项目名称:ravendb,代码行数:22,代码来源:PrefetchingBehavior.cs

示例12: HandleCollectingDocumentsAfterCommit

		private void HandleCollectingDocumentsAfterCommit(Etag reqestedEtag)
		{
			if(ShouldHandleUnusedDocumentsAddedAfterCommit == false)
				return;

			if (DisableCollectingDocumentsAfterCommit)
			{
				if (lowestInMemoryDocumentAddedAfterCommit != null && reqestedEtag.CompareTo(lowestInMemoryDocumentAddedAfterCommit.Etag) > 0)
				{
					lowestInMemoryDocumentAddedAfterCommit = null;
					DisableCollectingDocumentsAfterCommit = false;
				}
			}
			else
			{
				if (lowestInMemoryDocumentAddedAfterCommit != null && SystemTime.UtcNow - lowestInMemoryDocumentAddedAfterCommit.AddedAt > TimeSpan.FromMinutes(10))
				{
					DisableCollectingDocumentsAfterCommit = true;
				}
			}
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:21,代码来源:PrefetchingBehavior.cs

示例13: GetMinimumEtagFromFutureBatches

        /// <summary>
        /// Gets the minimum etag from the future batches that is bigger than the startEtag
        /// </summary>
        /// <param name="startEtag">The minimum etag we start to look from</param>
        /// <returns></returns>
        private Etag GetMinimumEtagFromFutureBatches(Etag startEtag)
        {
            Etag minEtag = null;

            foreach (var futureIndexBatch in futureIndexBatches.Values)
            {
                if (startEtag.CompareTo(futureIndexBatch.StartingEtag) < 0 &&
                    (minEtag == null || futureIndexBatch.StartingEtag.CompareTo(minEtag) < 0))
                {
                    minEtag = futureIndexBatch.StartingEtag;
                }
            }

            if (minEtag != null && minEtag != Etag.Empty)
                minEtag = Abstractions.Util.EtagUtil.Increment(minEtag, -1);

            return minEtag;
        }
开发者ID:fitzchak,项目名称:ravendb,代码行数:23,代码来源:PrefetchingBehavior.cs

示例14: CleanupDocuments

        public void CleanupDocuments(Etag lastIndexedEtag)
        {
            if (lastIndexedEtag == null)
                return;

            foreach (var docToRemove in documentsToRemove)
            {
                if (docToRemove.Value == null)
                    continue;
                if (docToRemove.Value.All(etag => lastIndexedEtag.CompareTo(etag) > 0) == false)
                    continue;

                HashSet<Etag> _;
                documentsToRemove.TryRemove(docToRemove.Key, out _);
            }

            HandleCleanupOfUnusedDocumentsInQueue();
        }
开发者ID:fitzchak,项目名称:ravendb,代码行数:18,代码来源:PrefetchingBehavior.cs

示例15: WaitForReplicationFromServerAsync

        private async Task WaitForReplicationFromServerAsync(string url, string sourceUrl, string sourceDbId, Etag etag, ReplicatedEtagInfo[] latestEtags, int index, CancellationToken cancellationToken)
        {
            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();

                try
                {
                    var etags = await GetReplicatedEtagsFor(url, sourceUrl, sourceDbId);

                    latestEtags[index] = etags;

                    var replicated = etag.CompareTo(etags.DocumentEtag) <= 0;

                    if (replicated)
                        return;
                }
                catch (Exception e)
                {
                    log.DebugException(string.Format("Failed to get replicated etags for '{0}'.", sourceUrl), e);

                    throw;
                }

                await Task.Delay(100, cancellationToken);
            }
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:27,代码来源:ReplicationBehavior.cs


注:本文中的Etag.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。