/// <inheritdoc/>
        protected override void OnServiceStart()
        {
            base.OnServiceStart();

            _downloadServiceConfig = _getDownloadServiceConfig();

            _innerEyeSegmentationClient?.Dispose();
            _innerEyeSegmentationClient = _getInnerEyeSegmentationClient.Invoke();
        }
Beispiel #2
0
        /// <inheritdoc/>
        protected override void OnServiceStart()
        {
            base.OnServiceStart();

            _innerEyeSegmentationClient?.Dispose();
            _innerEyeSegmentationClient = _getInnerEyeSegmentationClient.Invoke();

            _aetConfigModels = _aetConfigProvider.Invoke();
        }
Beispiel #3
0
 /// <summary>
 /// Create a new instance of the <see cref="ConfigurationService"/> class.
 /// </summary>
 /// <param name="innerEyeSegmentationClient">Optional InnerEye segmentation client.</param>
 /// <param name="getConfigurationServiceConfig">Configuration service config callback.</param>
 /// <param name="services">The services.</param>
 /// <returns>New ConfigurationService<T>.</returns>
 protected ConfigurationService CreateConfigurationService(
     IInnerEyeSegmentationClient innerEyeSegmentationClient          = null,
     Func <ConfigurationServiceConfig> getConfigurationServiceConfig = null,
     params IService[] services) =>
 new ConfigurationService(
     innerEyeSegmentationClient != null ? () => innerEyeSegmentationClient : TestGatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(),
     getConfigurationServiceConfig ?? TestGatewayProcessorConfigProvider.ConfigurationServiceConfig,
     _loggerFactory.CreateLogger("ConfigurationService"),
     services);
        /// <summary>
        /// Disposes of all managed resources.
        /// </summary>
        /// <param name="disposing">If we are disposing.</param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!disposing)
            {
                return;
            }

            _innerEyeSegmentationClient?.Dispose();
            _innerEyeSegmentationClient = null;
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="UploadService"/> class.
 /// </summary>
 /// <param name="innerEyeSegmentationClient">Optional InnerEye segmentation client.</param>
 /// <param name="aetConfigProvider">AET configuration provider.</param>
 /// <param name="instances">The number of concurrent execution instances we should have.</param>
 /// <returns>New UploadService.</returns>
 protected UploadService CreateUploadService(
     IInnerEyeSegmentationClient innerEyeSegmentationClient = null,
     Func <IEnumerable <AETConfigModel> > aetConfigProvider = null,
     int instances = 1) =>
 new UploadService(
     innerEyeSegmentationClient != null ? () => innerEyeSegmentationClient : TestGatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(),
     aetConfigProvider ?? _testAETConfigProvider.AETConfigModels,
     TestUploadQueuePath,
     TestDownloadQueuePath,
     TestDeleteQueuePath,
     TestGatewayProcessorConfigProvider.DequeueServiceConfig,
     _loggerFactory.CreateLogger("UploadService"),
     instances);
Beispiel #6
0
 /// <summary>
 /// Creates a new instance of the <see cref="DownloadService"/> class.
 /// </summary>
 /// <param name="innerEyeSegmentationClient">Optional InnerEye segmentation client.</param>
 /// <param name="dequeueServiceConfig">Optional dequeue service config.</param>
 /// <param name="instances">The number of concurrent execution instances we should have.</param>
 /// <returns>New DownloadService.</returns>
 protected DownloadService CreateDownloadService(
     IInnerEyeSegmentationClient innerEyeSegmentationClient = null,
     DequeueServiceConfig dequeueServiceConfig = null,
     int instances = 1) =>
 new DownloadService(
     innerEyeSegmentationClient != null ? () => innerEyeSegmentationClient : TestGatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(),
     TestDownloadQueuePath,
     TestPushQueuePath,
     TestDeleteQueuePath,
     () => new DownloadServiceConfig(),
     dequeueServiceConfig != null ? (Func <DequeueServiceConfig>)(() => dequeueServiceConfig) : TestGatewayProcessorConfigProvider.DequeueServiceConfig,
     _loggerFactory.CreateLogger("DownloadService"),
     instances);
Beispiel #7
0
        /// <summary>
        /// Disposes of all managed resources.
        /// </summary>
        /// <param name="disposing">If we are disposing.</param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!disposing)
            {
                return;
            }

            _services.ForEach(x => x.StopRequested -= Service_StopRequested);
            _services.ForEach(x => x.Dispose());

            _innerEyeSegmentationClient?.Dispose();
            _innerEyeSegmentationClient = null;
        }
Beispiel #8
0
        /// <summary>
        /// Called when the service is started.
        /// </summary>
        protected override void OnServiceStart()
        {
            _innerEyeSegmentationClient?.Dispose();
            _innerEyeSegmentationClient = null;

            if (_getInnerEyeSegmentationClient != null)
            {
                _innerEyeSegmentationClient = _getInnerEyeSegmentationClient.Invoke();

                Task.WaitAll(PingAsync(stopServiceOnAuthFailures: false));
            }

            _configurationServiceConfig = _getConfigurationServiceConfig();

            // Initialize the log
            LogInformation(LogEntry.CreateInitialize());

            // Start the services.
            _services.ForEach(x => x.Start());
        }
Beispiel #9
0
        /// <summary>
        /// Called when [update tick] is called. This will wait for all work to execute then will pause for desired interval delay.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The async task.
        /// </returns>
        protected override async Task OnUpdateTickAsync(CancellationToken cancellationToken)
        {
            // Check we can still ping with the license key
            // This call will stop this service if the license key is invalid.
            await PingAsync().ConfigureAwait(false);

            await Task.Delay(_configurationServiceConfig.ConfigurationRefreshDelay, cancellationToken).ConfigureAwait(false);

            var config = _getConfigurationServiceConfig();

            if (config.ConfigCreationDateTime > _configurationServiceConfig.ConfigCreationDateTime &&
                DateTime.UtcNow >= config.ApplyConfigDateTime)
            {
                LogInformation(LogEntry.Create(ServiceStatus.NewConfigurationAvailable));

                _innerEyeSegmentationClient?.Dispose();
                _innerEyeSegmentationClient = null;

                if (_getInnerEyeSegmentationClient != null)
                {
                    _innerEyeSegmentationClient = _getInnerEyeSegmentationClient.Invoke();
                }

                // Update the current configuration.
                _configurationServiceConfig = config;

                // Stop the services
                _services.ForEach(x => x.OnStop());

                // Re-initialize the log
                LogInformation(LogEntry.CreateInitialize());

                // Start the services again
                _services.ForEach(x => x.Start());

                LogInformation(LogEntry.Create(ServiceStatus.NewConfigurationApplied));
            }
        }
 public MockInnerEyeSegmentationClient(IInnerEyeSegmentationClient InnerEyeSegmentationClient)
 {
     _InnerEyeSegmentationClient = InnerEyeSegmentationClient;
 }