Пример #1
0
 public BufferedDocumentStore(IDocumentStore innerDocumentStore)
 {
     Condition.Requires(innerDocumentStore, "innerDocumentStore").IsNotNull();
     this._innerDocumentStore = innerDocumentStore;
     this._strategy           = innerDocumentStore.Strategy;
     this._documentWriters    = new List <IBufferedDocumentWriter>();
 }
Пример #2
0
        protected override NuclearStorage Compose(IDocumentStrategy strategy)
        {
            var dev = AzureStorage.CreateConfigurationForDev();

            WipeAzureAccount.Fast(s => s.StartsWith("test-views"), dev);
            return(dev.CreateNuclear(strategy));
        }
Пример #3
0
        public AzureAtomicReader(CloudBlobClient storage, IDocumentStrategy strategy)
        {
            _strategy = strategy;
            var folder = strategy.GetEntityBucket <TEntity>();

            _container = storage.GetBlobDirectoryReference(folder);
        }
Пример #4
0
        public AzureAtomicWriter(CloudBlobClient storageClient, IDocumentStrategy strategy)
        {
            this._strategy = strategy;
            var folder = strategy.GetEntityBucket <TEntity>();

            this._containerDirectory = storageClient.GetBlobDirectory(folder);
        }
 public void SetUp()
 {
     _strategy = new DocumentStrategy();
       _log = Console.Out;
       _store = new FileDocumentStore(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Remove(0,6), _strategy, _log);
       _store.Reset(_strategy.GetEntityBucket<TestObject>());
 }
Пример #6
0
        public AzureAtomicWriter(CloudBlobClient directory, IDocumentStrategy strategy)
        {
            _strategy = strategy;
            var folderForEntity = strategy.GetEntityBucket <TEntity>();

            _container = directory.GetBlobDirectoryReference(folderForEntity);
        }
Пример #7
0
        public AzureAtomicReader(CloudBlobClient storageClient, IDocumentStrategy strategy)
        {
            this._strategy = strategy;
            var folder = strategy.GetEntityBucket <TEntity>();

            this._containerDirectory = storageClient.GetBlobDirectory(folder);
            this._logger             = NetcoLogger.GetLogger(this.GetType());
            this._ap = ActionPolicyAsync.From((exception =>
            {
                var storageException = exception as StorageException;
                if (storageException == null)
                {
                    return(false);
                }

                switch (storageException.RequestInformation.HttpStatusCode)
                {
                case ( int )HttpStatusCode.InternalServerError:
                case ( int )HttpStatusCode.ServiceUnavailable:
                    return(true);

                default:
                    return(false);
                }
            })).Retry(200, (ex, i) =>
            {
                this._logger.Log().Trace(ex, "Retrying Azure API GET call: {0}/200", i);
                var secondsDelay = 0.2 + 0.1 * _random.Next(-1, 1);                   // randomize wait time
                Task.Delay(TimeSpan.FromSeconds(secondsDelay)).Wait();
            });
        }
Пример #8
0
        /// <summary> Creates the simplified nuclear storage wrapper around Atomic storage. </summary>
        /// <param name="config">The storage config.</param>
        /// <param name="strategy">The atomic storage strategy.</param>
        /// <returns></returns>
        public static IDocumentStore CreateDocumentStore(this IAzureStorageConfig config,
                                                         IDocumentStrategy strategy)
        {
            var client = config.CreateBlobClient();

            return(new AzureDocumentStore(strategy, client));
        }
 public void SetUp()
 {
   _strategy = new JsonDocumentStrategy();
   _store = new FileDocumentStore(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Remove(0, 6), _strategy);
   _store.Reset(_strategy.GetEntityBucket<TestObject>());
   _store.Reset(_strategy.GetEntityBucket<TestEvent>());
   _store.Reset(_strategy.GetEntityBucket<TestWrapper>());
 }
Пример #10
0
 public BufferedDocumentWriter(IDocumentReader <TKey, TEntity> reader, IDocumentWriter <TKey, TEntity> writer, IDocumentStrategy strategy)
 {
     this._reader        = reader;
     this._writer        = writer;
     this._strategy      = strategy;
     this._viewsCache    = new ConcurrentDictionary <string, TEntity>();
     this._viewsToDelete = new ConcurrentDictionary <string, bool>();
     this._keys          = new ConcurrentDictionary <string, TKey>();
 }
Пример #11
0
        /// <summary> Creates the simplified nuclear storage wrapper around Atomic storage. </summary>
        /// <param name="storageConfig">The storage config.</param>
        /// <param name="strategy">The atomic storage strategy.</param>
        /// <returns></returns>
        public static NuclearStorage CreateNuclear(this IAzureStorageConfig storageConfig,
                                                   IDocumentStrategy strategy)
        {
            var client = storageConfig.CreateBlobClient();

            var factory = new AzureDocumentStore(strategy, client);

            return(new NuclearStorage(factory));
        }
Пример #12
0
        public ProjectionInfo(IEnumerable <ViewInfo> views, object tempProjection, IDocumentStrategy strategy)
        {
            Condition.Requires(views, "views").IsNotNull();
            Condition.Requires(tempProjection, "tempProjection").IsNotNull();
            Condition.Requires(strategy, "strategy").IsNotNull();

            this.ViewBuckets = views.Select(v => v.StoreBucket).ToArray();
            var viewTypes = views.Select(v => v.EntityType);

            var projectionType = tempProjection.GetType();

            this.Hash           = new ProjectionHash(projectionType, viewTypes, strategy.GetType());
            this.ProjectionName = projectionType.Name;

            this._checkpoint     = new ProjectionCheckpoint();
            this._tempProjection = tempProjection;
        }
 public FileDocumentReaderWriter(string directoryPath, IDocumentStrategy strategy, TextWriter log)
 {
     _folder   = Path.Combine(directoryPath, strategy.GetEntityBucket <TEntity>());//.Replace('/', Path.DirectorySeparatorChar);
     _strategy = strategy;
     _log      = log;
 }
Пример #14
0
 /// <summary> Creates the simplified nuclear storage wrapper around Atomic storage. </summary>
 /// <param name="config">The storage config.</param>
 /// <param name="strategy">The atomic storage strategy.</param>
 /// <returns></returns>
 public static IDocumentStore CreateDocumentStore(this IAzureStorageConfig config,
     IDocumentStrategy strategy)
 {
     var client = config.CreateBlobClient();
     return new AzureDocumentStore(strategy, client);
 }
Пример #15
0
 public FileDocumentStore(string folderPath, IDocumentStrategy strategy)
 {
     _folderPath = folderPath;
     _strategy   = strategy;
 }
Пример #16
0
 protected abstract NuclearStorage Compose(IDocumentStrategy strategy);
Пример #17
0
 public AzureDocumentStore(IDocumentStrategy strategy, CloudBlobClient client)
 {
     _strategy = strategy;
     _client   = client;
 }
Пример #18
0
 /// <summary>
 /// Creates the simplified nuclear storage wrapper around Atomic storage.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 /// <param name="strategy">The atomic storage strategy.</param>
 /// <returns></returns>
 public static NuclearStorage CreateNuclear(this MemoryStorageConfig dictionary, IDocumentStrategy strategy)
 {
     var container = new MemoryDocumentStore(dictionary.Data, strategy);
     return new NuclearStorage(container);
 }
Пример #19
0
        private IEnumerable <ProjectionInfo> GeneratedProjectionInfosFromProjectors(CancellationToken token, IDocumentStore memoryContainer, IDocumentStrategy strategy)
        {
            var trackingStore = new ProjectionInspectingStore(memoryContainer);

            var generatedProjectionInfos = new List <ProjectionInfo>();

            foreach (var projection in this._projectors(trackingStore))
            {
                var views          = trackingStore.GetNewViewsAndReset();
                var projectionInfo = new ProjectionInfo(views, projection, strategy);
                if (generatedProjectionInfos.Any(p => p.ProjectionName == projectionInfo.ProjectionName))
                {
                    throw new InvalidOperationException("Duplicate projection encountered: " + projectionInfo.ProjectionName);
                }

                generatedProjectionInfos.Add(projectionInfo);
            }
            trackingStore.ValidateSanity();
            token.ThrowIfCancellationRequested();

            if (trackingStore.Views.Count != generatedProjectionInfos.Count)
            {
                throw new InvalidOperationException("Projections count mismatch");
            }
            return(generatedProjectionInfos);
        }
Пример #20
0
        /// <summary> Creates the simplified nuclear storage wrapper around Atomic storage. </summary>
        /// <param name="storageConfig">The storage config.</param>
        /// <param name="strategy">The atomic storage strategy.</param>
        /// <returns></returns>
        public static NuclearStorage CreateNuclear(this IAzureStorageConfig storageConfig,
            IDocumentStrategy strategy)
        {
            var client = storageConfig.CreateBlobClient();

            var factory = new AzureDocumentStore(strategy, client);
            return new NuclearStorage(factory);
        }
Пример #21
0
 public static IDocumentStore CreateDocumentStore(this FileStorageConfig config, IDocumentStrategy strategy)
 {
     return new FileDocumentStore(config.FullPath, strategy);
 }
 public FileDocumentReaderWriter(string directoryPath, IDocumentStrategy strategy)
 {
     _strategy = strategy;
     _folder   = Path.Combine(directoryPath, strategy.GetEntityBucket <TEntity>());
 }
Пример #23
0
 public CachingDocumentReader(IDocumentReader <TKey, TEntity> reader, IDocumentStrategy strategy)
 {
     this._reader   = reader;
     this._strategy = strategy;
     this._cache    = new ConcurrentDictionary <string, Task <Maybe <TEntity> > >();
 }
Пример #24
0
 protected override NuclearStorage Compose(IDocumentStrategy strategy)
 {
     return(new MemoryStorageConfig().CreateNuclear(strategy));
 }
Пример #25
0
 public void SetUp()
 {
     _strategy = new DocumentStrategy();
     _store    = new MemoryDocumentStore(_strategy, new MemoryStorageConfig().Data);
 }
Пример #26
0
 public static NuclearStorage CreateNuclear(this FileStorageConfig config, IDocumentStrategy strategy)
 {
     var factory = new FileDocumentStore(config.FullPath, strategy);
     return new NuclearStorage(factory);
 }
Пример #27
0
 protected abstract NuclearStorage Compose(IDocumentStrategy strategy);
 public FileDocumentStore(string folderPath, IDocumentStrategy strategy, TextWriter log)
 {
     _folderPath = folderPath;
     _strategy   = strategy;
     _log        = log;
 }
 public NonserializingMemoryDocumentStore(ConcurrentDictionary <string, ConcurrentDictionary <string, object> > store, IDocumentStrategy strategy)
 {
     this._store    = store;
     this._strategy = strategy;
 }
Пример #30
0
        public static NuclearStorage CreateNuclear(this FileStorageConfig config, IDocumentStrategy strategy)
        {
            var factory = new FileDocumentStore(config.FullPath, strategy);

            return(new NuclearStorage(factory));
        }
Пример #31
0
 public void Setup()
 {
     m_strategy = new FileJsonDocumentStrategy();
     m_store = new FileDocumentStore(FOLDER_PATH, m_strategy);
     m_account = new AccountView
     {
         AccountID = Guid.NewGuid(),
         Name = "Test Account"
     };
     m_accountID = new AccountID(m_account.AccountID);
     m_store.ResetAll();
 }
 protected override NuclearStorage Compose(IDocumentStrategy strategy)
 {
     return(_config.CreateNuclear(strategy));
 }
Пример #33
0
        /// <summary>
        /// Creates the simplified nuclear storage wrapper around Atomic storage.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="strategy">The atomic storage strategy.</param>
        /// <returns></returns>
        public static NuclearStorage CreateNuclear(this MemoryStorageConfig dictionary, IDocumentStrategy strategy)
        {
            var container = new MemoryDocumentStore(dictionary.Data, strategy);

            return(new NuclearStorage(container));
        }
 protected override NuclearStorage Compose(IDocumentStrategy strategy)
 {
     return new MemoryStorageConfig().CreateNuclear(strategy);
 }
 public NonserializingMemoryDocumentReaderWriter(IDocumentStrategy strategy, ConcurrentDictionary <string, object> store)
 {
     this._store    = store;
     this._strategy = strategy;
 }
Пример #36
0
 public MemoryDocumentStore(ConcurrentDictionary <string, ConcurrentDictionary <string, byte[]> > store, IDocumentStrategy strategy)
 {
     _store    = store;
     _strategy = strategy;
 }
 public void SetUp()
 {
   _strategy = new DocumentStrategy();
   _store = new MemoryDocumentStore(_strategy, new MemoryStorageConfig().Data);
 }
Пример #38
0
 public MemoryDocumentReaderWriter(IDocumentStrategy strategy, ConcurrentDictionary <string, byte[]> store)
 {
     _strategy = strategy;
     _store    = store;
 }
Пример #39
0
 public static IDocumentStore CreateDocumentStore(this FileStorageConfig config, IDocumentStrategy strategy)
 {
     return(new FileDocumentStore(config.FullPath, strategy));
 }
 protected override NuclearStorage Compose(IDocumentStrategy strategy)
 {
     return _config.CreateNuclear(strategy);
 }
 protected override NuclearStorage Compose(IDocumentStrategy strategy)
 {
     var dev = AzureStorage.CreateConfigurationForDev();
     WipeAzureAccount.Fast(s => s.StartsWith("test-views"), dev);
     return dev.CreateNuclear(strategy);
 }