Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HealthCheckNotifier"/> class.
        /// </summary>
        /// <param name="healthChecksSettings">The configuration for health check settings.</param>
        /// <param name="healthChecks">The collection of healthchecks.</param>
        /// <param name="notifications">The collection of healthcheck notification methods.</param>
        /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param>
        /// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param>
        /// <param name="mainDom">Representation of the main application domain.</param>
        /// <param name="scopeProvider">Provides scopes for database operations.</param>
        /// <param name="logger">The typed logger.</param>
        /// <param name="profilingLogger">The profiling logger.</param>
        /// <param name="cronTabParser">Parser of crontab expressions.</param>
        public HealthCheckNotifier(
            IOptionsMonitor <HealthChecksSettings> healthChecksSettings,
            HealthCheckCollection healthChecks,
            HealthCheckNotificationMethodCollection notifications,
            IRuntimeState runtimeState,
            IServerRoleAccessor serverRegistrar,
            IMainDom mainDom,
            ICoreScopeProvider scopeProvider,
            ILogger <HealthCheckNotifier> logger,
            IProfilingLogger profilingLogger,
            ICronTabParser cronTabParser)
            : base(
                logger,
                healthChecksSettings.CurrentValue.Notification.Period,
                healthChecksSettings.CurrentValue.GetNotificationDelay(cronTabParser, DateTime.Now, DefaultDelay))
        {
            _healthChecksSettings = healthChecksSettings.CurrentValue;
            _healthChecks         = healthChecks;
            _notifications        = notifications;
            _runtimeState         = runtimeState;
            _serverRegistrar      = serverRegistrar;
            _mainDom         = mainDom;
            _scopeProvider   = scopeProvider;
            _logger          = logger;
            _profilingLogger = profilingLogger;

            healthChecksSettings.OnChange(x =>
            {
                _healthChecksSettings = x;
                ChangePeriod(x.Notification.Period);
            });
        }
        private TouchServerTask CreateTouchServerTask(RuntimeLevel runtimeLevel = RuntimeLevel.Run, string applicationUrl = ApplicationUrl, bool useElection = true)
        {
            var mockRequestAccessor = new Mock <IHostingEnvironment>();

            mockRequestAccessor.SetupGet(x => x.ApplicationMainUrl).Returns(!string.IsNullOrEmpty(applicationUrl) ? new Uri(ApplicationUrl) : null);

            var mockRunTimeState = new Mock <IRuntimeState>();

            mockRunTimeState.SetupGet(x => x.Level).Returns(runtimeLevel);

            var mockLogger = new Mock <ILogger <TouchServerTask> >();

            _mockServerRegistrationService = new Mock <IServerRegistrationService>();

            var settings = new GlobalSettings
            {
                DatabaseServerRegistrar = new DatabaseServerRegistrarSettings
                {
                    StaleServerTimeout = _staleServerTimeout,
                }
            };

            IServerRoleAccessor roleAccessor = useElection
                ? new ElectedServerRoleAccessor(_mockServerRegistrationService.Object)
                : new SingleServerRoleAccessor();

            return(new TouchServerTask(
                       mockRunTimeState.Object,
                       _mockServerRegistrationService.Object,
                       mockRequestAccessor.Object,
                       mockLogger.Object,
                       Options.Create(settings),
                       roleAccessor));
        }
 /// <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;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TouchServerTask"/> class.
 /// </summary>
 /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param>
 /// <param name="serverRegistrationService">Services for server registrations.</param>
 /// <param name="requestAccessor">Accessor for the current request.</param>
 /// <param name="logger">The typed logger.</param>
 /// <param name="globalSettings">The configuration for global settings.</param>
 public TouchServerTask(
     IRuntimeState runtimeState,
     IServerRegistrationService serverRegistrationService,
     IHostingEnvironment hostingEnvironment,
     ILogger <TouchServerTask> logger,
     IOptions <GlobalSettings> globalSettings,
     IServerRoleAccessor serverRoleAccessor)
     : base(logger, globalSettings.Value.DatabaseServerRegistrar.WaitTimeBetweenCalls, TimeSpan.FromSeconds(15))
 {
     _runtimeState = runtimeState;
     _serverRegistrationService = serverRegistrationService ?? throw new ArgumentNullException(nameof(serverRegistrationService));
     _hostingEnvironment        = hostingEnvironment;
     _logger             = logger;
     _globalSettings     = globalSettings.Value;
     _serverRoleAccessor = serverRoleAccessor;
 }
 /// <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;
 }
Beispiel #6
0
 /// <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;
 }
Beispiel #7
0
 /// <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="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;
 }
Beispiel #9
0
 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 SystemInformationTelemetryProvider(
        IUmbracoVersion version,
        ILocalizationService localizationService,
        IOptionsMonitor <ModelsBuilderSettings> modelsBuilderSettings,
        IOptionsMonitor <HostingSettings> hostingSettings,
        IOptionsMonitor <GlobalSettings> globalSettings,
        IHostEnvironment hostEnvironment,
        IUmbracoDatabaseFactory umbracoDatabaseFactory,
        IServerRoleAccessor serverRoleAccessor)
    {
        _version                = version;
        _localizationService    = localizationService;
        _hostEnvironment        = hostEnvironment;
        _umbracoDatabaseFactory = umbracoDatabaseFactory;
        _serverRoleAccessor     = serverRoleAccessor;

        _globalSettings        = globalSettings.CurrentValue;
        _hostingSettings       = hostingSettings.CurrentValue;
        _modelsBuilderSettings = modelsBuilderSettings.CurrentValue;
    }
Beispiel #11
0
        /// <summary>
        /// Generate a new uSyncApplicationStartingHandler object
        /// </summary>
        public uSyncApplicationStartingHandler(
            ILogger <uSyncApplicationStartingHandler> logger,
            IRuntimeState runtimeState,
            IServerRoleAccessor serverRegistrar,
            IUmbracoContextFactory umbracoContextFactory,
            uSyncConfigService uSyncConfigService,
            SyncFileService syncFileService,
            uSyncService uSyncService)
        {
            this._runtimeState    = runtimeState;
            this._serverRegistrar = serverRegistrar;

            this._umbracoContextFactory = umbracoContextFactory;

            this._logger = logger;

            this._uSyncConfig = uSyncConfigService;

            this._syncFileService = syncFileService;
            this._uSyncService    = uSyncService;
        }
Beispiel #12
0
        /// <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);
        }
 /// <summary>
 ///     Sets the server registrar.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="registrar">A server registrar.</param>
 public static IUmbracoBuilder SetServerRegistrar(this IUmbracoBuilder builder, IServerRoleAccessor registrar)
 {
     builder.Services.AddUnique(registrar);
     return(builder);
 }