public void Main(string[] args)
        {
            var binaryFilePath = Path.Combine(Path.GetDirectoryName(_applicationEnvironment.ApplicationBasePath), "SimpleTaskRunner\\bin\\debug");
            var dataFilePath = Path.Combine(_applicationEnvironment.ApplicationBasePath, "Data");
            var container = GetCloudBlobContainer(_configuration.GetSection("AppSettings:StorageConnectionString").Value, "batch");

            var taskDefiniton = new ComputeTaskDefinition
            {
                BinaryFilePath = binaryFilePath,
                DataFilePath = dataFilePath,
                StorageUri = container.Uri,
                ExecutableName = "SimpleTaskRunner.exe"
            };

            var computeTasks = new List<IComputeTask>
            {
                new ComputeTask("task-1", taskDefiniton).AddArguments(new InputComputeTaskArgument("taskdata1.txt"), new SimpleComputeTaskArgument("3")),
                new ComputeTask("task-2", taskDefiniton).AddArguments(new InputComputeTaskArgument("taskdata2.txt"), new SimpleComputeTaskArgument("3")),
                new ComputeTask("task-3", taskDefiniton).AddArguments(new InputComputeTaskArgument("taskdata3.txt"), new SimpleComputeTaskArgument("3"))
            }.ToArray();

            var computeJob = new ComputeJob("job-1") { ComputeTasks = computeTasks };

            Console.WriteLine("Prepared the files. Press Enter to continue.");
            Console.ReadLine();

            var jobInstance = new JobInstance(_scheduler, container);
            jobInstance.OnScheduleRequested(computeJob);
            jobInstance.PrepareJob();
            jobInstance.Execute();
            jobInstance.ProcessResults();
            //jobInstance.Cleanup();
        }
        public void AddTask(ComputeJob computeJob, IComputeTask computeTask)
        {
            using (var client = BatchClient.Open(_credentials))
            {
                var cloudJob = client.JobOperations.GetJob(computeJob.Id);

                AddTasks(client, cloudJob, computeJob.Id, new[] { computeTask });
            }
        }
        public void BeginJob(ComputeJob computeJob)
        {
            var poolId = CreatePoolIfRequired();

            using (var client = BatchClient.Open(_credentials))
            {
                var cloudJob = client.JobOperations.ListJobs().SingleOrDefault(j => j.Id == computeJob.Id);

                if (cloudJob == null)
                {
                    cloudJob = client.JobOperations.CreateJob();
                    cloudJob.Id = computeJob.Id;
                    cloudJob.PoolInformation = new PoolInformation { PoolId = poolId };
                    cloudJob.Commit();
                }

                _jobIdToPoolId.Add(computeJob, poolId);
                _pools[poolId].Add(computeJob);

                AddTasks(client, cloudJob, computeJob.Id, computeJob.ComputeTasks);
            }
        }
        public void DeleteJob(ComputeJob computeJob)
        {
            using (var client = BatchClient.Open(_credentials))
            {
                client.JobOperations.DeleteJob(computeJob.Id);

                var poolId = _jobIdToPoolId[computeJob];
                _jobIdToPoolId.Remove(computeJob);

                DeletePoolIfRequired(poolId);
            }
        }
Beispiel #5
0
 public void OnScheduleRequested(ComputeJob computeJob)
 {
     _computeJob = computeJob;
 }
 public void OnScheduleRequested(ComputeJob computeJob)
 {
     _computeJob = computeJob;
 }