public TopicAndQueueInitializer(QueueSnapshotCache queueSnapshotCache,
                                 ITopicsAndQueuesSnapshotStorage storage, QueueSnapshotWriter queueSnapshotWriter,
                                 AppGlobalFlags appGlobalFlags, IAppLogger appLogger, TaskSchedulerByTopic schedulerByTopic,
                                 RestorePageFromBlobOperation restorePageFromBlobOperation)
 {
     _queueSnapshotCache           = queueSnapshotCache;
     _storage                      = storage;
     _queueSnapshotWriter          = queueSnapshotWriter;
     _appGlobalFlags               = appGlobalFlags;
     _appLogger                    = appLogger;
     _schedulerByTopic             = schedulerByTopic;
     _restorePageFromBlobOperation = restorePageFromBlobOperation;
 }
예제 #2
0
 public ServicesDisposer(TaskSchedulerByTopic taskSchedulerByTopic,
                         QueueSnapshotWriter queueSnapshotWriter)
 {
     _taskSchedulerByTopic = taskSchedulerByTopic;
     _queueSnapshotWriter  = queueSnapshotWriter;
 }
예제 #3
0
        public static void Init(IServiceProvider sp, SettingsModel settingsModel)
        {
            AppLogger = sp.GetRequiredService <IAppLogger>();
            LogsSnapshotRepository = sp.GetRequiredService <LogsSnapshotRepository>();

            var items = LogsSnapshotRepository.LoadAsync().AsTask().Result;

            ((AppLogger)AppLogger).Init(items);

            var queuesTimeSpan = TimeSpan.Parse(settingsModel.FlushQueuesSnapshotFreq);

            _taskTimerSyncQueues = new TaskTimer(queuesTimeSpan);

            var messagesTimeSpan = TimeSpan.Parse(settingsModel.FlushMessagesFreq);

            _taskTimerSyncMessages = new TaskTimer(messagesTimeSpan);

            AppGlobalFlags = sp.GetRequiredService <AppGlobalFlags>();
            AppGlobalFlags.LoadBlobPagesSize = settingsModel.LoadBlobPagesSize;

            _serviceProvider      = sp;
            QueueSnapshotCache    = sp.GetRequiredService <QueueSnapshotCache>();
            MessagesContentCache  = sp.GetRequiredService <MessagesContentCache>();
            MessagesContentReader = sp.GetRequiredService <MessagesContentReader>();
            MetricsByTopic        = sp.GetRequiredService <MetricsByTopic>();

            _activePagesWarmerAndGc = sp.GetRequiredService <ActivePagesWarmerAndGc>();

            TaskSchedulerByTopic = sp.GetRequiredService <TaskSchedulerByTopic>();

            _queueSnapshotWriter = sp.GetRequiredService <QueueSnapshotWriter>();

            CompressPageBlobOperation = sp.GetRequiredService <CompressPageBlobOperation>();

            CompressedMessagesStorage = sp.GetRequiredService <ICompressedMessagesStorage>();

            CompressedMessagesUtils = sp.GetRequiredService <CompressedMessagesUtils>();

            LegacyCompressedMessagesStorage = sp.GetRequiredService <ILegacyCompressedMessagesStorage>();

            MessagesContentPersistentStorage = sp.GetRequiredService <IMessagesContentPersistentStorage>();
            ((MessagesPersistentStorage)MessagesContentPersistentStorage).Inject(sp);

            LastCompressedPageStorage = sp.GetRequiredService <ILastCompressedPageStorage>();

            IndexByMinuteWriter = sp.GetRequiredService <IndexByMinuteWriter>();

            SyncAndGcBlobOperations = sp.GetRequiredService <SyncAndGcBlobOperations>();


            Task.Run(() => InitTopicsAsync(sp));

            _taskTimerSyncQueues.Register("SyncQueuesSnapshotToStorage", _queueSnapshotWriter.ExecuteAsync);
            _taskTimerSyncQueues.Register("ActiveMessagesWarmerAndGc", _activePagesWarmerAndGc.CheckAndWarmItUpOrGcAsync);
            _taskTimerSyncQueues.Register("IndexByMinuteWriter", IndexByMinuteWriter.SaveMessagesToStorage);
            _taskTimerSyncQueues.Register("FlushLastCompressedPagesState", LastCompressedPageStorage.FlushAsync);
            _taskTimerSyncQueues.Register("Update prometheus", () =>
            {
                MetricsCollector.UpdatePrometheus();
                return(new ValueTask());
            });

            _taskTimerSyncQueues.RegisterExceptionHandler((timer, e) =>
            {
                AppLogger.AddLog(LogProcess.System, timer, e.Message, e.StackTrace);
                return(new ValueTask());
            });

            _taskTimerSyncMessages.Register("PersistentOperationsScheduler", SyncAndGcBlobOperations.Sync);

            _taskTimerSyncMessages.RegisterExceptionHandler((timer, e) =>
            {
                AppLogger.AddLog(LogProcess.System, timer, e.Message, e.StackTrace);
                return(new ValueTask());
            });
        }