public RebuildOnStartupTask(IMainDom mainDom, IndexRebuilder indexRebuilder, ILogger logger, bool onlyEmptyIndexes, int waitMilliseconds = 0) { _mainDom = mainDom; _indexRebuilder = indexRebuilder ?? throw new ArgumentNullException(nameof(indexRebuilder)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _onlyEmptyIndexes = onlyEmptyIndexes; _waitMilliseconds = waitMilliseconds; }
/// <summary> /// Initializes a new instance of the <see cref="TempFileCleanup"/> class. /// </summary> /// <param name="ioHelper">Helper service for IO operations.</param> /// <param name="mainDom">Representation of the main application domain.</param> /// <param name="logger">The typed logger.</param> public TempFileCleanup(IIOHelper ioHelper, IMainDom mainDom, ILogger <TempFileCleanup> logger) : base(TimeSpan.FromMinutes(60), DefaultDelay) { _ioHelper = ioHelper; _mainDom = mainDom; _logger = logger; _tempFolders = _ioHelper.GetTempFolders(); }
/// <summary> /// Called on startup to configure each index. /// </summary> /// <remarks> /// Configures and unlocks all Lucene based indexes registered with the <see cref="IExamineManager"/>. /// </remarks> internal static void ConfigureIndexes(this IExamineManager examineManager, IMainDom mainDom, ILogger logger) { LazyInitializer.EnsureInitialized( ref _configuredInit, ref _isConfigured, ref _isConfiguredLocker, () => { examineManager.ConfigureLuceneIndexes(logger, !mainDom.IsMainDom); return(null); }); }
/// <summary> /// Initializes a new instance of the <see cref="AutoModelsNotificationHandler"/> class. /// </summary> public AutoModelsNotificationHandler( ILogger <AutoModelsNotificationHandler> logger, IOptions <ModelsBuilderSettings> config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors, IMainDom mainDom) { _logger = logger; _config = config.Value ?? throw new ArgumentNullException(nameof(config)); _modelGenerator = modelGenerator; _mbErrors = mbErrors; _mainDom = mainDom; }
/// <summary> /// Initializes a new instance of the <see cref="AutoModelsNotificationHandler"/> class. /// </summary> public AutoModelsNotificationHandler( ILogger <AutoModelsNotificationHandler> logger, IOptionsMonitor <ModelsBuilderSettings> config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors, IMainDom mainDom) { _logger = logger; //We cant use IOptionsSnapshot here, cause this is used in the Core runtime, and that cannot use a scoped service as it has no scope _config = config.CurrentValue ?? throw new ArgumentNullException(nameof(config)); _modelGenerator = modelGenerator; _mbErrors = mbErrors; _mainDom = mainDom; }
private bool AcquireMainDom(IMainDom mainDom) { using (var timer = ProfilingLogger.DebugDuration <CoreRuntime>("Acquiring MainDom.", "Acquired.")) { try { return(mainDom.IsMainDom); } catch { timer?.Fail(); throw; } } }
public ExaminePdfComponent( IExamineManager examineManager, PdfIndexCreator pdfIndexCreator, PdfIndexPopulator pdfIndexPopulator, IMediaService mediaService, IMainDom mainDom, //TODO: Remove for 8.1.2 ILogger logger) { _examineManager = examineManager; _pdfIndexCreator = pdfIndexCreator; _pdfIndexPopulator = pdfIndexPopulator; _mediaService = mediaService; _mainDom = mainDom; _logger = logger; }
public TestBackgroundIndexRebuilder( IMainDom mainDom, IRuntimeState runtimeState, ILogger <ExamineIndexRebuilder> logger, IExamineManager examineManager, IEnumerable <IIndexPopulator> populators, IBackgroundTaskQueue backgroundTaskQueue) : base( mainDom, runtimeState, logger, examineManager, populators, backgroundTaskQueue) { }
/// <summary> /// Initializes a new instance of the <see cref="ContentVersionCleanup"/> class. /// </summary> public ContentVersionCleanup( IRuntimeState runtimeState, ILogger <ContentVersionCleanup> logger, IOptionsMonitor <ContentSettings> settingsMonitor, IContentVersionService service, IMainDom mainDom, IServerRoleAccessor serverRoleAccessor) : base(logger, TimeSpan.FromHours(1), TimeSpan.FromMinutes(3)) { _runtimeState = runtimeState; _logger = logger; _settingsMonitor = settingsMonitor; _service = service; _mainDom = mainDom; _serverRoleAccessor = serverRoleAccessor; }
/// <summary> /// Registers essential services. /// </summary> public static void RegisterEssentials(this Composition composition, ILogger logger, IProfiler profiler, IProfilingLogger profilingLogger, IMainDom mainDom, AppCaches appCaches, IUmbracoDatabaseFactory databaseFactory, TypeLoader typeLoader, IRuntimeState state) { composition.RegisterUnique(logger); composition.RegisterUnique(profiler); composition.RegisterUnique(profilingLogger); composition.RegisterUnique(mainDom); composition.RegisterUnique(appCaches); composition.RegisterUnique(databaseFactory); composition.RegisterUnique(factory => factory.GetInstance <IUmbracoDatabaseFactory>().SqlContext); composition.RegisterUnique(typeLoader); composition.RegisterUnique(state); }
/// <summary> /// Initializes a new instance of the <see cref="KeepAlive"/> class. /// </summary> /// <param name="hostingEnvironment">The current hosting environment</param> /// <param name="mainDom">Representation of the main application domain.</param> /// <param name="keepAliveSettings">The configuration for keep alive settings.</param> /// <param name="logger">The typed logger.</param> /// <param name="profilingLogger">The profiling logger.</param> /// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param> /// <param name="httpClientFactory">Factory for <see cref="HttpClient" /> instances.</param> public KeepAlive( IHostingEnvironment hostingEnvironment, IMainDom mainDom, IOptions <KeepAliveSettings> keepAliveSettings, ILogger <KeepAlive> logger, IProfilingLogger profilingLogger, IServerRoleAccessor serverRegistrar, IHttpClientFactory httpClientFactory) : base(TimeSpan.FromMinutes(5), DefaultDelay) { _hostingEnvironment = hostingEnvironment; _mainDom = mainDom; _keepAliveSettings = keepAliveSettings.Value; _logger = logger; _profilingLogger = profilingLogger; _serverRegistrar = serverRegistrar; _httpClientFactory = httpClientFactory; }
/// <summary> /// Initializes a new instance of the <see cref="LogScrubber"/> class. /// </summary> /// <param name="mainDom">Representation of the main application domain.</param> /// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param> /// <param name="auditService">Service for handling audit operations.</param> /// <param name="settings">The configuration for logging settings.</param> /// <param name="scopeProvider">Provides scopes for database operations.</param> /// <param name="logger">The typed logger.</param> /// <param name="profilingLogger">The profiling logger.</param> public LogScrubber( IMainDom mainDom, IServerRoleAccessor serverRegistrar, IAuditService auditService, IOptions <LoggingSettings> settings, IScopeProvider scopeProvider, ILogger <LogScrubber> logger, IProfilingLogger profilingLogger) : base(logger, TimeSpan.FromHours(4), DefaultDelay) { _mainDom = mainDom; _serverRegistrar = serverRegistrar; _auditService = auditService; _settings = settings.Value; _scopeProvider = scopeProvider; _logger = logger; _profilingLogger = profilingLogger; }
/// <summary> /// Initializes a new instance of the <see cref="ScheduledPublishing"/> class. /// </summary> /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param> /// <param name="mainDom">Representation of the main application domain.</param> /// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param> /// <param name="contentService">Service for handling content operations.</param> /// <param name="umbracoContextFactory">Service for creating and managing Umbraco context.</param> /// <param name="logger">The typed logger.</param> /// <param name="serverMessenger">Service broadcasting cache notifications to registered servers.</param> /// <param name="backofficeSecurityFactory">Creates and manages <see cref="IBackOfficeSecurity"/> instances.</param> public ScheduledPublishing( IRuntimeState runtimeState, IMainDom mainDom, IServerRoleAccessor serverRegistrar, IContentService contentService, IUmbracoContextFactory umbracoContextFactory, ILogger <ScheduledPublishing> logger, IServerMessenger serverMessenger) : base(TimeSpan.FromMinutes(1), DefaultDelay) { _runtimeState = runtimeState; _mainDom = mainDom; _serverRegistrar = serverRegistrar; _contentService = contentService; _umbracoContextFactory = umbracoContextFactory; _logger = logger; _serverMessenger = serverMessenger; }
/// <summary> /// Initializes a new instance of the <see cref="BatchedDatabaseServerMessenger"/> class. /// </summary> public BatchedDatabaseServerMessenger( IMainDom mainDom, CacheRefresherCollection cacheRefreshers, IServerRoleAccessor serverRoleAccessor, ILogger <BatchedDatabaseServerMessenger> logger, ISyncBootStateAccessor syncBootStateAccessor, IHostingEnvironment hostingEnvironment, ICacheInstructionService cacheInstructionService, IJsonSerializer jsonSerializer, IRequestCache requestCache, IRequestAccessor requestAccessor, LastSyncedFileManager lastSyncedFileManager, IOptions <GlobalSettings> globalSettings) : base(mainDom, cacheRefreshers, serverRoleAccessor, logger, true, syncBootStateAccessor, hostingEnvironment, cacheInstructionService, jsonSerializer, lastSyncedFileManager, globalSettings) { _requestCache = requestCache; _requestAccessor = requestAccessor; }
public async Task Start_And_Stop_Umbraco_With_Components_Enabled() { IRuntime runtime = Services.GetRequiredService <IRuntime>(); IRuntimeState runtimeState = Services.GetRequiredService <IRuntimeState>(); IMainDom mainDom = Services.GetRequiredService <IMainDom>(); ComponentCollection components = Services.GetRequiredService <ComponentCollection>(); MyComponent myComponent = components.OfType <MyComponent>().First(); Assert.IsTrue(mainDom.IsMainDom); Assert.IsNull(runtimeState.BootFailedException); Assert.IsTrue(myComponent.IsInit, "The component was not initialized"); // force stop now await runtime.StopAsync(CancellationToken.None); Assert.IsTrue(myComponent.IsTerminated, "The component was not terminated"); }
public ScheduledPublishing( IRuntimeState runtimeState, IMainDom mainDom, IServerRoleAccessor serverRegistrar, IContentService contentService, IUmbracoContextFactory umbracoContextFactory, ILogger <ScheduledPublishing> logger, IServerMessenger serverMessenger) : this( runtimeState, mainDom, serverRegistrar, contentService, umbracoContextFactory, logger, serverMessenger, StaticServiceProvider.Instance.GetRequiredService <IScopeProvider>()) { }
public ExamineComponent(IMainDom mainDom, IExamineManager examineManager, IProfilingLogger profilingLogger, IScopeProvider scopeProvider, IUmbracoIndexesCreator indexCreator, ServiceContext services, IContentValueSetBuilder contentValueSetBuilder, IPublishedContentValueSetBuilder publishedContentValueSetBuilder, IValueSetBuilder <IMedia> mediaValueSetBuilder, IValueSetBuilder <IMember> memberValueSetBuilder) { _services = services; _scopeProvider = scopeProvider; _examineManager = examineManager; _contentValueSetBuilder = contentValueSetBuilder; _publishedContentValueSetBuilder = publishedContentValueSetBuilder; _mediaValueSetBuilder = mediaValueSetBuilder; _memberValueSetBuilder = memberValueSetBuilder; _mainDom = mainDom; _logger = profilingLogger; _indexCreator = indexCreator; }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseServerMessenger"/> class. /// </summary> protected DatabaseServerMessenger( IMainDom mainDom, CacheRefresherCollection cacheRefreshers, IServerRoleAccessor serverRoleAccessor, ILogger <DatabaseServerMessenger> logger, bool distributedEnabled, ISyncBootStateAccessor syncBootStateAccessor, IHostingEnvironment hostingEnvironment, ICacheInstructionService cacheInstructionService, IJsonSerializer jsonSerializer, LastSyncedFileManager lastSyncedFileManager, IOptionsMonitor <GlobalSettings> globalSettings) : base(distributedEnabled) { _cancellationToken = _cancellationTokenSource.Token; _mainDom = mainDom; _cacheRefreshers = cacheRefreshers; _serverRoleAccessor = serverRoleAccessor; _hostingEnvironment = hostingEnvironment; Logger = logger; _syncBootStateAccessor = syncBootStateAccessor; CacheInstructionService = cacheInstructionService; JsonSerializer = jsonSerializer; _lastSyncedFileManager = lastSyncedFileManager; GlobalSettings = globalSettings.CurrentValue; _lastPruned = _lastSync = DateTime.UtcNow; _syncIdle = new ManualResetEvent(true); globalSettings.OnChange(x => GlobalSettings = x); using (var process = Process.GetCurrentProcess()) { // See notes on _localIdentity LocalIdentity = Environment.MachineName // eg DOMAIN\SERVER + "/" + hostingEnvironment.ApplicationId // eg /LM/S3SVC/11/ROOT + " [P" + process.Id // eg 1234 + "/D" + AppDomain.CurrentDomain.Id // eg 22 + "] " + Guid.NewGuid().ToString("N").ToUpper(); // make it truly unique } _initialized = new Lazy <SyncBootState?>(InitializeWithMainDom); }
public PublishedSnapshotService( PublishedSnapshotServiceOptions options, ISyncBootStateAccessor syncBootStateAccessor, IMainDom mainDom, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IProfilingLogger profilingLogger, ILoggerFactory loggerFactory, IScopeProvider scopeProvider, INuCacheContentService publishedContentService, IDefaultCultureAccessor defaultCultureAccessor, IOptions <GlobalSettings> globalSettings, IPublishedModelFactory publishedModelFactory, IHostingEnvironment hostingEnvironment, IOptions <NuCacheSettings> config, ContentDataSerializer contentDataSerializer) { _options = options; _syncBootStateAccessor = syncBootStateAccessor; _mainDom = mainDom; _serviceContext = serviceContext; _publishedContentTypeFactory = publishedContentTypeFactory; _publishedSnapshotAccessor = publishedSnapshotAccessor; _variationContextAccessor = variationContextAccessor; _profilingLogger = profilingLogger; _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <PublishedSnapshotService>(); _scopeProvider = scopeProvider; _publishedContentService = publishedContentService; _defaultCultureAccessor = defaultCultureAccessor; _globalSettings = globalSettings.Value; _hostingEnvironment = hostingEnvironment; _contentDataSerializer = contentDataSerializer; _config = config.Value; _publishedModelFactory = publishedModelFactory; }
/// <summary> /// Initializes a new instance of the <see cref="CoreRuntime"/> class. /// </summary> public CoreRuntime( ILoggerFactory loggerFactory, IRuntimeState state, ComponentCollection components, IApplicationShutdownRegistry applicationShutdownRegistry, IProfilingLogger profilingLogger, IMainDom mainDom, IUmbracoDatabaseFactory databaseFactory, IEventAggregator eventAggregator, IHostingEnvironment hostingEnvironment, IUmbracoVersion umbracoVersion) { State = state; _loggerFactory = loggerFactory; _components = components; _applicationShutdownRegistry = applicationShutdownRegistry; _profilingLogger = profilingLogger; _mainDom = mainDom; _databaseFactory = databaseFactory; _eventAggregator = eventAggregator; _hostingEnvironment = hostingEnvironment; _umbracoVersion = umbracoVersion; _logger = _loggerFactory.CreateLogger <CoreRuntime>(); }
public ExamineUmbracoIndexingHandler( IMainDom mainDom, ILogger <ExamineUmbracoIndexingHandler> logger, IProfilingLogger profilingLogger, IScopeProvider scopeProvider, IExamineManager examineManager, IBackgroundTaskQueue backgroundTaskQueue, IContentValueSetBuilder contentValueSetBuilder, IPublishedContentValueSetBuilder publishedContentValueSetBuilder, IValueSetBuilder <IMedia> mediaValueSetBuilder, IValueSetBuilder <IMember> memberValueSetBuilder) { _mainDom = mainDom; _logger = logger; _profilingLogger = profilingLogger; _scopeProvider = scopeProvider; _examineManager = examineManager; _backgroundTaskQueue = backgroundTaskQueue; _contentValueSetBuilder = contentValueSetBuilder; _publishedContentValueSetBuilder = publishedContentValueSetBuilder; _mediaValueSetBuilder = mediaValueSetBuilder; _memberValueSetBuilder = memberValueSetBuilder; _enabled = new Lazy <bool>(IsEnabled); }
public CoreRuntime(ILogger logger, IMainDom mainDom) { MainDom = mainDom; Logger = logger; }
public BackgroundIndexRebuilder(IMainDom mainDom, IProfilingLogger logger, IndexRebuilder indexRebuilder) { _mainDom = mainDom; _logger = logger; _indexRebuilder = indexRebuilder; }
/// <summary> /// Boots the runtime within a timer. /// </summary> protected virtual IFactory Boot(IRegister register, DisposableTimer timer) { Composition composition = null; try { // Setup event listener UnattendedInstalled += CoreRuntime_UnattendedInstalled; // throws if not full-trust new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted).Demand(); // run handlers RuntimeOptions.DoRuntimeBoot(ProfilingLogger); // application caches var appCaches = GetAppCaches(); // database factory var databaseFactory = GetDatabaseFactory(); // configs var configs = GetConfigs(); // type loader var typeLoader = new TypeLoader(appCaches.RuntimeCache, configs.Global().LocalTempPath, ProfilingLogger); // runtime state // beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>' // as the second one captures the current value (null) and therefore fails _state = new RuntimeState(Logger, configs.Settings(), configs.Global(), new Lazy <IMainDom>(() => _factory.GetInstance <IMainDom>()), new Lazy <IServerRegistrar>(() => _factory.GetInstance <IServerRegistrar>())) { Level = RuntimeLevel.Boot }; // TODO: remove this in netcore, this is purely backwards compat hacks with the empty ctor if (MainDom == null) { MainDom = new MainDom(Logger, new MainDomSemaphoreLock(Logger)); } // create the composition composition = new Composition(register, typeLoader, ProfilingLogger, _state, configs); composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, MainDom, appCaches, databaseFactory, typeLoader, _state); // run handlers RuntimeOptions.DoRuntimeEssentials(composition, appCaches, typeLoader, databaseFactory); // register runtime-level services // there should be none, really - this is here "just in case" Compose(composition); // acquire the main domain - if this fails then anything that should be registered with MainDom will not operate AcquireMainDom(MainDom); // determine our runtime level DetermineRuntimeLevel(databaseFactory, ProfilingLogger); // get composers, and compose var composerTypes = ResolveComposerTypes(typeLoader); IEnumerable <Attribute> enableDisableAttributes; using (ProfilingLogger.DebugDuration <CoreRuntime>("Scanning enable/disable composer attributes")) { enableDisableAttributes = typeLoader.GetAssemblyAttributes(typeof(EnableComposerAttribute), typeof(DisableComposerAttribute)); } var composers = new Composers(composition, composerTypes, enableDisableAttributes, ProfilingLogger); composers.Compose(); // create the factory _factory = Current.Factory = composition.CreateFactory(); // determines if unattended install is enabled and performs it if required DoUnattendedInstall(databaseFactory); // determine our runtime level (AFTER UNATTENDED INSTALL) // TODO: Feels kinda weird to call this again DetermineRuntimeLevel(databaseFactory, ProfilingLogger); // if level is Run and reason is UpgradeMigrations, that means we need to perform an unattended upgrade if (_state.Reason == RuntimeLevelReason.UpgradeMigrations && _state.Level == RuntimeLevel.Run) { // do the upgrade DoUnattendedUpgrade(_factory.GetInstance <DatabaseBuilder>()); // upgrade is done, set reason to Run _state.Reason = RuntimeLevelReason.Run; } // create & initialize the components _components = _factory.GetInstance <ComponentCollection>(); _components.Initialize(); } catch (Exception e) { var bfe = e as BootFailedException ?? new BootFailedException("Boot failed.", e); if (_state != null) { _state.Level = RuntimeLevel.BootFailed; _state.BootFailedException = bfe; } timer?.Fail(exception: bfe); // be sure to log the exception - even if we repeat ourselves // if something goes wrong above, we may end up with no factory // meaning nothing can get the runtime state, etc - so let's try // to make sure we have a factory if (_factory == null) { try { _factory = Current.Factory = composition?.CreateFactory(); } catch { // In this case we are basically dead, we do not have a factory but we need // to report on the state so we need to manually set that, this is the only time // we ever do this. Current.RuntimeState = _state; } } Debugger.Break(); // throwing here can cause w3wp to hard-crash and we want to avoid it. // instead, we're logging the exception and setting level to BootFailed. // various parts of Umbraco such as UmbracoModule and UmbracoDefaultOwinStartup // understand this and will nullify themselves, while UmbracoModule will // throw a BootFailedException for every requests. } return(_factory); }
public ExamineFinalComponent(IProfilingLogger logger, IExamineManager examineManager, BackgroundIndexRebuilder indexRebuilder, IMainDom mainDom, ISyncBootStateAccessor syncBootStateAccessor) { _logger = logger; _examineManager = examineManager; _indexRebuilder = indexRebuilder; _mainDom = mainDom; _syncBootStateAccessor = syncBootStateAccessor; }
/// <summary> /// Initializes a new instance of the <see cref="WebRuntime"/> class. /// </summary> /// <param name="umbracoApplication"></param> public WebRuntime(UmbracoApplicationBase umbracoApplication, ILogger logger, IMainDom mainDom) : base(logger, mainDom) { _umbracoApplication = umbracoApplication; }
/// <summary> /// Initializes a new instance of the <see cref="MainDomHook"/> class. /// </summary> /// <param name="mainDom">The <see cref="IMainDom"/> object.</param> /// <param name="install">A method to execute when hooking into the main domain.</param> /// <param name="release">A method to execute when the main domain releases.</param> public MainDomHook(IMainDom mainDom, Action install, Action release) { MainDom = mainDom; Install = install; Release = release; }
public TestRuntime(ILogger logger, IMainDom mainDom) : base(logger, mainDom) { }
public ExamineUserComponent(IMainDom mainDom) { _mainDom = mainDom; }
public ExamineFinalComponent(IProfilingLogger logger, IExamineManager examineManager, BackgroundIndexRebuilder indexRebuilder, IMainDom mainDom) { _logger = logger; _examineManager = examineManager; _indexRebuilder = indexRebuilder; _mainDom = mainDom; }