/// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// Uses Composite Component Metadata config values to override Components config values in subgraph.
        /// </summary>
        /// <param name="id">The id of the node.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment;
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment</param>
        /// <returns>
        /// Created node
        /// </returns>
        public override RunnableNode CreateNode(String id, Metadata metadata, LoggerNameRoot loggerNameRoot, ComponentsLibrary library,
                                                AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata originalComponentMetadata = metadata as ComponentMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;

            if (originalComponentMetadata != null)
            {
                ComponentMetadata overrideComponentMetadata = (ComponentMetadata)originalComponentMetadata.Clone();
                OverrideConfigValues(id, overrideComponentMetadata);
                retNode = base.CreateNode(id, overrideComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                OverrideConfigValues(id, compositeComponentMetadata);
                retNode = base.CreateCompositeComponentNode(id, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else
            {
                retNode = base.CreateNode(id, metadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }

            return retNode;
        }
        /// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// </summary>
        /// <param name="nodeId">The node id.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment; 
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment.</param>
        /// <returns>
        /// Created node
        /// </returns>
        public virtual RunnableNode CreateNode(String nodeId, Metadata metadata, LoggerNameRoot loggerNameRoot, 
                                               ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata componentMetadata = metadata as ComponentMetadata;
            DecisionMetadata decisionMetadata = metadata as DecisionMetadata;
            StartNodeMetadata startNodeMetadata = metadata as StartNodeMetadata;
            EndNodeMetadata endNodeMetadata = metadata as EndNodeMetadata;
            ScopeBaseMetadata scopeMetadata = metadata as ScopeBaseMetadata;
            LoopScopeMetadata loopMetadata = metadata as LoopScopeMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;
            ExitDecisionMetadata exitDecisionMetadata = metadata as ExitDecisionMetadata;
            if (componentMetadata != null)
            {
                TraceLabSDK.ComponentLogger logger = TraceLab.Core.Components.LoggerFactory.CreateLogger(loggerNameRoot, nodeId, componentMetadata);
                IComponent component = library.LoadComponent(componentMetadata, Workspace, logger, componentsAppDomain);
                retNode = new RunnableComponentNode(nodeId, componentMetadata.Label, component, logger, library, componentMetadata.WaitsForAllPredecessors);
            }
            else if (decisionMetadata != null)
            {
                IDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(decisionMetadata, Workspace, componentsAppDomain);
                retNode = new RunnableDecisionNode(nodeId, decisionMetadata.Label, decisionModule, library, decisionMetadata.WaitsForAllPredecessors);
            }
            else if (startNodeMetadata != null)
            {
                retNode = new RunnableStartNode(nodeId);
            }
            else if (endNodeMetadata != null)
            {
                retNode = new RunnableEndNode(nodeId, endNodeMetadata.WaitsForAllPredecessors);
            }
            else if (loopMetadata != null)
            {
                retNode = CreateLoopNode(nodeId, loopMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (scopeMetadata != null)
            {
                retNode = CreateScopeCompositeComponentNode(nodeId, scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                retNode = CreateCompositeComponentNode(nodeId, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (exitDecisionMetadata != null)
            {
                retNode = new RunnablePrimitiveNode(nodeId, exitDecisionMetadata.WaitsForAllPredecessors);
            }
            else
            {
                throw new Exceptions.InconsistentTemplateException("Could not identify node type.");
            }

            return retNode;
        }
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            base.CopyFrom(other);

            ComponentTemplateMetadata metadata = (ComponentTemplateMetadata)other;
            m_IOSpec = metadata.m_IOSpec.Clone();
                        
            HasDeserializationError = metadata.HasDeserializationError;
            if (HasDeserializationError)
            {
                DeserializationErrorMessage = metadata.DeserializationErrorMessage;
            }
        }
        public RunnableNode CreateNode(string id, Metadata metadata, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            StartNodeMetadata startNodeMetadata = metadata as StartNodeMetadata;
            EndNodeMetadata endNodeMetadata = metadata as EndNodeMetadata;
            ComponentMetadata componentMetadata = metadata as ComponentMetadata;

            if (startNodeMetadata != null)
            {
                return new RunnableStartNode(id);
            }
            else if (endNodeMetadata != null)
            {
                return new RunnableEndNode(id, endNodeMetadata.WaitsForAllPredecessors);
            }
            else if (componentMetadata != null)
            {
                //mock failure
                if (componentMetadata.Label.Equals("Broken Component"))
                {
                    throw new ArgumentException("Failed");
                }

                //otherwise create a mock node and keep reference
                MockNode mockNode = new MockNode(id);
                CreatedNodes.Add(mockNode);

                return mockNode;
            }
            else
            {
                throw new ArgumentException("Could not identify node type.");
            }
        }
 public RunnableNode CreateNode(string id, Metadata metadata, LoggerNameRoot loggerNameRoot, TraceLab.Core.Components.ComponentsLibrary library, AppDomain componentsAppDomain,
     System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
 {
     return CreateNode(id, metadata, terminateExperimentExecutionResetEvent);
 }
Example #6
0
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            base.CopyFrom(other);

            CommentMetadata metadata = (CommentMetadata)other;
            m_comment = metadata.Comment;
        }
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");
            
            base.CopyFrom(other);

            CompositeComponentMetadata metadata = (CompositeComponentMetadata)other;
            m_IOSpec = metadata.m_IOSpec.Clone();
            m_configWrapper = metadata.m_configWrapper.Clone();
            m_experimentLocationRoot = metadata.m_experimentLocationRoot;
            m_compositeComponentMetadataDefinition = metadata.m_compositeComponentMetadataDefinition;
            m_componentMetadataDefinitionID = metadata.m_componentMetadataDefinitionID;

            HasDeserializationError = metadata.HasDeserializationError;
            if (HasDeserializationError)
            {
                DeserializationErrorMessage = metadata.DeserializationErrorMessage;
            } 

            // if composite component was not present in the library, then corresponding component graph may be null.
            // the deserialization has already set the corresponding error above, nevertheless subgraph cannot be cloned obviously
            if (HasDeserializationError == false && metadata.m_compositeComponentGraph != null)
            {
                m_compositeComponentGraph = (CompositeComponentGraph)(metadata.m_compositeComponentGraph.Clone());
            }

            m_tempConfigWrapper = metadata.m_tempConfigWrapper;
            m_tempIoSpec = metadata.m_tempIoSpec;
            m_tempLabel = metadata.m_tempLabel;
        }
Example #8
0
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <remarks>All fields and properties are copied.</remarks>
        protected virtual void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            Label = other.Label;
            WaitsForAllPredecessors = other.WaitsForAllPredecessors;
            DeserializationErrorMessage = other.DeserializationErrorMessage;
            HasDeserializationError = other.HasDeserializationError;

            LogLevelItemLookup = new Dictionary<NLog.LogLevel, LogLevelItem>();
            foreach (KeyValuePair<NLog.LogLevel, LogLevelItem> pair in other.LogLevelItemLookup)
            {
                LogLevelItemLookup.Add(pair.Key, new LogLevelItem(pair.Value.Level, pair.Value.IsEnabled, pair.Value.IsLocked));
            }
        }
 /// <summary>
 /// Adds the node.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="metadata">The metadata.</param>
 public override void AddNode(String id, Metadata metadata, LoggerNameRoot loggerNameRoot)
 {
     // adds a node to the graph
     RunnableNode node = m_nodesFactory.CreateNode(id, metadata, loggerNameRoot, Library, ComponentsAppDomain, TerminateExperimentExecutionResetEvent);
     if (node is RunnableStartNode)
     {
         //allow set only once
         if (m_startNode != null)
         {
             throw new TraceLab.Core.Exceptions.InconsistentTemplateException("Template cannot have two start nodes defined.");
         }
         m_startNode = node;
     }
     if (node is RunnableEndNode)
     {
         //allow set only once
         if (m_endNode != null)
         {
             throw new TraceLab.Core.Exceptions.InconsistentTemplateException("Template cannot have two end nodes defined.");
         }
         m_endNode = node;
     }
     m_nodes.Add(node);
 }
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            base.CopyFrom(other);

            ComponentMetadata metadata = (ComponentMetadata)other;
            m_IOSpec = metadata.m_IOSpec.Clone();
            m_configWrapper = metadata.m_configWrapper.Clone();
            m_experimentLocationRoot = metadata.m_experimentLocationRoot;
            m_componentMetadataDefinition = metadata.m_componentMetadataDefinition;
            m_componentMetadataDefinitionID = metadata.m_componentMetadataDefinitionID;

            HasDeserializationError = metadata.HasDeserializationError;
            if (HasDeserializationError)
            {
                DeserializationErrorMessage = metadata.DeserializationErrorMessage;
            }

            m_tempConfigWrapper = metadata.m_tempConfigWrapper;
            m_tempIoSpec = metadata.m_tempIoSpec;
            m_tempLabel = metadata.m_tempLabel;
        }
 /// <summary>
 /// Copies from.
 /// </summary>
 /// <param name="other">The other.</param>
 protected override void CopyFrom(Metadata other)
 {
     base.CopyFrom(other);
 }
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            base.CopyFrom(other);

            ScopeBaseMetadata metadata = (ScopeBaseMetadata)other;
            m_experimentLocationRoot = metadata.m_experimentLocationRoot;
            m_compositeComponentGraph = (CompositeComponentEditableGraph)(metadata.m_compositeComponentGraph.Clone());
            
            HasDeserializationError = metadata.HasDeserializationError;
            if (HasDeserializationError)
            {
                DeserializationErrorMessage = metadata.DeserializationErrorMessage;
            }
            
        }
 /// <summary>
 /// Adds the node.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="metadata">The metadata.</param>
 /// <param name="loggerNameRoot">The logger name root.</param>
 public abstract void AddNode(String id, Metadata metadata, LoggerNameRoot loggerNameRoot);
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            base.CopyFrom(other);

            LoopScopeMetadata metadata = (LoopScopeMetadata)other;
            UniqueDecisionID = metadata.UniqueDecisionID;
            CompilationStatus = metadata.CompilationStatus;
            IsCodeDirty = metadata.IsCodeDirty;
            DecisionCode = metadata.DecisionCode;
        }
Example #15
0
 private SerializedVertexData(SerializationInfo info, StreamingContext context)
 {
     m_x = (double)info.GetValue("m_x", typeof(double));
     m_y = (double)info.GetValue("m_y", typeof(double));
     m_metadata = (Metadata)info.GetValue("m_metadata", typeof(Metadata));
 }
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            base.CopyFrom(other);

            DecisionMetadata metadata = (DecisionMetadata)other;
            UniqueDecisionID = metadata.UniqueDecisionID;
            CompilationStatus = metadata.CompilationStatus;
            IsCodeDirty = metadata.IsCodeDirty;
            DecisionCode = metadata.DecisionCode;
        }