コード例 #1
0
        public MqttService(
            PythonEngineService pythonEngineService,
            SystemService systemService,
            DiagnosticsService diagnosticsService,
            StorageService storageService,
            SystemStatusService systemStatusService,
            ILoggerFactory loggerFactory)
        {
            _systemService  = systemService ?? throw new ArgumentNullException(nameof(systemService));
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <MqttService>();

            if (pythonEngineService == null)
            {
                throw new ArgumentNullException(nameof(pythonEngineService));
            }
            pythonEngineService.RegisterSingletonProxy(new MqttPythonProxy(this));

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _inboundCounter  = diagnosticsService.CreateOperationsPerSecondCounter("mqtt.inbound_rate");
            _outboundCounter = diagnosticsService.CreateOperationsPerSecondCounter("mqtt.outbound_rate");

            systemStatusService.Set("mqtt.subscribers_count", () => _subscribers.Count);
            systemStatusService.Set("mqtt.incoming_messages_count", () => _incomingMessages.Count);
            systemStatusService.Set("mqtt.inbound_rate", () => _inboundCounter.Count);
            systemStatusService.Set("mqtt.outbound_rate", () => _outboundCounter.Count);
        }
コード例 #2
0
        public MqttService(
            SystemCancellationToken systemCancellationToken,
            DiagnosticsService diagnosticsService,
            StorageService storageService,
            SystemStatusService systemStatusService,
            ILoggerFactory loggerFactory)
        {
            _systemCancellationToken = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _storageService          = storageService ?? throw new ArgumentNullException(nameof(storageService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <MqttService>();

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _inboundCounter  = diagnosticsService.CreateOperationsPerSecondCounter("mqtt.inbound_rate");
            _outboundCounter = diagnosticsService.CreateOperationsPerSecondCounter("mqtt.outbound_rate");

            systemStatusService.Set("mqtt.subscribers_count", () => _subscribers.Count);
            systemStatusService.Set("mqtt.incoming_messages_count", () => _incomingMessages.Count);
            systemStatusService.Set("mqtt.inbound_rate", () => _inboundCounter.Count);
            systemStatusService.Set("mqtt.outbound_rate", () => _outboundCounter.Count);
        }
コード例 #3
0
        public SchedulerService(
            PythonEngineService pythonEngineService,
            SystemStatusService systemStatusService,
            SystemService systemService,
            StorageService storageService,
            ILoggerFactory loggerFactory)
        {
            _systemService  = systemService ?? throw new ArgumentNullException(nameof(systemService));
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <SchedulerService>();

            if (pythonEngineService == null)
            {
                throw new ArgumentNullException(nameof(pythonEngineService));
            }
            pythonEngineService.RegisterSingletonProxy(new SchedulerPythonProxy(this));

            systemStatusService.Set("scheduler.active_threads", () => _activeThreads.Count);
            systemStatusService.Set("scheduler.active_timers", () => _activeTimers.Count);
            systemStatusService.Set("scheduler.active_countdowns", () => _activeCountdowns.Count);
        }
コード例 #4
0
        public HistoryService(
            ComponentRegistryService componentRegistryService,
            StorageService storageService,
            MessageBusService messageBusService,
            SystemStatusService systemStatusService,
            SystemCancellationToken systemCancellationToken,
            DiagnosticsService diagnosticsService,
            ILogger <HistoryService> logger)
        {
            _componentRegistryService = componentRegistryService ?? throw new ArgumentNullException(nameof(componentRegistryService));
            _storageService           = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService        = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _systemCancellationToken  = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _updateRateCounter = diagnosticsService.CreateOperationsPerSecondCounter("history.update_rate");

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("history.component_status.pending_updates_count", _pendingComponentStatusValues.Count);
            systemStatusService.Set("history.component_status.update_rate", () => _updateRateCounter.Count);
            systemStatusService.Set("history.component_status.update_duration", () => _componentStatusUpdateDuration);
        }
コード例 #5
0
ファイル: LogService.cs プロジェクト: Spencerx/Wirehome.Core
        private void UpdateSystemStatus()
        {
            var informationsCount = 0;
            var warningsCount     = 0;
            var errorsCount       = 0;

            foreach (var logEntry in _logEntries)
            {
                if (logEntry.Level == LogLevel.Error)
                {
                    errorsCount++;
                }
                else if (logEntry.Level == LogLevel.Warning)
                {
                    warningsCount++;
                }
                else if (logEntry.Level == LogLevel.Information)
                {
                    informationsCount++;
                }
            }

            _systemStatusService.Set("log.informations_count", informationsCount);
            _systemStatusService.Set("log.warnings_count", warningsCount);
            _systemStatusService.Set("log.errors_count", errorsCount);
        }
コード例 #6
0
        public MqttService(
            SystemCancellationToken systemCancellationToken,
            DiagnosticsService diagnosticsService,
            StorageService storageService,
            SystemStatusService systemStatusService,
            ILogger <MqttService> logger)
        {
            _systemCancellationToken = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _storageService          = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _inboundCounter  = diagnosticsService.CreateOperationsPerSecondCounter("mqtt.inbound_rate");
            _outboundCounter = diagnosticsService.CreateOperationsPerSecondCounter("mqtt.outbound_rate");

            if (systemStatusService is null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("mqtt.subscribers_count", () => _subscribers.Count);
            systemStatusService.Set("mqtt.incoming_messages_count", () => _incomingMessages.Count);
            systemStatusService.Set("mqtt.inbound_rate", () => _inboundCounter.Count);
            systemStatusService.Set("mqtt.outbound_rate", () => _outboundCounter.Count);
            systemStatusService.Set("mqtt.connected_clients_count", () => _mqttServer.GetClientStatusAsync().GetAwaiter().GetResult().Count);

            _topicImportManager = new MqttTopicImportManager(this, _logger);
        }
コード例 #7
0
        public MessageBusService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            DiagnosticsService diagnosticsService,
            SystemCancellationToken systemCancellationToken,
            ILogger <MessageBusService> logger)
        {
            _systemCancellationToken = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (storageService == null)
            {
                throw new ArgumentNullException(nameof(storageService));
            }
            storageService.TryReadOrCreate(out _options, MessageBusServiceOptions.Filename);

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _inboundCounter        = diagnosticsService.CreateOperationsPerSecondCounter("message_bus.inbound_rate");
            _processingRateCounter = diagnosticsService.CreateOperationsPerSecondCounter("message_bus.processing_rate");

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("message_bus.queued_messages_count", () => _messageQueue.Count);
            systemStatusService.Set("message_bus.subscribers_count", () => _subscribers.Count);
            systemStatusService.Set("message_bus.inbound_rate", () => _inboundCounter.Count);
            systemStatusService.Set("message_bus.processing_rate", () => _processingRateCounter.Count);
        }
コード例 #8
0
        public MessageBusService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            DiagnosticsService diagnosticsService,
            SystemCancellationToken systemCancellationToken,
            ILogger <MessageBusService> logger)
        {
            _systemCancellationToken = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (storageService == null)
            {
                throw new ArgumentNullException(nameof(storageService));
            }
            storageService.SafeReadSerializedValue(out _options, DefaultDirectoryNames.Configuration, MessageBusServiceOptions.Filename);

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _inboundCounter        = diagnosticsService.CreateOperationsPerSecondCounter("message_bus.inbound_rate");
            _processingRateCounter = diagnosticsService.CreateOperationsPerSecondCounter("message_bus.processing_rate");

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("message_bus.queued_messages_count", () => _messageQueue.Count);
            systemStatusService.Set("message_bus.subscribers_count", () => _subscribers.Count);
            systemStatusService.Set("message_bus.inbound_rate", () => _inboundCounter.Count);
            systemStatusService.Set("message_bus.processing_rate", () => _processingRateCounter.Count);

            _options.ToString(); // TODO: Remove or add new settings.
        }
コード例 #9
0
        public void set(string key, object value)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            _systemInformationService.Set(key, value);
        }
コード例 #10
0
        public SchedulerService(
            SystemStatusService systemStatusService,
            SystemCancellationToken systemCancellationToken,
            StorageService storageService,
            ILogger <SchedulerService> logger)
        {
            _systemCancellationToken = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _storageService          = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            systemStatusService.Set("scheduler.active_threads", () => _activeThreads.Count);
            systemStatusService.Set("scheduler.active_timers", () => _activeTimers.Count);
            systemStatusService.Set("scheduler.active_countdowns", () => _activeCountdowns.Count);
        }
コード例 #11
0
        public NotificationsService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            ResourcesService resourcesService,
            PythonEngineService pythonEngineService,
            MessageBusService messageBusService,
            SystemService systemService,
            ILoggerFactory loggerFactory)
        {
            _storageService    = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _resourcesService  = resourcesService ?? throw new ArgumentNullException(nameof(resourcesService));
            _messageBusService = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _systemService     = systemService ?? throw new ArgumentNullException(nameof(systemService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <NotificationsService>();

            pythonEngineService.RegisterSingletonProxy(new NotificationsPythonProxy(this));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("notifications.count", () =>
            {
                lock (_notifications)
                {
                    return(_notifications.Count);
                }
            });
        }
コード例 #12
0
        public ComponentRegistryService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            MessageBusService messageBusService,
            ComponentInitializerFactory componentInitializerFactory,
            PythonEngineService pythonEngineService,
            ILoggerFactory loggerFactory)
        {
            _storageService              = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService           = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _componentInitializerFactory = componentInitializerFactory ?? throw new ArgumentNullException(nameof(componentInitializerFactory));

            _messageBusProxy = new ComponentRegistryMessageBusProxy(messageBusService);

            pythonEngineService.RegisterSingletonProxy(new ComponentRegistryPythonProxy(this));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <ComponentRegistryService>();

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("component_registry.count", () => _components.Count);
        }
コード例 #13
0
        public ServiceHostService(
            StorageService storageService,
            PackageManagerService repositoryService,
            PythonScriptHostFactoryService pythonScriptHostFactoryService,
            SystemService systemService,
            SystemStatusService systemStatusService,
            ILogger <ServiceHostService> logger)
        {
            _repositoryService = repositoryService ?? throw new ArgumentNullException(nameof(repositoryService));
            _pythonScriptHostFactoryService = pythonScriptHostFactoryService ?? throw new ArgumentNullException(nameof(pythonScriptHostFactoryService));
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _logger         = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("service_host.service_count", () => _services.Count);

            if (systemService == null)
            {
                throw new ArgumentNullException(nameof(systemService));
            }
            systemService.StartupCompleted += (s, e) =>
            {
                StartDelayedServices();
            };
        }
コード例 #14
0
        public NotificationsService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            ResourceService resourcesService,
            MessageBusService messageBusService,
            SystemCancellationToken systemCancellationToken,
            ILogger <NotificationsService> logger)
        {
            _storageService          = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _resourcesService        = resourcesService ?? throw new ArgumentNullException(nameof(resourcesService));
            _messageBusService       = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _systemCancellationToken = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("notifications.count", () =>
            {
                lock (_notifications)
                {
                    return(_notifications.Count);
                }
            });
        }
コード例 #15
0
        public ComponentRegistryService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            MessageBusService messageBusService,
            AppService appService,
            ComponentInitializerService componentInitializerService,
            ILogger <ComponentRegistryService> logger)
        {
            _storageService              = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService           = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _componentInitializerService = componentInitializerService ?? throw new ArgumentNullException(nameof(componentInitializerService));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _messageBusWrapper = new ComponentRegistryMessageBusWrapper(messageBusService);

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("component_registry.count", () => _components.Count);

            if (appService is null)
            {
                throw new ArgumentNullException(nameof(appService));
            }
            appService.RegisterStatusProvider("components", () =>
            {
                return(GetComponents().Select(c => ComponentsController.CreateComponentModel(c)));
            });
        }
コード例 #16
0
        public void Start()
        {
            lock (_macros)
            {
                Load();
            }

            AttachToMessageBus();

            _systemStatusService.Set("macros.macros_count", () => _macros.Count);
        }
コード例 #17
0
        public PythonEngineService(SystemStatusService systemStatusService, ILogger <PythonEngineService> logger)
        {
            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("python_engine.created_script_hosts_count", () => _createdScriptHostsCount);

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _logPythonProxy      = new LogPythonProxy(_logger);
            _pythonIOToLogStream = new PythonIOToLogStream(_logger);
        }
コード例 #18
0
        public CloudService(StorageService storageService, SystemStatusService systemStatusService, ILogger <CloudService> logger)
        {
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _logger         = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("cloud.is_connected", () => _isConnected);

            _httpClient.BaseAddress = new Uri("http://127.0.0.1:80");
        }
コード例 #19
0
        public MessageBusService(
            PythonEngineService pythonEngineService,
            SystemStatusService systemStatusService,
            DiagnosticsService diagnosticsService,
            SystemService systemService,
            ILoggerFactory loggerFactory)
        {
            _systemService = systemService ?? throw new ArgumentNullException(nameof(systemService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <MessageBusService>();

            if (pythonEngineService == null)
            {
                throw new ArgumentNullException(nameof(pythonEngineService));
            }
            pythonEngineService.RegisterSingletonProxy(new MessageBusPythonProxy(this));

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _inboundCounter        = diagnosticsService.CreateOperationsPerSecondCounter("message_bus.inbound_rate");
            _processingRateCounter = diagnosticsService.CreateOperationsPerSecondCounter("message_bus.processing_rate");

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("message_bus.queued_messages_count", () => _messageQueue.Count);
            systemStatusService.Set("message_bus.subscribers_count", () => _subscribers.Count);
            systemStatusService.Set("message_bus.inbound_rate", () => _inboundCounter.Count);
            systemStatusService.Set("message_bus.processing_rate", () => _processingRateCounter.Count);
        }
コード例 #20
0
        public ComponentGroupRegistryService(
            StorageService storageService,
            SystemStatusService systemInformationService,
            MessageBusService messageBusService,
            ILogger <ComponentGroupRegistryService> logger)
        {
            _storageService    = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _logger            = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            systemInformationService.Set("component_group_registry.count", () => _componentGroups.Count);
        }
コード例 #21
0
        public MacroRegistryService(
            StorageService storageService,
            MessageBusService messageBusService,
            SystemStatusService systemStatusService,
            ComponentRegistryService componentRegistryService,
            ILogger <MacroRegistryService> logger)
        {
            _storageService           = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService        = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _componentRegistryService = componentRegistryService ?? throw new ArgumentNullException(nameof(componentRegistryService));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("macro_registry.count", () => _macros.Count);

            _messageBusWrapper = new MacroRegistryMessageBusWrapper(_messageBusService);
        }
コード例 #22
0
        public MacroRegistryService(
            StorageService storageService,
            MessageBusService messageBusService,
            SystemStatusService systemStatusService,
            ILoggerFactory loggerFactory)
        {
            _storageService      = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService   = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _systemStatusService = systemStatusService ?? throw new ArgumentNullException(nameof(systemStatusService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <MacroRegistryService>();

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("macros.macros_count", () => 0);
        }
コード例 #23
0
        public ServiceHostService(
            StorageService storageService,
            RepositoryService repositoryService,
            PythonEngineService pythonEngineService,
            SystemStatusService systemStatusService,
            ILoggerFactory loggerFactory)
        {
            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            _repositoryService   = repositoryService ?? throw new ArgumentNullException(nameof(repositoryService));
            _pythonEngineService = pythonEngineService ?? throw new ArgumentNullException(nameof(pythonEngineService));
            _loggerFactory       = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            _storageService      = storageService ?? throw new ArgumentNullException(nameof(storageService));

            _logger = loggerFactory.CreateLogger <ServiceHostService>();

            pythonEngineService.RegisterSingletonProxy(new ServiceHostPythonProxy(this));

            systemStatusService.Set("service_host.service_count", () => _serviceInstances.Count);
        }
コード例 #24
0
        public ComponentGroupRegistryService(
            StorageService storageService,
            SystemStatusService systemInformationService,
            MessageBusService messageBusService,
            AppService appService,
            ILogger <ComponentGroupRegistryService> logger)
        {
            _storageService    = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _appService        = appService ?? throw new ArgumentNullException(nameof(appService));
            _logger            = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            systemInformationService.Set("component_group_registry.count", () => _componentGroups.Count);

            appService.RegisterStatusProvider("componentGroups", () =>
            {
                return(GetComponentGroups().Select(c => ComponentGroupsController.CreateComponentGroupModel(c)));
            });
        }
コード例 #25
0
        public ServiceHostService(
            StorageService storageService,
            RepositoryService repositoryService,
            PythonScriptHostFactoryService pythonScriptHostFactoryService,
            SystemStatusService systemStatusService,
            ILoggerFactory loggerFactory)
        {
            _repositoryService = repositoryService ?? throw new ArgumentNullException(nameof(repositoryService));
            _pythonScriptHostFactoryService = pythonScriptHostFactoryService ?? throw new ArgumentNullException(nameof(pythonScriptHostFactoryService));
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <ServiceHostService>();

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("service_host.service_count", () => _services.Count);
        }
コード例 #26
0
        public ComponentHistoryService(
            ComponentRegistryService componentRegistryService,
            HistoryService historyService,
            StorageService storageService,
            SystemStatusService systemStatusService,
            SystemCancellationToken systemCancellationToken,
            BackupService backupService,
            ILogger <ComponentHistoryService> logger)
        {
            _componentRegistryService = componentRegistryService ?? throw new ArgumentNullException(nameof(componentRegistryService));
            _historyService           = historyService ?? throw new ArgumentNullException(nameof(historyService));
            _storageService           = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _systemCancellationToken  = systemCancellationToken ?? throw new ArgumentNullException(nameof(systemCancellationToken));
            _backupService            = backupService ?? throw new ArgumentNullException(nameof(backupService));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("component_history.pending_status_work_items", _pendingStatusWorkItems.Count);

            _componentRegistryService.ComponentStatusChanged += OnComponentStatusChanged;
        }
コード例 #27
0
        public HistoryService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            DiagnosticsService diagnosticsService,
            ILogger <HistoryService> logger)
        {
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _logger         = logger ?? throw new ArgumentNullException(nameof(logger));

            _historyRepository = new HistoryRepository();

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }
            _updateRateCounter = diagnosticsService.CreateOperationsPerSecondCounter("history.update_rate");

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("history.update_rate", () => _updateRateCounter.Count);
            systemStatusService.Set("history.updates_count", () => _updatesCount);
            systemStatusService.Set("history.last_update_duration", () => _lastUpdateDuration);
            systemStatusService.Set("history.max_update_duration", () => _maxUpdateDuration);
            systemStatusService.Set("history.min_update_duration", () => _minUpdateDuration);
            systemStatusService.Set("history.average_update_duration", () =>
            {
                if (_updatesCount == 0)
                {
                    return(double.NaN);
                }

                return(_totalUpdateDuration / (decimal)_updatesCount);
            });
        }
コード例 #28
0
 public void PostSystemStatus(string uid, [FromBody] object value)
 {
     _systemStatusService.Set(uid, value);
 }
コード例 #29
0
ファイル: LogService.cs プロジェクト: mfr78/Wirehome.Core
 private void UpdateSystemStatus()
 {
     _systemStatusService.Set("log.informations_count", _informationsCount);
     _systemStatusService.Set("log.warnings_count", _warningsCount);
     _systemStatusService.Set("log.errors_count", _errorsCount);
 }
コード例 #30
0
        public CloudService(StorageService storageService, SystemStatusService systemStatusService, ILogger <CloudService> logger)
        {
            _storageService = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _logger         = logger ?? throw new ArgumentNullException(nameof(logger));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("cloud.is_connected", () => _isConnected);
            systemStatusService.Set("cloud.bytes_sent", () => _channel?.GetStatistics()?.BytesSent);
            systemStatusService.Set("cloud.bytes_received", () => _channel?.GetStatistics()?.BytesReceived);
            systemStatusService.Set("cloud.connected", () => _channel?.GetStatistics()?.Connected.ToString("O"));
            systemStatusService.Set("cloud.last_message_received", () => _channel?.GetStatistics()?.LastMessageReceived?.ToString("O"));
            systemStatusService.Set("cloud.last_message_sent", () => _channel?.GetStatistics()?.LastMessageSent?.ToString("O"));
            systemStatusService.Set("cloud.messages_received", () => _channel?.GetStatistics()?.MessagesReceived);
            systemStatusService.Set("cloud.messages_sent", () => _channel?.GetStatistics()?.MessagesSent);
            systemStatusService.Set("cloud.malformed_messages_received", () => _channel?.GetStatistics()?.MalformedMessagesReceived);
            systemStatusService.Set("cloud.receive_errors", () => _channel?.GetStatistics()?.ReceiveErrors);
            systemStatusService.Set("cloud.send_errors", () => _channel?.GetStatistics()?.SendErrors);

            _httpClient.BaseAddress = new Uri("http://127.0.0.1:80");

            _cloudMessageSerializer = new CloudMessageSerializer();
            _cloudMessageFactory    = new CloudMessageFactory(_cloudMessageSerializer);
        }