public DocumentStoreTenantSettings(
            string tenantId,
            DocumentStoreConfiguration config)
            : base(new TenantId(tenantId))
        {
            _config = config;
            SetConnectionString("events");
            SetConnectionString("originals");
            SetConnectionString("artifacts");
            SetConnectionString("system");
            SetConnectionString("readmodel");

            Set("system.db", GetDatabase("system"));
            Set("readmodel.db", GetDatabase("readmodel"));

            Set("originals.db", GetDatabase("originals"));
            Set("artifacts.db", GetDatabase("artifacts"));

            switch (_config.StorageType)
            {
            case StorageType.GridFs:
                Set("originals.db.legacy", GetLegacyDatabase("originals"));
                Set("artifacts.db.legacy", GetLegacyDatabase("artifacts"));
                break;

            case StorageType.FileSystem:
                //we can simply use the connectionstring
                SetFileSystemBaseDirectory("originals");
                SetFileSystemBaseDirectory("artifacts");
                SetConnectionString("descriptors");
                Set("fsdescriptor.db", GetDatabase("descriptors"));
                break;
            }
        }
        public void CanExportZip()
        {
            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                           .Build();

            var documentStoreConfig         = new DocumentStoreConfiguration();
            var agencyPaymentsConfiguration = new AgencyPaymentsConfiguration();

            configuration
            .GetSection("documentStore")
            .Bind(documentStoreConfig);
            configuration
            .GetSection("agencyPayments")
            .Bind(agencyPaymentsConfiguration);

            IDocumentStore documentStore = new DocumentStore
            {
                Urls     = new[] { documentStoreConfig.Url },
                Database = documentStoreConfig.Database
            };

            new BacsExportService(documentStore, agencyPaymentsConfiguration).ExportZip(BacsExportType.Agency).Wait();
            new BacsExportService(documentStore, agencyPaymentsConfiguration).ExportZip(BacsExportType.Supplier).Wait();
        }
示例#3
0
        public BacsExportService()
        {
            IConfiguration Configuration = new ConfigurationBuilder()
                                           .AddJsonFile(APP_SETTINGS_PATH)
                                           .Build();

            var documentStoreConfig = new DocumentStoreConfiguration();

            agencyPaymentsConfiguration = new AgencyPaymentsConfiguration();
            Configuration
            .GetSection(DOCUMENT_STORE_KEY)
            .Bind(documentStoreConfig);
            Configuration
            .GetSection(AGENCY_PAYMENTS_KEY)
            .Bind(agencyPaymentsConfiguration);

            documentStore = new DocumentStore
            {
                Urls     = new[] { documentStoreConfig.Url },
                Database = documentStoreConfig.Database
            };

            documentStore.Initialize();

            agencyPaymentService   = new AgencyPaymentService(documentStore);
            supplierPaymentService = new SupplierPaymentService();
        }
        private static void ConfigureRebuild(DocumentStoreConfiguration config)
        {
            if (!Environment.UserInteractive)
            {
                return;
            }

            if (!_documentStoreConfiguration.IsReadmodelBuilder)
            {
                return;
            }

            Banner();

            RebuildSettings.Init(config.Rebuild, config.NitroMode);

            if (RebuildSettings.ShouldRebuild)
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("---> Rebuild the readmodel (y/N)?");

                var res = Console.ReadLine().Trim().ToLowerInvariant();
                if (res != "y")
                {
                    RebuildSettings.DisableRebuild();
                }
            }
        }
示例#5
0
 public DeduplicationHelper(
     DocumentStoreConfiguration config,
     DocumentDescriptorByHashReader hashReader,
     IBlobStore blobStore)
 {
     _config     = config;
     _hashReader = hashReader;
     _blobStore  = blobStore;
 }
示例#6
0
 public PollerManager(
     IPollerJobManager[] pollerJobManagers,
     DocumentStoreConfiguration configuration)
 {
     _pollerJobManagers = pollerJobManagers.ToDictionary(p => p.GetType().Name, p => p);
     _configuration     = configuration;
     queueClients       = new List <ClientInfo>();
     Logger             = NullLogger.Instance;
 }
示例#7
0
 public FileStoreMultipartStreamProvider(
     IBlobStore store,
     DocumentStoreConfiguration config
     )
     : base(Path.GetTempPath())
 {
     _store  = store;
     _config = config;
 }
示例#8
0
        public OutOfProcessBaseJobManager(DocumentStoreConfiguration configuration)
        {
            _configuration    = configuration;
            _jobInfoList      = new ConcurrentDictionary <string, PollingJobInfo>();
            _startedProcesses = new ConcurrentDictionary <string, ProcessInfo>();
            Logger            = NullLogger.Instance;
            //check each 10 minutes if some process is dead and was not started.
            // _monitorTimer = new Timer(CheckProcesses, null, 30 * 1000, 10 * 60 * 1000);

            _monitorTimer = new Timer(CheckProcesses, null, 10 * 1000, 10 * 60 * 1000);
        }
 public ImportFormatFromFileQueue(
     DocumentStoreConfiguration configuration,
     ITenantAccessor tenantAccessor,
     ICommandBus commandBus
     )
 {
     DeleteTaskFileAfterImport = true;
     _configuration            = configuration;
     _foldersToWatch           = _configuration.FoldersToMonitor;
     _tenantAccessor           = tenantAccessor;
     _commandBus = commandBus;
 }
示例#10
0
 public QueueManager(
     IMongoDatabase mongoDatabase,
     ITenantAccessor tenantAccessor,
     QueueHandler[] queueHandlers,
     DocumentStoreConfiguration configuration)
 {
     _tenantAccessor = tenantAccessor;
     _configuration  = configuration;
     _queueHandlers  = queueHandlers
                       .ToDictionary(qh => qh.Name, qh => qh);
     _checkpointCollection = mongoDatabase.GetCollection <StreamCheckpoint>("stream.checkpoints");
     Logger = NullLogger.Instance;
 }
 /// <summary>
 /// Standard Constructor
 /// </summary>
 /// <param name="db">The database where I want to store information</param>
 /// <param name="collectionName">The name of the collection that will be used
 /// to store information of the file</param>
 /// <param name="baseDirectory">Base directory on filesystem where binary blob
 /// will be stored</param>
 /// <param name="counterService">Counter service to generate new <see cref="BlobId"/></param>
 /// <param name="documentStoreConfiguration">Global configuration to grab storage user name and password
 /// </param>
 public FileSystemBlobStore(
     IMongoDatabase db,
     String collectionName,
     String baseDirectory,
     ICounterService counterService,
     DocumentStoreConfiguration documentStoreConfiguration) : this(
         db,
         collectionName,
         baseDirectory,
         counterService,
         documentStoreConfiguration.StorageUserName,
         documentStoreConfiguration.StoragePassword)
 {
 }
        public QueuedJobQuartzMonitor(
            IPollerJobManager pollerJobManager,
            QueueHandler[] queueHandlers,
            DocumentStoreConfiguration config)
        {
            _pollerJobManager = pollerJobManager;
            _queueHandlers    = queueHandlers;
            _config           = config;

            new List <String>()
            {
                //@@TODO: Multiple bindings?
                config.GetServerAddressForJobs()
            };
            Logger = NullLogger.Instance;
        }
示例#13
0
        private void BuildContainer(DocumentStoreConfiguration config)
        {
            _container = new WindsorContainer();
            ContainerAccessor.Instance = _container;
            _container.Register(Component.For <DocumentStoreConfiguration>().Instance(config));
            _container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel, true));
            _container.Kernel.Resolver.AddSubResolver(new ArrayResolver(_container.Kernel, true));

            _container.AddFacility <LoggingFacility>(config.CreateLoggingFacility);

#if DEBUG
            UdpAppender.AppendToConfiguration();
#endif

            _container.AddFacility <StartableFacility>();
            _container.AddFacility <JarvisTypedFactoryFacility>();

            _logger = _container.Resolve <ILoggerFactory>().Create(GetType());
        }
示例#14
0
        private TenantManager BuildTenants(IWindsorContainer container, DocumentStoreConfiguration config)
        {
            _logger.Debug("Configuring tenants");
            var manager = new TenantManager(container.Kernel);

            container.Register(Component.For <ITenantAccessor, TenantManager>().Instance(manager));

            foreach (var settings in config.TenantSettings)
            {
                _logger.DebugFormat("Adding tenant {0}", settings.TenantId);

                var tenant = manager.AddTenant(settings);
                tenant.Container.Kernel.Resolver.AddSubResolver(new CollectionResolver(tenant.Container.Kernel, true));
                tenant.Container.Kernel.Resolver.AddSubResolver(new ArrayResolver(tenant.Container.Kernel, true));
                tenant.Container.AddFacility <StartableFacility>();
                tenant.Container.AddFacility <JarvisTypedFactoryFacility>();
                container.AddChildContainer(tenant.Container);
            }

            return(manager);
        }
 public DocumentsController(
     IBlobStore blobStore,
     DocumentStoreConfiguration configService,
     IIdentityGenerator identityGenerator,
     IMongoDbReader <DocumentDescriptorReadModel, DocumentDescriptorId> documentDescriptorReader,
     IMongoDbReader <DocumentDeletedReadModel, String> documentDeletedReader,
     IInProcessCommandBus commandBus,
     IDocumentWriter handleWriter,
     IQueueManager queueDispatcher,
     ICounterService counterService,
     IDocumentFormatTranslator documentFormatTranslator)
 {
     _blobStore                = blobStore;
     _configService            = configService;
     _identityGenerator        = identityGenerator;
     _documentDescriptorReader = documentDescriptorReader;
     _documentDeletedReader    = documentDeletedReader;
     _handleWriter             = handleWriter;
     _queueDispatcher          = queueDispatcher;
     _counterService           = counterService;
     _documentFormatTranslator = documentFormatTranslator;
     CommandBus                = commandBus;
 }
示例#16
0
 public static void SetConfig(DocumentStoreConfiguration config)
 {
     _config = config;
 }
示例#17
0
 internal DocumentStore(DocumentStoreConfiguration configuration)
 {
     NHSessionFactory = configuration.NHConfiguration.BuildSessionFactory();
     _entityToCollectionMap = configuration.EntityToCollectionMap;
 }
示例#18
0
 public EventStoreInstaller(TenantManager manager, DocumentStoreConfiguration config)
 {
     _manager = manager;
     _config  = config;
 }
示例#19
0
        private void InitializeEverything(DocumentStoreConfiguration config)
        {
            var installers = new List <IWindsorInstaller>()
            {
                new CoreInstaller(config),
                new EventStoreInstaller(Manager, config),
                new SchedulerInstaller(false),
                new BackgroundTasksInstaller(config),
                new QueueInfrasctructureInstaller(config.QueueConnectionString, config.QueueInfoList),
            };

            _logger.Debug("Configured Scheduler");

            DocumentStoreApplication.SetConfig(config);
            if (config.IsApiServer)
            {
                installers.Add(new ApiInstaller());
            }

            var options = new StartOptions();

            foreach (var uri in config.ServerAddresses)
            {
                _logger.InfoFormat("Binding to @ {0}", uri);
                options.Urls.Add(uri);
            }

            _container.Install(installers.ToArray());
            foreach (var tenant in Manager.Tenants)
            {
                var tenantInstallers = new List <IWindsorInstaller>
                {
                    new TenantCoreInstaller(tenant, config),
                    new TenantHandlersInstaller(tenant),
                    new TenantJobsInstaller(tenant)
                };

                if (config.IsApiServer)
                {
                    tenantInstallers.Add(new TenantApiInstaller());
                }

                tenantInstallers.Add(new TenantProjectionsInstaller <NotifyReadModelChanges>(tenant, config));
                _logger.DebugFormat("Configured Projections for tenant {0}", tenant.Id);

                tenant.Container.Install(tenantInstallers.ToArray());
                tenant.Container.CheckConfiguration();
            }

            try
            {
                _webApplication = WebApp.Start <DocumentStoreApplication>(options);
            }
            catch (Exception ex)
            {
                throw new Exception($"Cannot listen on url {options.Urls.Single()} {ex.Message}", ex);
            }

            _logger.InfoFormat("Server started");

            foreach (var act in _container.ResolveAll <IStartupActivity>())
            {
                _logger.DebugFormat("Starting activity: {0}", act.GetType().FullName);
                try
                {
                    act.Start();
                }
                catch (Exception ex)
                {
                    _logger.ErrorFormat(ex, "Shutting down {0}", act.GetType().FullName);
                }
            }
        }
示例#20
0
        public void Start(DocumentStoreConfiguration config)
        {
            _config = config;
            BuildContainer(config);

            if (_config.EnableSingleAggregateRepositoryCache)
            {
                _logger.InfoFormat("Single Aggregate Repository Cache - ENABLED");
                JarvisFrameworkGlobalConfiguration.EnableSingleAggregateRepositoryCache();
            }
            else
            {
                _logger.InfoFormat("Single Aggregate Repository Cache - DISABLED");
                JarvisFrameworkGlobalConfiguration.DisableSingleAggregateRepositoryCache();
            }
            if (_config.DisableRepositoryLockOnAggregateId)
            {
                _logger.InfoFormat("Repository lock on Aggregate Id - DISABLED");
                NeventStoreExGlobalConfiguration.DisableRepositoryLockOnAggregateId();
            }
            else
            {
                _logger.InfoFormat("Repository lock on Aggregate Id - ENABLED");
                NeventStoreExGlobalConfiguration.EnableRepositoryLockOnAggregateId();
            }

            Manager = BuildTenants(_container, config);
            //Setup database check.
            foreach (var tenant in _config.TenantSettings)
            {
                foreach (var connection in _databaseNames)
                {
#pragma warning disable S1848 // Objects should not be created to be dropped immediately without being used
                    new DatabaseHealthCheck(
                        String.Format("Tenant: {0} [Db:{1}]", tenant.TenantId, connection),
                        tenant.GetConnectionString(connection));
#pragma warning restore S1848 // Objects should not be created to be dropped immediately without being used
                }
            }

            while (!StartupCheck())
            {
                _logger.InfoFormat("Some precondition to start the service are not met. Will retry in 3 seconds!");
                Thread.Sleep(3000);
            }

            if (RebuildSettings.ShouldRebuild && Environment.UserInteractive)
            {
                Console.WriteLine("---> Set Log Level to INFO to speedup rebuild (y/N)?");
                var res = Console.ReadLine().Trim().ToLowerInvariant();
                if (res == "y")
                {
                    SetLogLevelTo("INFO");
                }
            }

            _logger.DebugFormat(
                "Roles:\n  api: {0}\n  worker : {1}\n  projections: {2}",
                config.IsApiServer,
                config.IsWorker,
                config.IsReadmodelBuilder
                );

            InitializeEverything(config);

            //Check if container misconfigured
            _container.CheckConfiguration();
        }
 public BackgroundTasksInstaller(DocumentStoreConfiguration config)
 {
     _config = config;
 }
示例#22
0
 private static void LoadConfiguration()
 {
     _documentStoreConfiguration = new RemoteDocumentStoreConfiguration();
 }