本文整理汇总了C#中IStorageActionsAccessor类的典型用法代码示例。如果您正苦于以下问题:C# IStorageActionsAccessor类的具体用法?C# IStorageActionsAccessor怎么用?C# IStorageActionsAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStorageActionsAccessor类属于命名空间,在下文中一共展示了IStorageActionsAccessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetNextIdentityValueWithoutOverwritingOnExistingDocuments
public long GetNextIdentityValueWithoutOverwritingOnExistingDocuments(string key,
IStorageActionsAccessor actions,
TransactionInformation transactionInformation)
{
int tries;
return GetNextIdentityValueWithoutOverwritingOnExistingDocuments(key, actions, transactionInformation, out tries);
}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:7,代码来源:DocumentActions.cs
示例2: IsIndexStale
protected override bool IsIndexStale(IndexStats indexesStat, IStorageActionsAccessor actions, bool isIdle, Reference<bool> onlyFoundIdleWork)
{
var isStale = actions.Staleness.IsMapStale(indexesStat.Id);
var indexingPriority = indexesStat.Priority;
if (isStale == false)
return false;
if (indexingPriority == IndexingPriority.None)
return true;
if ((indexingPriority & IndexingPriority.Normal) == IndexingPriority.Normal)
{
onlyFoundIdleWork.Value = false;
return true;
}
if ((indexingPriority & (IndexingPriority.Disabled | IndexingPriority.Error)) != IndexingPriority.None)
return false;
if (isIdle == false)
return false; // everything else is only valid on idle runs
if ((indexingPriority & IndexingPriority.Idle) == IndexingPriority.Idle)
return true;
if ((indexingPriority & IndexingPriority.Abandoned) == IndexingPriority.Abandoned)
{
var timeSinceLastIndexing = (SystemTime.UtcNow - indexesStat.LastIndexingTime);
return (timeSinceLastIndexing > context.Configuration.TimeToWaitBeforeRunningAbandonedIndexes);
}
throw new InvalidOperationException("Unknown indexing priority for index " + indexesStat.Id + ": " + indexesStat.Priority);
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:34,代码来源:IndexingExecuter.cs
示例3: GetApplicableTask
protected override DatabaseTask GetApplicableTask(IStorageActionsAccessor actions)
{
var removeFromIndexTasks = (DatabaseTask)actions.Tasks.GetMergedTask<RemoveFromIndexTask>();
var touchReferenceDocumentIfChangedTask = removeFromIndexTasks ?? actions.Tasks.GetMergedTask<TouchReferenceDocumentIfChangedTask>();
return touchReferenceDocumentIfChangedTask;
}
开发者ID:cocytus,项目名称:ravendb,代码行数:7,代码来源:IndexingExecuter.cs
示例4: Delete
public void Delete(string fileName, IStorageActionsAccessor actionsAccessor = null)
{
RavenJObject metadata = null;
Action<IStorageActionsAccessor> delete = accessor =>
{
accessor.DeleteConfig(RavenFileNameHelper.ConflictConfigNameForFile(fileName));
metadata = accessor.GetFile(fileName, 0, 0).Metadata;
metadata.Remove(SynchronizationConstants.RavenSynchronizationConflict);
metadata.Remove(SynchronizationConstants.RavenSynchronizationConflictResolution);
accessor.UpdateFileMetadata(fileName, metadata);
};
if (actionsAccessor != null)
{
delete(actionsAccessor);
}
else
{
storage.Batch(delete);
}
if (metadata != null)
{
index.Index(fileName, metadata);
}
}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:27,代码来源:ConflictArtifactManager.cs
示例5: IndexDocuments
public override void IndexDocuments(
AbstractViewGenerator viewGenerator,
IEnumerable<dynamic> documents,
WorkContext context,
IStorageActionsAccessor actions,
DateTime minimumTimestamp)
{
actions.Indexing.SetCurrentIndexStatsTo(name);
var count = 0;
Func<object, object> documentIdFetcher = null;
var reduceKeys = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
var documentsWrapped = documents.Select(doc =>
{
var documentId = doc.__document_id;
foreach (var reduceKey in actions.MappedResults.DeleteMappedResultsForDocumentId((string)documentId, name))
{
reduceKeys.Add(reduceKey);
}
return doc;
});
foreach (var doc in RobustEnumeration(documentsWrapped, viewGenerator.MapDefinition, actions, context))
{
count++;
documentIdFetcher = CreateDocumentIdFetcherIfNeeded(documentIdFetcher, doc);
var docIdValue = documentIdFetcher(doc);
if (docIdValue == null)
throw new InvalidOperationException("Could not find document id for this document");
var reduceValue = viewGenerator.GroupByExtraction(doc);
if (reduceValue == null)
{
logIndexing.DebugFormat("Field {0} is used as the reduce key and cannot be null, skipping document {1}", viewGenerator.GroupByExtraction, docIdValue);
continue;
}
var reduceKey = ReduceKeyToString(reduceValue);
var docId = docIdValue.ToString();
reduceKeys.Add(reduceKey);
var data = GetMapedData(doc);
logIndexing.DebugFormat("Mapped result for '{0}': '{1}'", name, data);
var hash = ComputeHash(name, reduceKey);
actions.MappedResults.PutMappedResult(name, docId, reduceKey, data, hash);
actions.Indexing.IncrementSuccessIndexing();
}
actions.Tasks.AddTask(new ReduceTask
{
Index = name,
ReduceKeys = reduceKeys.ToArray()
}, minimumTimestamp);
logIndexing.DebugFormat("Mapped {0} documents for {1}", count, name);
}
开发者ID:dplaskon,项目名称:ravendb,代码行数:60,代码来源:MapReduceIndex.cs
示例6: SynchronizationTimeout
private TimeSpan SynchronizationTimeout(IStorageActionsAccessor accessor)
{
var timeoutConfigExists = accessor.TryGetConfigurationValue(
SynchronizationConstants.RavenSynchronizationLockTimeout, out configuredTimeout);
return timeoutConfigExists ? configuredTimeout : defaultTimeout;
}
开发者ID:randacc,项目名称:ravendb,代码行数:7,代码来源:FileLockManager.cs
示例7: IndexingStorageActions
public IndexingStorageActions(TableStorage tableStorage, IUuidGenerator generator, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IStorageActionsAccessor storageActionsAccessor, IBufferPool bufferPool)
: base(snapshot, bufferPool)
{
this.tableStorage = tableStorage;
this.generator = generator;
this.writeBatch = writeBatch;
this.currentStorageActionsAccessor = storageActionsAccessor;
}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:8,代码来源:IndexingStorageActions.cs
示例8: ReplicateDocument
private void ReplicateDocument(IStorageActionsAccessor actions, string id, RavenJObject metadata, RavenJObject document, string src)
{
var existingDoc = actions.Documents.DocumentByKey(id, null);
if (existingDoc == null)
{
log.DebugFormat("New document {0} replicated successfully from {1}", id, src);
actions.Documents.AddDocument(id, Guid.Empty, document, metadata);
return;
}
var existingDocumentIsInConflict = existingDoc.Metadata[ReplicationConstants.RavenReplicationConflict] != null;
if (existingDocumentIsInConflict == false && // if the current document is not in conflict, we can continue without having to keep conflict semantics
(IsDirectChildOfCurrentDocument(existingDoc, metadata))) // this update is direct child of the existing doc, so we are fine with overwriting this
{
log.DebugFormat("Existing document {0} replicated successfully from {1}", id, src);
actions.Documents.AddDocument(id, null, document, metadata);
return;
}
var newDocumentConflictId = id + "/conflicts/" +
metadata.Value<string>(ReplicationConstants.RavenReplicationSource) + "/" +
metadata.Value<string>("@etag");
metadata.Add(ReplicationConstants.RavenReplicationConflict, RavenJToken.FromObject(true));
actions.Documents.AddDocument(newDocumentConflictId, null, document, metadata);
if (existingDocumentIsInConflict) // the existing document is in conflict
{
log.DebugFormat("Conflicted document {0} has a new version from {1}, adding to conflicted documents", id, src);
// just update the current doc with the new conflict document
existingDoc.DataAsJson.Value<RavenJArray>("Conflicts").Add(RavenJToken.FromObject(newDocumentConflictId));
actions.Documents.AddDocument(id, existingDoc.Etag, existingDoc.DataAsJson, existingDoc.Metadata);
return;
}
log.DebugFormat("Existing document {0} is in conflict with replicated version from {1}, marking document as conflicted", id, src);
// we have a new conflict
// move the existing doc to a conflict and create a conflict document
var existingDocumentConflictId = id + "/conflicts/" + Database.TransactionalStorage.Id + "/" + existingDoc.Etag;
existingDoc.Metadata.Add(ReplicationConstants.RavenReplicationConflict, RavenJToken.FromObject(true));
actions.Documents.AddDocument(existingDocumentConflictId, null, existingDoc.DataAsJson, existingDoc.Metadata);
actions.Documents.AddDocument(id, null,
new RavenJObject
{
{
"Conflicts", new RavenJArray(existingDocumentConflictId, newDocumentConflictId)
}
},
new RavenJObject
{
{ReplicationConstants.RavenReplicationConflict, true},
{"@Http-Status-Code", 409},
{"@Http-Status-Description", "Conflict"}
});
}
开发者ID:kblooie,项目名称:ravendb,代码行数:57,代码来源:DocumentReplicationResponder.cs
示例9: MappedResultsStorageActions
public MappedResultsStorageActions(TableStorage tableStorage, IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool, IStorageActionsAccessor storageActionsAccessor)
: base(snapshot, bufferPool)
{
this.tableStorage = tableStorage;
this.generator = generator;
this.documentCodecs = documentCodecs;
this.writeBatch = writeBatch;
this.storageActionsAccessor = storageActionsAccessor;
}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:9,代码来源:MappedResultsStorageActions.cs
示例10: MappedResultsStorageActions
public MappedResultsStorageActions(TableStorage tableStorage, IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, Reference<SnapshotReader> snapshot,
Reference<WriteBatch> writeBatch, IBufferPool bufferPool, IStorageActionsAccessor storageActionsAccessor, ConcurrentDictionary<int, RemainingReductionPerLevel> ScheduledReductionsPerViewAndLevel)
: base(snapshot, bufferPool)
{
this.tableStorage = tableStorage;
this.generator = generator;
this.documentCodecs = documentCodecs;
this.writeBatch = writeBatch;
this.storageActionsAccessor = storageActionsAccessor;
this.scheduledReductionsPerViewAndLevel = ScheduledReductionsPerViewAndLevel;
}
开发者ID:VPashkov,项目名称:ravendb,代码行数:11,代码来源:MappedResultsStorageActions.cs
示例11: SynchronizationTimeout
private TimeSpan SynchronizationTimeout(IStorageActionsAccessor accessor)
{
string timeoutConfigKey = string.Empty;
accessor.TryGetConfigurationValue<string>(SynchronizationConstants.RavenSynchronizationLockTimeout, out timeoutConfigKey);
TimeSpan timeoutConfiguration;
if (TimeSpan.TryParse(timeoutConfigKey, out timeoutConfiguration))
return timeoutConfiguration;
return defaultTimeout;
}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:11,代码来源:FileLockManager.cs
示例12: LockByCreatingSyncConfiguration
public void LockByCreatingSyncConfiguration(string fileName, ServerInfo sourceServer, IStorageActionsAccessor accessor)
{
var syncLock = new SynchronizationLock
{
SourceServer = sourceServer,
FileLockedAt = DateTime.UtcNow
};
accessor.SetConfig(RavenFileNameHelper.SyncLockNameForFile(fileName), syncLock.AsConfig());
log.Debug("File '{0}' was locked", fileName);
}
开发者ID:randacc,项目名称:ravendb,代码行数:12,代码来源:FileLockManager.cs
示例13: IndexDocuments
public override void IndexDocuments(
AbstractViewGenerator viewGenerator,
IEnumerable<object> documents,
WorkContext context,
IStorageActionsAccessor actions)
{
actions.Indexing.SetCurrentIndexStatsTo(name);
var count = 0;
Write(indexWriter =>
{
bool madeChanges = false;
PropertyDescriptorCollection properties = null;
var processedKeys = new HashSet<string>();
var documentsWrapped = documents.Select((dynamic doc) =>
{
var documentId = doc.__document_id.ToString();
if (processedKeys.Add(documentId) == false)
return doc;
madeChanges = true;
context.IndexUpdateTriggers.Apply(trigger => trigger.OnIndexEntryDeleted(name, documentId));
indexWriter.DeleteDocuments(new Term("__document_id", documentId));
return doc;
});
foreach (var doc in RobustEnumeration(documentsWrapped, viewGenerator.MapDefinition, actions, context))
{
count++;
string newDocId;
IEnumerable<AbstractField> fields;
if (doc is DynamicJsonObject)
fields = ExtractIndexDataFromDocument((DynamicJsonObject) doc, out newDocId);
else
fields = ExtractIndexDataFromDocument(properties, doc, out newDocId);
if (newDocId != null)
{
var luceneDoc = new Document();
luceneDoc.Add(new Field("__document_id", newDocId, Field.Store.YES, Field.Index.NOT_ANALYZED));
madeChanges = true;
CopyFieldsToDocument(luceneDoc, fields);
context.IndexUpdateTriggers.Apply(trigger => trigger.OnIndexEntryCreated(name, newDocId, luceneDoc));
log.DebugFormat("Index '{0}' resulted in: {1}", name, luceneDoc);
indexWriter.AddDocument(luceneDoc);
}
actions.Indexing.IncrementSuccessIndexing();
}
return madeChanges;
});
log.DebugFormat("Indexed {0} documents for {1}", count, name);
}
开发者ID:Inferis,项目名称:ravendb,代码行数:53,代码来源:SimpleIndex.cs
示例14: LockByCreatingSyncConfiguration
public void LockByCreatingSyncConfiguration(string fileName, FileSystemInfo sourceFileSystem, IStorageActionsAccessor accessor)
{
var syncLock = new SynchronizationLock
{
SourceFileSystem = sourceFileSystem,
FileLockedAt = DateTime.UtcNow
};
accessor.SetConfig(RavenFileNameHelper.SyncLockNameForFile(fileName), JsonExtensions.ToJObject(syncLock));
log.Debug("File '{0}' was locked", fileName);
}
开发者ID:IdanHaim,项目名称:ravendb,代码行数:12,代码来源:FileLockManager.cs
示例15: ReplicateAttachment
private void ReplicateAttachment(IStorageActionsAccessor actions, string id, JObject metadata, byte[] data, Guid lastEtag ,string src)
{
var existingAttachment = actions.Attachments.GetAttachment(id);
if (existingAttachment == null)
{
log.DebugFormat("New attachment {0} replicated successfully from {1}", id, src);
actions.Attachments.AddAttachment(id, Guid.Empty, data, metadata);
return;
}
var existingDocumentIsInConflict = existingAttachment.Metadata[ReplicationConstants.RavenReplicationConflict] != null;
if (existingDocumentIsInConflict == false && // if the current document is not in conflict, we can continue without having to keep conflict semantics
(IsDirectChildOfCurrentAttachment(existingAttachment, metadata))) // this update is direct child of the existing doc, so we are fine with overwriting this
{
log.DebugFormat("Existing document {0} replicated successfully from {1}", id, src);
actions.Attachments.AddAttachment(id, null, data, metadata);
return;
}
var newDocumentConflictId = id + "/conflicts/" +
metadata.Value<string>(ReplicationConstants.RavenReplicationSource) +
"/" + lastEtag;
metadata.Add(ReplicationConstants.RavenReplicationConflict, JToken.FromObject(true));
actions.Attachments.AddAttachment(newDocumentConflictId, null, data, metadata);
if (existingDocumentIsInConflict) // the existing document is in conflict
{
log.DebugFormat("Conflicted document {0} has a new version from {1}, adding to conflicted documents", id, src);
// just update the current doc with the new conflict document
existingAttachment.Metadata.Value<JArray>("Conflicts").Add(JToken.FromObject(newDocumentConflictId));
actions.Attachments.AddAttachment(id, existingAttachment.Etag, existingAttachment.Data, existingAttachment.Metadata);
return;
}
log.DebugFormat("Existing document {0} is in conflict with replicated version from {1}, marking document as conflicted", id, src);
// we have a new conflict
// move the existing doc to a conflict and create a conflict document
var existingDocumentConflictId = id + "/conflicts/" + Database.TransactionalStorage.Id + "/" + existingAttachment.Etag;
existingAttachment.Metadata.Add(ReplicationConstants.RavenReplicationConflict, JToken.FromObject(true));
actions.Attachments.AddAttachment(existingDocumentConflictId, null, existingAttachment.Data, existingAttachment.Metadata);
actions.Attachments.AddAttachment(id, null,
new JObject(
new JProperty("Conflicts", new JArray(existingDocumentConflictId, newDocumentConflictId))).ToBytes(),
new JObject(
new JProperty(ReplicationConstants.RavenReplicationConflict, true),
new JProperty("@Http-Status-Code", 409),
new JProperty("@Http-Status-Description", "Conflict")
));
}
开发者ID:philiphoy,项目名称:ravendb,代码行数:52,代码来源:AttachmentReplicationResponder.cs
示例16: TimeoutExceeded
public bool TimeoutExceeded(string fileName, IStorageActionsAccessor accessor)
{
SynchronizationLock syncLock;
try
{
syncLock = accessor.GetConfig(RavenFileNameHelper.SyncLockNameForFile(fileName)).JsonDeserialization<SynchronizationLock>();
}
catch (FileNotFoundException)
{
return true;
}
return (DateTime.UtcNow - syncLock.FileLockedAt).TotalMilliseconds > SynchronizationConfigAccessor.GetOrDefault(accessor).SynchronizationLockTimeoutMiliseconds;
}
开发者ID:IdanHaim,项目名称:ravendb,代码行数:15,代码来源:FileLockManager.cs
示例17: GetOrDefault
public static SynchronizationConfig GetOrDefault(IStorageActionsAccessor accessor)
{
try
{
if (accessor.ConfigExists(SynchronizationConstants.RavenSynchronizationConfig) == false)
return new SynchronizationConfig(); // return a default one
return accessor.GetConfig(SynchronizationConstants.RavenSynchronizationConfig).JsonDeserialization<SynchronizationConfig>();
}
catch (Exception e)
{
Log.Warn("Could not deserialize a synchronization configuration", e);
return new SynchronizationConfig(); // return a default one
}
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:15,代码来源:SynchronizationConfigAccessor.cs
示例18: TimeoutExceeded
public bool TimeoutExceeded(string fileName, IStorageActionsAccessor accessor)
{
SynchronizationLock syncLock;
try
{
syncLock =
accessor.GetConfig(RavenFileNameHelper.SyncLockNameForFile(fileName)).AsObject<SynchronizationLock>();
}
catch (FileNotFoundException)
{
return true;
}
return DateTime.UtcNow - syncLock.FileLockedAt > SynchronizationTimeout(accessor);
}
开发者ID:randacc,项目名称:ravendb,代码行数:16,代码来源:FileLockManager.cs
示例19: FilterDocuments
/// <summary>
/// We need to NOT remove documents that has been removed then added.
/// We DO remove documents that would be filtered out because of an Entity Name changed, though.
/// </summary>
private bool FilterDocuments(WorkContext context, IStorageActionsAccessor accessor, string key)
{
var documentMetadataByKey = accessor.Documents.DocumentMetadataByKey(key, null);
if (documentMetadataByKey == null)
return true;
var generator = context.IndexDefinitionStorage.GetViewGenerator(Index);
if (generator == null)
return false;
if (generator.ForEntityNames.Count == 0)
return false;// there is a new document and this index applies to it
var entityName = documentMetadataByKey.Metadata.Value<string>(Constants.RavenEntityName);
if (entityName == null)
return true; // this document doesn't belong to this index any longer, need to remove it
return generator.ForEntityNames.Contains(entityName) == false;
}
开发者ID:jtmueller,项目名称:ravendb,代码行数:22,代码来源:RemoveFromIndexTask.cs
示例20: TryGetDeserializedConfig
private static bool TryGetDeserializedConfig(IStorageActionsAccessor accessor, string configurationName, out FileVersioningConfiguration fileVersioningConfiguration)
{
if (accessor.ConfigExists(configurationName) == false)
{
fileVersioningConfiguration = null;
return false;
}
var configuration = accessor.GetConfig(configurationName);
if (configuration == null)
{
fileVersioningConfiguration = null;
return false;
}
fileVersioningConfiguration = configuration.JsonDeserialization<FileVersioningConfiguration>();
return true;
}
开发者ID:GorelH,项目名称:ravendb,代码行数:18,代码来源:VersioningUtil.cs
注:本文中的IStorageActionsAccessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论