本文整理汇总了C#中ITransactionalStorage类的典型用法代码示例。如果您正苦于以下问题:C# ITransactionalStorage类的具体用法?C# ITransactionalStorage怎么用?C# ITransactionalStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITransactionalStorage类属于命名空间,在下文中一共展示了ITransactionalStorage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatingOrOpeningAndWritting
public static SynchronizingFileStream CreatingOrOpeningAndWritting(ITransactionalStorage storage, IndexStorage search,
StorageOperationsTask operationsTask,
string fileName, NameValueCollection metadata)
{
return new SynchronizingFileStream(storage, fileName, StorageStreamAccess.CreateAndWrite, metadata, search,
operationsTask) { PreventUploadComplete = true };
}
示例2: SynchronizingFileStream
private SynchronizingFileStream(ITransactionalStorage transactionalStorage, string fileName,
StorageStreamAccess storageStreamAccess, NameValueCollection metadata,
IndexStorage indexStorage, StorageOperationsTask operations)
: base(transactionalStorage, fileName, storageStreamAccess, metadata, indexStorage, operations)
{
md5Hasher = new MD5CryptoServiceProvider();
}
示例3: StorageSignatureRepository
public StorageSignatureRepository(ITransactionalStorage storage, string fileName)
{
_tempDirectory = TempDirectoryTools.Create();
_storage = storage;
_fileName = fileName;
_createdFiles = new Dictionary<string, FileStream>();
}
示例4: ReadIndexesFromCatalog
private void ReadIndexesFromCatalog(IEnumerable<AbstractViewGenerator> compiledGenerators, ITransactionalStorage transactionalStorage)
{
foreach (var generator in compiledGenerators)
{
var copy = generator;
var displayNameAtt = TypeDescriptor.GetAttributes(copy)
.OfType<DisplayNameAttribute>()
.FirstOrDefault();
var name = displayNameAtt != null ? displayNameAtt.DisplayName : copy.GetType().Name;
transactionalStorage.Batch(actions =>
{
if (actions.Indexing.GetIndexesStats().Any(x => x.Name == name))
return;
actions.Indexing.AddIndex(name, copy.ReduceDefinition != null);
});
var indexDefinition = new IndexDefinition
{
Name = name,
Map = "Compiled map function: " + generator.GetType().AssemblyQualifiedName,
// need to supply this so the index storage will create map/reduce index
Reduce = generator.ReduceDefinition == null ? null : "Compiled reduce function: " + generator.GetType().AssemblyQualifiedName,
Indexes = generator.Indexes,
Stores = generator.Stores,
IsCompiled = true
};
indexCache.AddOrUpdate(name, copy, (s, viewGenerator) => copy);
indexDefinitions.AddOrUpdate(name, indexDefinition, (s1, definition) => indexDefinition);
}
}
示例5: when_there_are_multiple_map_results_for_multiple_indexes
private static void when_there_are_multiple_map_results_for_multiple_indexes(ITransactionalStorage transactionalStorage)
{
transactionalStorage.Initialize(new DummyUuidGenerator());
transactionalStorage.Batch(accessor =>
{
accessor.Indexing.AddIndex("a",true);
accessor.Indexing.AddIndex("b", true);
accessor.Indexing.AddIndex("c", true);
accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
});
transactionalStorage.Batch(actionsAccessor =>
{
Assert.True(actionsAccessor.Staleness.IsReduceStale("a"));
Assert.True(actionsAccessor.Staleness.IsReduceStale("b"));
Assert.True(actionsAccessor.Staleness.IsReduceStale("c"));
});
}
示例6: StorageStream
protected StorageStream(ITransactionalStorage transactionalStorage, string fileName,
StorageStreamAccess storageStreamAccess,
RavenJObject metadata, IndexStorage indexStorage, StorageOperationsTask operations)
{
TransactionalStorage = transactionalStorage;
StorageStreamAccess = storageStreamAccess;
Name = fileName;
switch (storageStreamAccess)
{
case StorageStreamAccess.Read:
TransactionalStorage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
if (fileHeader.TotalSize == null)
{
throw new FileNotFoundException("File is not uploaded yet");
}
Metadata = fileHeader.Metadata;
Seek(0, SeekOrigin.Begin);
break;
case StorageStreamAccess.CreateAndWrite:
TransactionalStorage.Batch(accessor =>
{
operations.IndicateFileToDelete(fileName);
accessor.PutFile(fileName, null, metadata);
indexStorage.Index(fileName, metadata);
});
Metadata = metadata;
break;
default:
throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
}
}
示例7: EtagSynchronizer
public EtagSynchronizer(EtagSynchronizerType type, ITransactionalStorage transactionalStorage)
{
this.type = type;
this.transactionalStorage = transactionalStorage;
LoadSynchronizationState();
}
示例8: LocalRdcManager
public LocalRdcManager(ISignatureRepository signatureRepository, ITransactionalStorage transactionalStorage,
SigGenerator sigGenerator)
{
_signatureRepository = signatureRepository;
_transactionalStorage = transactionalStorage;
_sigGenerator = sigGenerator;
}
示例9: AbstractIndexingExecuter
protected AbstractIndexingExecuter(
ITransactionalStorage transactionalStorage, WorkContext context, TaskScheduler scheduler)
{
this.transactionalStorage = transactionalStorage;
this.context = context;
this.scheduler = scheduler;
}
示例10: SynchronizingFileStream
private SynchronizingFileStream(ITransactionalStorage transactionalStorage, string fileName,
StorageStreamAccess storageStreamAccess, RavenJObject metadata,
IndexStorage indexStorage, StorageOperationsTask operations)
: base(transactionalStorage, fileName, storageStreamAccess, metadata, indexStorage, operations)
{
md5Hasher = Encryptor.Current.CreateHash();
}
示例11: IndexDefinitionStorage
public IndexDefinitionStorage(
ITransactionalStorage transactionalStorage,
string path,
IEnumerable<AbstractViewGenerator> compiledGenerators,
AbstractDynamicCompilationExtension[] extensions)
{
this.extensions = extensions;// this is used later in the ctor, so it must appears first
this.path = Path.Combine(path, IndexDefDir);
if (Directory.Exists(this.path) == false)
Directory.CreateDirectory(this.path);
this.extensions = extensions;
foreach (var index in Directory.GetFiles(this.path, "*.index"))
{
try
{
AddAndCompileIndex(
MonoHttpUtility.UrlDecode(Path.GetFileNameWithoutExtension(index)),
JsonConvert.DeserializeObject<IndexDefinition>(File.ReadAllText(index), new JsonEnumConverter())
);
}
catch (Exception e)
{
logger.Warn("Could not compile index " + index + ", skipping bad index", e);
}
}
//compiled view generators always overwrite dynamic views
foreach (var generator in compiledGenerators)
{
var copy = generator;
var displayNameAtt = TypeDescriptor.GetAttributes(copy)
.OfType<DisplayNameAttribute>()
.FirstOrDefault();
var name = displayNameAtt != null ? displayNameAtt.DisplayName : copy.GetType().Name;
transactionalStorage.Batch(actions =>
{
if (actions.Indexing.GetIndexesStats().Any(x => x.Name == name))
return;
actions.Indexing.AddIndex(name);
});
var indexDefinition = new IndexDefinition
{
Map = "Compiled map function: " + generator.GetType().AssemblyQualifiedName,
// need to supply this so the index storage will create map/reduce index
Reduce = generator.ReduceDefinition == null ? null : "Compiled reduce function: " + generator.GetType().AssemblyQualifiedName,
Indexes = generator.Indexes,
Stores = generator.Stores,
IsCompiled = true
};
indexCache.AddOrUpdate(name, copy, (s, viewGenerator) => copy);
indexDefinitions.AddOrUpdate(name, indexDefinition, (s1, definition) => indexDefinition);
}
}
示例12: TimeoutExceeded
public bool TimeoutExceeded(string fileName, ITransactionalStorage storage)
{
var result = false;
storage.Batch(accessor => result = TimeoutExceeded(fileName, accessor));
return result;
}
示例13: StorageOperationsTask
public StorageOperationsTask(ITransactionalStorage storage, IndexStorage search, INotificationPublisher notificationPublisher)
{
this.storage = storage;
this.search = search;
this.notificationPublisher = notificationPublisher;
InitializeTimer();
}
示例14: GetOrDefault
public static SynchronizationConfig GetOrDefault(ITransactionalStorage storage)
{
SynchronizationConfig result = null;
storage.Batch(accessor => result = GetOrDefault(accessor));
return result ?? new SynchronizationConfig();
}
示例15: RavenFileSystem
public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState recievedTransportState = null)
{
this.Name = name;
this.systemConfiguration = systemConfiguration;
var storageType = systemConfiguration.FileSystem.DefaultStorageTypeName;
storage = CreateTransactionalStorage(storageType, systemConfiguration);
search = new IndexStorage(systemConfiguration.FileSystem.IndexStoragePath, systemConfiguration.Settings);
sigGenerator = new SigGenerator();
var replicationHiLo = new SynchronizationHiLo(storage);
var sequenceActions = new SequenceActions(storage);
transportState = recievedTransportState ?? new TransportState();
notificationPublisher = new NotificationPublisher(transportState);
fileLockManager = new FileLockManager();
storage.Initialize();
search.Initialize();
var uuidGenerator = new UuidGenerator(sequenceActions);
historian = new Historian(storage, replicationHiLo, uuidGenerator);
BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024);
conflictArtifactManager = new ConflictArtifactManager(storage, search);
conflictDetector = new ConflictDetector();
conflictResolver = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog));
synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration);
storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher);
metricsCounters = new MetricsCountersManager();
AppDomain.CurrentDomain.ProcessExit += ShouldDispose;
AppDomain.CurrentDomain.DomainUnload += ShouldDispose;
}