public TenantProjectionsInstaller(
     ITenant tenant,
     DocumentStoreConfiguration config)
 {
     _tenant = tenant;
     _config = config;
 }
 public DeduplicationHelper(
     DocumentStoreConfiguration config, 
     DocumentDescriptorByHashReader hashReader, 
     IBlobStore blobStore)
 {
     _config = config;
     _hashReader = hashReader;
     _blobStore = blobStore;
 }
 public PollerManager(
     IPollerJobManager[] pollerJobManagers,
     DocumentStoreConfiguration configuration)
 {
     _pollerJobManagers = pollerJobManagers.ToDictionary(p => p.GetType().Name, p => p);
     _configuration = configuration;
     queueClients = new List<ClientInfo>();
     Logger = NullLogger.Instance;
 }
 public FileStoreMultipartStreamProvider(
     IBlobStore store,
     DocumentStoreConfiguration config
 )
     : base(Path.GetTempPath())
 {
     _store = store;
     _config = config;
 }
        public ImportFormatFromFileQueue(
            DocumentStoreConfiguration configuration,
            ITenantAccessor tenantAccessor,
            ICommandBus commandBus
        )
        {
            DeleteTaskFileAfterImport = true;
            _configuration = configuration;
            _foldersToWatch = _configuration.FoldersToMonitor;
            _tenantAccessor = tenantAccessor;
            _commandBus = commandBus;

        }
 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;
 }
 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;
 }
        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>();

                container.AddChildContainer(tenant.Container);
            }

            return manager;
        }
        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<TypedFactoryFacility>();

            _logger = _container.Resolve<ILoggerFactory>().Create(GetType());

        }
        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");

            if (config.HasMetersEnabled)
            {
                //@@TODO: https://github.com/etishor/Metrics.NET/wiki/ElasticSearch
                var binding = config.MetersOptions["http-endpoint"];
                _logger.DebugFormat("Meters available on {0}", binding);

                Metric
                    .Config
                    .WithHttpEndpoint(binding)
                    .WithAllCounters();
            }

            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),
                    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();

            }

            _webApplication = WebApp.Start<DocumentStoreApplication>(options);
            _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);
                }
            }
            _initialized = true;
        }
 public QueueManagerShutdownActivity(QueueManager queueManager, DocumentStoreConfiguration config, PollerManager pollerManager)
 {
     _queueManager  = queueManager;
     _config        = config;
     _pollerManager = pollerManager;
 }
 public SchedulerStartup(IScheduler scheduler, DocumentStoreConfiguration config)
 {
     _scheduler = scheduler;
     _config = config;
 }
 public CoreInstaller(DocumentStoreConfiguration config)
 {
     _config = config;
 }
Ejemplo n.º 14
0
        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();
                }
            }
        }
        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)
                {
                    DatabaseHealthCheck check = new DatabaseHealthCheck(
                          String.Format("Tenant: {0} [Db:{1}]", tenant.TenantId, connection),
                          tenant.GetConnectionString(connection));
                }
            }

            while (StartupCheck() == false)
            {
                _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();          
        }
Ejemplo n.º 16
0
 public SchedulerStartup(IScheduler scheduler, DocumentStoreConfiguration config)
 {
     _scheduler = scheduler;
     _config    = config;
 }
 public static void SetConfig(DocumentStoreConfiguration config)
 {
     _config = config;
 }
 public QueueManagerShutdownActivity(QueueManager queueManager, DocumentStoreConfiguration config, PollerManager pollerManager)
 {
     _queueManager = queueManager;
     _config = config;
     _pollerManager = pollerManager;
 }
 public TenantCoreInstaller(ITenant tenant, DocumentStoreConfiguration config)
 {
     _tenant         = tenant;
     _config         = config;
     _tenantSettings = config.TenantSettings.Single(t => t.TenantId == tenant.Id);
 }
Ejemplo n.º 20
0
 static void LoadConfiguration()
 {
     _documentStoreConfiguration = new RemoteDocumentStoreConfiguration();
 }
 public BackgroundTasksInstaller(DocumentStoreConfiguration config)
 {
     _config = config;
 }
Ejemplo n.º 22
0
 public CoreInstaller(DocumentStoreConfiguration config)
 {
     _config = config;
 }
 public EventStoreInstaller(TenantManager manager, DocumentStoreConfiguration config)
 {
     _manager = manager;
     _config = config;
 }