本文整理汇总了C#中Raven.Bundles.Replication.Tasks.ReplicationStrategy.OriginsFromOtherDestination方法的典型用法代码示例。如果您正苦于以下问题:C# ReplicationStrategy.OriginsFromOtherDestination方法的具体用法?C# ReplicationStrategy.OriginsFromOtherDestination怎么用?C# ReplicationStrategy.OriginsFromOtherDestination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Bundles.Replication.Tasks.ReplicationStrategy
的用法示例。
在下文中一共展示了ReplicationStrategy.OriginsFromOtherDestination方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetJsonDocuments
private JsonDocumentsToReplicate GetJsonDocuments(SourceReplicationInformationWithBatchInformation destinationsReplicationInformationForSource, ReplicationStrategy destination, PrefetchingBehavior prefetchingBehavior, ReplicationStatisticsRecorder.ReplicationStatisticsRecorderScope scope)
{
var timeout = TimeSpan.FromSeconds(docDb.Configuration.Replication.FetchingFromDiskTimeoutInSeconds);
var duration = Stopwatch.StartNew();
var result = new JsonDocumentsToReplicate
{
LastEtag = Etag.Empty,
};
try
{
var destinationId = destinationsReplicationInformationForSource.ServerInstanceId.ToString();
var maxNumberOfItemsToReceiveInSingleBatch = destinationsReplicationInformationForSource.MaxNumberOfItemsToReceiveInSingleBatch;
docDb.TransactionalStorage.Batch(actions =>
{
var lastEtag = destinationsReplicationInformationForSource.LastDocumentEtag;
int docsSinceLastReplEtag = 0;
List<JsonDocument> docsToReplicate;
List<JsonDocument> filteredDocsToReplicate;
result.LastEtag = lastEtag;
while (true)
{
docDb.WorkContext.CancellationToken.ThrowIfCancellationRequested();
docsToReplicate = GetDocsToReplicate(actions, prefetchingBehavior, result, maxNumberOfItemsToReceiveInSingleBatch);
filteredDocsToReplicate =
docsToReplicate
.Where(document =>
{
var info = docDb.Documents.GetRecentTouchesFor(document.Key);
if (info != null)
{
if (info.TouchedEtag.CompareTo(result.LastEtag) > 0)
{
log.Debug(
"Will not replicate document '{0}' to '{1}' because the updates after etag {2} are related document touches",
document.Key, destinationId, info.TouchedEtag);
return false;
}
}
string reason;
return destination.FilterDocuments(destinationId, document.Key, document.Metadata, out reason) &&
prefetchingBehavior.FilterDocuments(document);
})
.ToList();
docsSinceLastReplEtag += docsToReplicate.Count;
result.CountOfFilteredDocumentsWhichAreSystemDocuments +=
docsToReplicate.Count(doc => destination.IsSystemDocumentId(doc.Key));
result.CountOfFilteredDocumentsWhichOriginFromOtherDestinations +=
docsToReplicate.Count(doc => destination.OriginsFromOtherDestination(_transactionalStorageId, doc.Metadata) && !destination.IsSystemDocumentId(doc.Key));
if (docsToReplicate.Count > 0)
{
var lastDoc = docsToReplicate.Last();
Debug.Assert(lastDoc.Etag != null);
result.LastEtag = lastDoc.Etag;
if (lastDoc.LastModified.HasValue)
result.LastLastModified = lastDoc.LastModified.Value;
}
if (docsToReplicate.Count == 0 || filteredDocsToReplicate.Count != 0)
{
break;
}
log.Debug("All the docs were filtered, trying another batch from etag [>{0}]", result.LastEtag);
if (duration.Elapsed > timeout)
break;
}
log.Debug(() =>
{
if (docsSinceLastReplEtag == 0)
return string.Format("No documents to replicate to {0} - last replicated etag: {1}", destination,
lastEtag);
if (docsSinceLastReplEtag == filteredDocsToReplicate.Count)
return string.Format("Replicating {0} docs [>{1}] to {2}.",
docsSinceLastReplEtag,
lastEtag,
destination);
var diff = docsToReplicate.Except(filteredDocsToReplicate).Select(x => x.Key);
return string.Format("Replicating {1} docs (out of {0}) [>{4}] to {2}. [Not replicated: {3}]",
docsSinceLastReplEtag,
filteredDocsToReplicate.Count,
destination,
string.Join(", ", diff),
lastEtag);
});
scope.Record(new RavenJObject
{
{"StartEtag", lastEtag.ToString()},
//.........这里部分代码省略.........