예제 #1
0
        public override void Validate(ParallelLoopState loopState, SystemManifest manifest, string machineName)
        {
            TraceFactory.Logger.Debug("Validating activities for {0} on Machine {1}".FormatWith(Id, machineName));
            Parallel.ForEach <ResourceMetadata>(Metadata, (m, l) => m.Validate(l, Id, manifest, machineName));
            if (SessionMapElement.AnyElementsSetTo <ResourceMetadata>(Metadata, RuntimeState.Error))
            {
                var elements = SessionMapElement.GetElements <ResourceMetadata>(RuntimeState.Error, Metadata).Select(x => x.Detail.Name);
                TraceFactory.Logger.Debug("Metadata in ERROR: {0}".FormatWith(string.Join(", ", elements.ToArray())));

                TraceFactory.Logger.Debug("Activity validation failed for {0}".FormatWith(Id));
                MapElement.UpdateStatus("Activity validation failed", RuntimeState.Error);
                loopState.Break();
                return;
            }
            else if (SessionMapElement.AnyElementsSetTo <ResourceMetadata>(Metadata, RuntimeState.Warning))
            {
                var elements = SessionMapElement.GetElements <ResourceMetadata>(RuntimeState.Warning, Metadata).Select(x => x.Detail.Name);
                TraceFactory.Logger.Debug("Metadata in WARNING: {0}".FormatWith(string.Join(", ", elements.ToArray())));

                TraceFactory.Logger.Debug("Activity validation caused a warning for {0}".FormatWith(Id));
                MapElement.UpdateStatus("Activity validation caused a warning", RuntimeState.Warning);
                return;
            }
            MapElement.UpdateStatus("Validated", RuntimeState.Validated);
        }
예제 #2
0
        /// <summary>
        /// Initializes this asset
        /// </summary>
        public virtual void Validate(ParallelLoopState loopState)
        {
            Thread.CurrentThread.SetName("Validate-{0}".FormatWith(Thread.CurrentThread.ManagedThreadId));

            MapElement.UpdateStatus("Validating", RuntimeState.Validating);

            try
            {
                TraceFactory.Logger.Debug("Validating host {0}".FormatWith(Machine.Name));
                Machine.Validate();

                // In case a new Machine was chosen, update the name of the map element to be consistent.
                MapElement.Name = Machine.Name;
                MapElement.UpdateStatus();
                Manifest.HostMachine = Machine.Name;
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error(ex);
                MapElement.UpdateStatus(ex.Message, RuntimeState.Error);
                loopState.Break();
                return;
            }

            TraceFactory.Logger.Debug("Now validating each resource running on {0}".FormatWith(Machine.Name));

            Parallel.ForEach <ResourceInstance>(Resources, (r, l) => r.Validate(l, Manifest, Machine.Name));

            if (SessionMapElement.AnyElementsSetTo <ResourceInstance>(Resources, RuntimeState.Error))
            {
                var elements = SessionMapElement.GetElements <ResourceInstance>(RuntimeState.Error, Resources).Select(x => x.Id);
                TraceFactory.Logger.Debug("Resources in ERROR: {0}".FormatWith(string.Join(", ", elements.ToArray())));

                TraceFactory.Logger.Debug("Resource validation for {0}".FormatWith(Machine.Name));
                MapElement.UpdateStatus("Resource validation failed", RuntimeState.Error);
                loopState.Break();
                return;
            }
            else if (SessionMapElement.AnyElementsSetTo <ResourceInstance>(Resources, RuntimeState.Warning))
            {
                var elements = SessionMapElement.GetElements <ResourceInstance>(RuntimeState.Warning, Resources).Select(x => x.Id);
                TraceFactory.Logger.Debug("Resources in WARNING: {0}".FormatWith(string.Join(", ", elements.ToArray())));

                TraceFactory.Logger.Debug("Resource validation caused warning on {0}".FormatWith(Machine.Name));
                MapElement.UpdateStatus("Resource validation caused a warning", RuntimeState.Warning);
                return;
            }

            MapElement.UpdateStatus("Validated", RuntimeState.Validated);
        }
예제 #3
0
        /// <summary>
        /// Revalidates the state
        /// </summary>
        /// <param name="loopState"></param>
        public override void Revalidate(ParallelLoopState loopState)
        {
            try
            {
                MapElement.UpdateStatus("Validating", RuntimeState.Validating);
                Parallel.ForEach <AssetHost>(Hosts, (h, l) => h.Revalidate(l)); // Used to call Validate()
                if (SessionMapElement.AnyElementsSetTo(Hosts, RuntimeState.Error, RuntimeState.AggregateError))
                {
                    TraceFactory.Logger.Debug("Some elements not validated");
                    MapElement.UpdateStatus(RuntimeState.AggregateError);
                    loopState.Break();
                    return;
                }

                MapElement.UpdateStatus("Validated", RuntimeState.Validated);
            }
            catch (AggregateException ex)
            {
                // Log the exception at this element level, the throw again to catch it higher
                MapElement.UpdateStatus(RuntimeState.Error, "Validation error", ex);
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes all components in this map.
        /// </summary>
        /// <param name="loopState">State of the loop.</param>
        public override void Validate(ParallelLoopState loopState)
        {
            try
            {
                MapElement.UpdateStatus("Validating", RuntimeState.Validating);

                Parallel.ForEach <RemotePrintQueueElement>(RemotePrintQueueElements, (h, l) => h.Validate(l));

                if (SessionMapElement.AnyElementsSetTo(RemotePrintQueueElements, RuntimeState.Error, RuntimeState.AggregateError))
                {
                    TraceFactory.Logger.Error("Some elements not validated");
                    MapElement.UpdateStatus(RuntimeState.AggregateError);
                    loopState.Break();
                    return;
                }

                MapElement.UpdateStatus("Validated", RuntimeState.Validated);
            }
            catch (AggregateException ex)
            {
                MapElement.UpdateStatus(RuntimeState.Error, "Validation error", ex);
                throw;
            }
        }