Beispiel #1
0
        private async Task PushNetworkDataAcquisitionJobConfig(
            string storageChannelName,
            IEnumerable <string> selectedAnalysersChannels,
            JobConfigUpdateCommand jobConfigUpdateCommand)
        {
            var outputChannels = selectedAnalysersChannels
                                 .Concat(new[] { storageChannelName, })
                                 .ToArray();

            foreach (var dataAcquirer in jobConfigUpdateCommand.DataAcquirers)
            {
                var attributes = jobConfigUpdateCommand
                                 .Attributes.GetValue(dataAcquirer)?.ToObject <JObject>() ?? new JObject();

                try
                {
                    var topicQuery = new JProperty("TopicQuery", jobConfigUpdateCommand.TopicQuery);
                    attributes.Add(topicQuery);
                    var languageProperty = new JProperty("Language", jobConfigUpdateCommand.Language);
                    attributes.Add(languageProperty);
                }
                catch (Exception e)
                {
                    _logger.TrackError(
                        "PushNetworkJobConfig",
                        "Error while adding attributes",
                        new
                    {
                        jobId     = jobConfigUpdateCommand.JobId,
                        exception = e
                    });

                    throw;
                }

                var notification = new DataAcquisitionConfigUpdateNotification
                {
                    JobId      = jobConfigUpdateCommand.JobId,
                    Attributes = attributes,
                    OutputMessageBrokerChannels = outputChannels,
                    Command = JobCommand.Start
                };

                await NotifyComponent(
                    jobConfigUpdateCommand.JobId,
                    dataAcquirer,
                    notification);

                var componentConfig = new JobComponentConfig
                {
                    ComponentId = dataAcquirer,
                    Attributes  = attributes,
                    JobId       = jobConfigUpdateCommand.JobId,
                    OutputMessageBrokerChannels = notification.OutputMessageBrokerChannels
                };

                await _componentRegistry.InsertJobComponentConfigAsync(componentConfig);
            }
        }
Beispiel #2
0
        private async Task InsertComponentJobConfigAsync(string componentId, Guid jobId)
        {
            IEnumerable <string> assert(JobComponentConfig a, JobComponentConfig b)
            {
                yield return(AssertProperty("ComponentId", (r) => r.ComponentId, a, b));

                yield return(AssertProperty("JobId", (r) => r.JobId, a, b));

                yield return(AssertProperty("OutputChannel(Length)", (r) => r.OutputMessageBrokerChannels.Length, a, b));

                yield return(AssertProperty("OutputChannel(Item)", (r) => r.OutputMessageBrokerChannels[0], a, b));

                yield return(AssertProperty("Attributes", (r) => r.Attributes?.Count, a, b));
            }

            var jobComponent = new JobComponentConfig
            {
                ComponentId = componentId,
                JobId       = jobId,
                OutputMessageBrokerChannels = new[] { "channels.output1" },
                Attributes = new JObject()
            };
            await _componentRegistry.InsertJobComponentConfigAsync(jobComponent);

            var components = await _componentRegistry.GetAllComponentJobConfigsAsync(componentId);


            if (components.Count != 1)
            {
                throw new JmsAssertException("invalid amount of components retrieved");
            }

            var errors = assert(jobComponent, components[0]).Where(r => !(r is null));

            AssertErrors("Component Job config", errors);
        }