Example #1
0
        /// <summary>
        /// Initializes the mediated state based on input metadata for the state object and sequencer object
        /// </summary>
        /// <param name="metadata"></param>
        public ExecutionContext(ExecutionContextMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            //create the state object, set initialization arguments and reset
            state = (IState)Activator.CreateInstance(metadata.StateType);
            state.Initialize(metadata.StateArguments);

            //Create the Action Sequencer
            actionSequencer = (IActionSequencer)Activator.CreateInstance(metadata.ActionSequencerType);
        }
Example #2
0
        public StabilityTestDefinition(ContentPropertyBag payload)
        {
            string schedulerTypename = payload["SchedulerType"];

            SchedulerType = Type.GetType(schedulerTypename);
            if (SchedulerType == null)
            {
                throw new ArgumentException(string.Format("Requested SchedulerType '{0}' does not exist in assembly '{1}'.", schedulerTypename, Assembly.GetExecutingAssembly().FullName));
            }

            RandomSeed       = int.Parse(payload["Seed"]);
            NumWorkerThreads = int.Parse(payload["NumWorkerThreads"]);

            IsolateThreadsInAppdomains = bool.Parse(payload["IsolateThreadsInAppdomains"]);

            ExecutionContext                     = new ExecutionContextMetadata();
            ExecutionContext.StateType           = InitType(payload["StateAssembly"], payload["StateType"]);
            ExecutionContext.ActionSequencerType = InitType(payload["ActionAssembly"], payload["SequenceType"]);
            ExecutionContext.StateArguments      = PopulateStateArgs(ExecutionContext.StateType, payload);

            int timeInMinutes;

            if (!int.TryParse(payload["DurationInMinutes"], out timeInMinutes))
            {
                timeInMinutes = 900;
            }
            ExecutionTime = TimeSpan.FromMinutes(timeInMinutes);

            int idleDuration;

            if (!int.TryParse(payload["IdleDuration"], out idleDuration))
            {
                idleDuration = 200;
            }
            IdleDuration = TimeSpan.FromMilliseconds(idleDuration);
        }