//init public QueueBase(ITemporaryStorage <TSignal> temporaryStorage) { _temporaryStorage = temporaryStorage; _itemsQueue = new Dictionary <int, Queue <SignalWrapper <TSignal> > >(); _queueLock = new object(); }
protected override async Task SaveAsync(TextAndVersion textAndVersion, CancellationToken cancellationToken) { this.storage = this.storageService.CreateTemporaryStorage(CancellationToken.None); this.storedVersion = textAndVersion.Version; this.storedFilePath = textAndVersion.FilePath; await storage.WriteTextAsync(textAndVersion.Text).ConfigureAwait(false); }
public TsdbClient( IStorageSelector <TKey, TEntry> storageSelector, ITemporaryStorage <TKey, TEntry> temporaryStorage, ITsdbLogger logger) : this(storageSelector, null, temporaryStorage, logger) { }
public TsdbClient( IStorageSelector <TKey, TEntry> storageSelector, IPublishSubscribe <TKey, TEntry> remotePublishSubscribe, ITemporaryStorage <TKey, TEntry> temporaryStorage) : this(storageSelector, remotePublishSubscribe, temporaryStorage, NullTsdbLogger.Default) { }
public TsdbClient( IDynamicStorageSelector <TKey, TEntry> dynamicStorageSelector, IVolumeStorageSelector <TKey, TEntry> volumeStorageSelector, ITemporaryStorage <TKey, TEntry> temporaryStorage) : this(dynamicStorageSelector, volumeStorageSelector, null, temporaryStorage, NullTsdbLogger.Default) { }
public TsdbClient( IDynamicStorageSelector <TKey, TEntry> dynamicStorageSelector, IVolumeStorageSelector <TKey, TEntry> volumeStorageSelector, IPublishSubscribe <TKey, TEntry> remotePublishSubscribe, ITemporaryStorage <TKey, TEntry> temporaryStorage) : this(dynamicStorageSelector, volumeStorageSelector, remotePublishSubscribe, temporaryStorage, NullTsdbLogger.Default) { }
internal override Task SaveRootAsync(TRoot root, CancellationToken cancellationToken) { var storageService = this.WorkspaceServices.GetService <ITemporaryStorageService>(); this.storage = storageService.CreateTemporaryStorage(cancellationToken); return(SaveTreeAsync(root, this.storage)); }
public TsdbClient( IDynamicStorageSelector <TKey, TEntry> dynamicStorageSelector, IVolumeStorageSelector <TKey, TEntry> volumeStorageSelector, ITemporaryStorage <TKey, TEntry> temporaryStorage, ITsdbLogger logger) : this(dynamicStorageSelector, volumeStorageSelector, null, temporaryStorage, logger) { }
public UploadFileCommandHandler( ITemporaryStorage storage, IEventService eventService, ILogger <UploadFileCommandHandler> logger) { _storage = storage; _eventService = eventService; _logger = logger; }
private static async Task SaveTreeWorkerAsync(SyntaxNode node, ITemporaryStorage storage, CancellationToken cancellationToken) { using (var stream = SerializableBytes.CreateWritableStream()) { node.SerializeTo(stream); stream.Position = 0; await storage.WriteStreamAsync(stream, cancellationToken).ConfigureAwait(false); } }
protected static Task SaveTreeAsync(SyntaxNode root, ITemporaryStorage storage) { using (taskGuard.DisposableWait()) { // force all save tasks to be in sequence latestTask = latestTask.SafeContinueWith(t => SaveTreeWorkerAsync(root, storage, CancellationToken.None), CancellationToken.None, TaskScheduler.Default).Unwrap(); return(latestTask); } }
private static void SaveTreeToMap(SyntaxTree tree, ITemporaryStorage storage) { var saved = map.GetValue(tree, _ => storage); // somebody has beaten us, let storage go. if (saved != storage) { storage.Dispose(); } }
public TsdbClient( IStorageSelector <TKey, TEntry> storageSelector, IPublishSubscribe <TKey, TEntry> remotePublishSubscribe, ITemporaryStorage <TKey, TEntry> temporaryStorage, ITsdbLogger logger) { _storageSelector = storageSelector; _remotePublishSubscribe = remotePublishSubscribe; _temporaryStorage = temporaryStorage; _localPublishSubscribe = new DefaultPublishSubscribe <TKey, TEntry>(false); _logger = logger; }
//init public SignalEventFlushJob(SenderSettings senderSettings, ITemporaryStorage <SignalEvent <TKey> > temporaryStorage , ISignalEventQueries <TKey> queries) : base(senderSettings, temporaryStorage, queries) { FlushPeriod = senderSettings.FlushJobFlushPeriod; QueueLimit = senderSettings.FlushJobQueueLimit; IsTemporaryStorageEnabled = senderSettings.SignalQueueIsTemporaryStorageEnabled; _temporaryStorageParameters = new TemporaryStorageParameters() { QueueType = NotificationsConstants.TS_EVENT_QUEUE_KEY, EntityVersion = NotificationsConstants.TS_ENTITIES_VERSION }; }
public TsdbClient( IDynamicStorageSelector <TKey, TEntry> dynamicStorageSelector, IVolumeStorageSelector <TKey, TEntry> volumeStorageSelector, IPublishSubscribe <TKey, TEntry> remotePublishSubscribe, ITemporaryStorage <TKey, TEntry> temporaryStorage, ITsdbLogger logger) { _dynamicStorageSelector = dynamicStorageSelector; _volumeStorageSelector = volumeStorageSelector; _remotePublishSubscribe = remotePublishSubscribe; _temporaryStorage = temporaryStorage; _localPublishSubscribe = new DefaultPublishSubscribe <TKey, TEntry>(false); _logger = logger; _migrations = new MigrationProvider <TKey, TEntry>(_dynamicStorageSelector, _volumeStorageSelector); }
public ProcessFileCommandHandler( ITemporaryStorage temporaryStorage, IMainStorage mainStorage, IConverter <IFileReader, IAsyncEnumerable <Product> > fileToProductConverter, IConverter <Product, IAsyncEnumerable <string> > productTofileConverter, IRepository <Product, Guid> productRepoitory, ILogger <ProcessFileCommandHandler> logger) { _temporaryStorage = temporaryStorage; _mainStorage = mainStorage; _fileToProductConverter = fileToProductConverter; _productTofileConverter = productTofileConverter; _productRepoitory = productRepoitory; _logger = logger; }
private void InvalidateCaptchas() { if (this.captchaController != null) { if (this.captchaController.Model.GetViewModel(this.captchaController.Model.Value) is CaptchaViewModel captchaViewModel) { var key = HttpContext.Current.Request[captchaViewModel.CaptchaKeyFormKey]; var keys = key.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); ITemporaryStorage tempStorage = ObjectFactory.Resolve <ITemporaryStorage>(); foreach (var item in keys) { tempStorage.Remove(item); } } } }
//init public EventQueue(SenderSettings senderSettings, ITemporaryStorage <SignalEvent <TKey> > temporaryStorage , ISignalFlushJob <SignalEvent <TKey> > signalFlushJob, ILogger logger) : base(temporaryStorage) { _signalFlushJob = signalFlushJob; _logger = logger; PersistBeginOnItemsCount = senderSettings.SignalQueuePersistBeginOnItemsCount; PersistEndOnItemsCount = senderSettings.SignalQueuePersistEndOnItemsCount; IsTemporaryStorageEnabled = senderSettings.SignalQueueIsTemporaryStorageEnabled; _temporaryStorageParameters = new TemporaryStorageParameters() { QueueType = NotificationsConstants.TS_EVENT_QUEUE_KEY, EntityVersion = NotificationsConstants.TS_ENTITIES_VERSION }; }
//init public SignalFlushJobBase(SenderSettings senderSettings, ITemporaryStorage <TSignal> temporaryStorage, ISignalQueries <TSignal> queries) : base(senderSettings) { _temporaryStorage = temporaryStorage; _queries = queries; //how to flush items new List <FlushAction> { FlushAction.Insert, FlushAction.Update, FlushAction.DeleteOne } .ForEach(action => _flushQueues[action] = new FlushQueue <SignalWrapper <TSignal> >(items => MakeQuery(items, action))); //what to do after flushing _flushedItemsHandlers.Add(RemovedFlushedFromTempStorage); }
public void TestTemporaryStorageMemoryMappedFileManagement() { var textFactory = new TextFactoryServiceFactory.TextFactoryService(); var service = new TemporaryStorageServiceFactory.TemporaryStorageService(textFactory); var buffer = new MemoryStream(257 * 1024 + 1); for (int i = 0; i < buffer.Length; i++) { buffer.WriteByte((byte)i); } // Do a relatively cheap concurrent stress test of the backing MemoryMappedFile management var tasks = Enumerable.Range(1, 257).Select(async i => { for (int j = 1; j < 5; j++) { using (ITemporaryStorage storage1 = service.CreateTemporaryStorage(CancellationToken.None), storage2 = service.CreateTemporaryStorage(CancellationToken.None)) { var storage3 = service.CreateTemporaryStorage(CancellationToken.None); // let the finalizer run for this instance storage1.WriteStream(new MemoryStream(buffer.GetBuffer(), 0, 1024 * i - 1)); storage2.WriteStream(new MemoryStream(buffer.GetBuffer(), 0, 1024 * i)); storage3.WriteStream(new MemoryStream(buffer.GetBuffer(), 0, 1024 * i + 1)); await Task.Yield(); using (Stream s1 = storage1.ReadStream(), s2 = storage2.ReadStream(), s3 = storage3.ReadStream()) { Assert.Equal(1024 * i - 1, s1.Length); Assert.Equal(1024 * i, s2.Length); Assert.Equal(1024 * i + 1, s3.Length); } } } }); Task.WaitAll(tasks.ToArray()); GC.Collect(2); GC.WaitForPendingFinalizers(); GC.Collect(2); }
//init public DispatchQueue(SenderSettings senderSettings, ITemporaryStorage <SignalDispatch <TKey> > temporaryStorage , IDispatchChannelRegistry <TKey> dispatcherRegistry, ISignalFlushJob <SignalDispatch <TKey> > signalFlushJob , ILogger logger) : base(temporaryStorage) { _dispatcherRegistry = dispatcherRegistry; _signalFlushJob = signalFlushJob; _logger = logger; RetryPeriod = senderSettings.SignalQueueRetryPeriod; MaxFailedAttempts = senderSettings.DatabaseSignalProviderItemsMaxFailedAttempts; PersistBeginOnItemsCount = senderSettings.SignalQueuePersistBeginOnItemsCount; PersistEndOnItemsCount = senderSettings.SignalQueuePersistEndOnItemsCount; IsTemporaryStorageEnabled = senderSettings.SignalQueueIsTemporaryStorageEnabled; _temporaryStorageParameters = new TemporaryStorageParameters() { QueueType = NotificationsConstants.TS_DISPATCH_QUEUE_KEY, EntityVersion = NotificationsConstants.TS_ENTITIES_VERSION }; }
//init public SignalDispatchFlushJob(SenderSettings senderSettings, ITemporaryStorage <SignalDispatch <TKey> > temporaryStorage, ISignalDispatchQueries <TKey> dispatchQueries, ILockTracker <TKey> dispatchLockTracker, IConsolidationLockTracker <TKey> consolidationLockTracker) : base(senderSettings, temporaryStorage, dispatchQueries) { _dispatchQueries = dispatchQueries; _dispatchLockTracker = dispatchLockTracker; _consolidationLockTracker = consolidationLockTracker; IsTemporaryStorageEnabled = senderSettings.SignalQueueIsTemporaryStorageEnabled; _temporaryStorageParameters = new TemporaryStorageParameters() { QueueType = NotificationsConstants.TS_DISPATCH_QUEUE_KEY, EntityVersion = NotificationsConstants.TS_ENTITIES_VERSION }; //how to flush items _flushQueues[FlushAction.DeleteConsolidated] = new FlushQueue <SignalWrapper <SignalDispatch <TKey> > >(signals => DeleteConsolidatedDispatches(signals)); //what to do after flushing _flushedItemsHandlers.Add(ForgetDispatchLocks); _flushedItemsHandlers.Add(ForgetConsolidationLocks); }
private MetadataOnlyImage(ITemporaryStorage storage, string assemblyName) { this.storage = storage; this.assemblyName = assemblyName; }
public TsdbClient( IStorageSelector <TKey, TEntry> storageSelector, ITemporaryStorage <TKey, TEntry> temporaryStorage) : this(storageSelector, null, temporaryStorage, NullTsdbLogger.Default) { }
public MemoryThenTempStorageStream(ITemporaryStorage storage) { this.m_tempStorage = storage; }