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

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

            _container = storage.GetBlobDirectoryReference(folder);
        }
Beispiel #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>());
 }
Beispiel #6
0
        public AzureAtomicWriter(CloudBlobClient directory, IDocumentStrategy strategy)
        {
            _strategy = strategy;
            var folderForEntity = strategy.GetEntityBucket <TEntity>();

            _container = directory.GetBlobDirectoryReference(folderForEntity);
        }
Beispiel #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();
            });
        }
Beispiel #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>());
 }
Beispiel #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>();
 }
Beispiel #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));
        }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #15
0
 public FileDocumentStore(string folderPath, IDocumentStrategy strategy)
 {
     _folderPath = folderPath;
     _strategy   = strategy;
 }
Beispiel #16
0
 protected abstract NuclearStorage Compose(IDocumentStrategy strategy);
Beispiel #17
0
 public AzureDocumentStore(IDocumentStrategy strategy, CloudBlobClient client)
 {
     _strategy = strategy;
     _client   = client;
 }
Beispiel #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);
 }
Beispiel #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);
        }
        /// <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);
        }
Beispiel #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>());
 }
 public CachingDocumentReader(IDocumentReader <TKey, TEntity> reader, IDocumentStrategy strategy)
 {
     this._reader   = reader;
     this._strategy = strategy;
     this._cache    = new ConcurrentDictionary <string, Task <Maybe <TEntity> > >();
 }
Beispiel #24
0
 protected override NuclearStorage Compose(IDocumentStrategy strategy)
 {
     return(new MemoryStorageConfig().CreateNuclear(strategy));
 }
Beispiel #25
0
 public void SetUp()
 {
     _strategy = new DocumentStrategy();
     _store    = new MemoryDocumentStore(_strategy, new MemoryStorageConfig().Data);
 }
Beispiel #26
0
 public static NuclearStorage CreateNuclear(this FileStorageConfig config, IDocumentStrategy strategy)
 {
     var factory = new FileDocumentStore(config.FullPath, strategy);
     return new NuclearStorage(factory);
 }
 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;
 }
Beispiel #30
0
        public static NuclearStorage CreateNuclear(this FileStorageConfig config, IDocumentStrategy strategy)
        {
            var factory = new FileDocumentStore(config.FullPath, strategy);

            return(new NuclearStorage(factory));
        }
Beispiel #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));
 }
Beispiel #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;
 }
 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);
 }
Beispiel #38
0
 public MemoryDocumentReaderWriter(IDocumentStrategy strategy, ConcurrentDictionary <string, byte[]> store)
 {
     _strategy = strategy;
     _store    = store;
 }
Beispiel #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);
 }