// starts an task per given experiment, which create an experiment service in each case
        public async Task distributeExperimentSeries(IExperimentSeries eSeries,
                                                     String dockerImage,
                                                     String executionPath)
        {
            bool isOk = ((eSeries != null) && (dockerImage != null) && (executionPath != null));

            if (isOk)
            {
                IList <KeyValuePair <String, Task <KeyValuePair <String, String> > > > tasks = new List <KeyValuePair <String, Task <KeyValuePair <String, String> > > >();
                IList <IExperiment> experiments = eSeries.getExperiments().ToList();
                Console.WriteLine("Investigator: Start distributing experiment tasks of " +
                                  "series of experiment with id " + eSeries.getId());
                // create task per experiment
                foreach (IExperiment experiment in experiments)
                {
                    // wait 10 seconds until to the next task creation
                    Task.Delay(10000).Wait();
                    // create task
                    tasks.Add(new KeyValuePair <string, Task <KeyValuePair <string, string> > >(
                                  eSeries.getId() + ":::" + experiment.getId(),
                                  this.distributeExperimentAsync(eSeries.getId(),
                                                                 eSeries.getName(),
                                                                 eSeries.getDescription(),
                                                                 eSeries.getExperimentSoftware(),
                                                                 experiment, dockerImage, executionPath)));
                }
                // check if an created task faulted
                tasks.Where(x => x.Value.IsFaulted).ToList().ForEach(x =>
                {
                    String error = "Investigator: Task\n\t        " + x.Key +
                                   "\n\t      is faulted because:\n" +
                                   x.Value.Exception.Message;
                    Console.WriteLine(error);
                });
                // watch for state of experiment services:
                // remove, if faulted or finished successful - and display a message
                await startRemovePolling(tasks.Select(x => x.Value.Result).ToList());

                Console.WriteLine("Investigator: Experiment tasks of the series of experiment " +
                                  "with id " + eSeries.getId() + " were finished");
            }
            else
            {
                throw new ArgumentException("Arguments 'eSeries','dockerImage' and " +
                                            "'executionPath' must be not null.");
            }
        }
Exemple #2
0
        public void execute(IExperimentSeries experimentSeries)
        {
            var experiment = (IParameterList)experimentSeries.getExperiments();

            for (uint i = 0; i < experiment.count(); i++)
            {
                var parameter = experiment.get(i);
                if (parameter.getValue().isPrimitive())
                {
                }
                else
                {
                    for (int j = 0; j < ((IParameterList)parameter).count(); j++)
                    {
                    }
                }
            }
        }
Exemple #3
0
        public async Task distributeExperimentSeries(IExperimentSeries eSeries,
                                                     String dockerImage,
                                                     String executionPath)
        {
            bool isOk = ((eSeries != null) && (dockerImage != null) && (executionPath != null));

            if (isOk)
            {
                IList <KeyValuePair <String, Task <KeyValuePair <String, String> > > > tasks = new List <KeyValuePair <String, Task <KeyValuePair <String, String> > > >();
                IList <IExperiment> experiments = eSeries.getExperiments().ToList();
                Console.WriteLine("Investigator: Start distributing experiment tasks of " +
                                  "series of experiment with id " + eSeries.getId());
                //while(experiments.Count > 0)
                //{
                foreach (IExperiment experiment in experiments)
                {
                    tasks.Add(new KeyValuePair <string, Task <KeyValuePair <string, string> > >(
                                  eSeries.getId() + ":::" + experiment.getId(),
                                  this.distributeExperimentAsync(eSeries.getId(),
                                                                 eSeries.getName(),
                                                                 eSeries.getDescription(),
                                                                 eSeries.getExperimentSoftware(),
                                                                 experiment, dockerImage, executionPath)));
                }
                //Task.Delay(3000).Wait();
                tasks.Where(x => x.Value.IsFaulted).ToList().ForEach(x =>
                {
                    String error = "Investigator: Task\n\t        " + x.Key +
                                   "\n\t      is faulted because:\n" +
                                   x.Value.Exception.Message;
                    Console.WriteLine(error);
                });
                // IList<String> faultedTasks = tasks.Where(x => x.Value.IsFaulted)
                //                                   .Select(x => x.Key).ToList();
                // experiments = experiments.Where(x =>
                // {
                //     bool isSelected = false;
                //     String identifier = eSeries.getId() + ":::" + x.getId();
                //     foreach(String brokenIdentifier in faultedTasks) {
                //         if (String.Compare(identifier, brokenIdentifier) == 0)
                //             isSelected = true;
                //     }
                //     return isSelected;
                // }).ToList();
                //}
                // foreach(IExperiment experiment in eSeries.getExperiments())
                // {
                //     tasks.Add(this.distributeExperimentAsync(eSeries.getId(),
                //                                            eSeries.getName(),
                //                                            eSeries.getDescription(),
                //                                            eSeries.getExperimentSoftware(),
                //                                            experiment, dockerImage, executionPath));
                // }
                await startRemovePolling(tasks.Select(x => x.Value.Result).ToList());

                Console.WriteLine("Investigator: Experiment tasks of the series of experiment " +
                                  "with id " + eSeries.getId() + " were finished");
            }
            else
            {
                throw new ArgumentException("Arguments 'eSeries','dockerImage' and " +
                                            "'executionPath' must be not null.");
            }
        }