Пример #1
0
        public int Execute(string[] args, CancellationToken ct)
        {
            try
            {
                ValidateArgs(args);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(GetUsage());
                return(1);
            }

            try
            {
                InitPackages(Storage.StorageCredentials.FromConfiguration());

                var jobParameters = GetJobParametersFromArgs(args);

                var apsim = new ParallelAPSIM(
                    Storage.StorageCredentials.FromConfiguration(),
                    Batch.BatchCredentials.FromConfiguration(),
                    Batch.PoolSettings.FromConfiguration());

                var jobId = apsim.SubmitJob(jobParameters, ct);

                if (!jobParameters.NoWait)
                {
                    var baseOutputPath = Path.Combine(Directory.GetCurrentDirectory(), "Outputs");
                    var jobOutput      = new JobOutputMonitor();
                    jobOutput.Execute(jobId, baseOutputPath, ct);
                }
            }
            catch (OperationCanceledException)
            {
                return(1);
            }
            catch (AggregateException e)
            {
                var unwrapped = ExceptionHelper.UnwrapAggregateException(e);
                Console.WriteLine(unwrapped.Message);
                Console.WriteLine(unwrapped.StackTrace);
                return(1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                return(1);
            }

            return(0);
        }
Пример #2
0
        public int Execute(string[] args, CancellationToken ct)
        {
            try
            {
                ValidateArgs(args);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(GetUsage());
                return(1);
            }

            try
            {
                var apsim = new ParallelAPSIM(
                    Storage.StorageCredentials.FromConfiguration(),
                    Batch.BatchCredentials.FromConfiguration(),
                    Batch.PoolSettings.FromConfiguration());

                var tasks = apsim.ListTasks(Guid.Parse(args[0]), ct);

                foreach (var task in tasks)
                {
                    var duration = task.Duration.HasValue ? Convert.ToInt32(task.Duration.Value.TotalMinutes) + " minute(s)" : "";

                    Console.WriteLine("TaskId: {0}", task.Id);
                    Console.WriteLine("    Task Info");
                    Console.WriteLine("        Description: {0}", task.DisplayName);
                    Console.WriteLine("        State: {0}", task.State);
                    Console.WriteLine("        StartTime: {0}", task.StartTime != null ? task.StartTime.Value.ToString() : "");
                    Console.WriteLine("        EndTime: {0}", task.EndTime != null ? task.EndTime.Value.ToString() : "");
                    Console.WriteLine("        Duration: {0}", duration);
                    Console.WriteLine("");
                }
            }
            catch (AggregateException e)
            {
                var unwrapped = ExceptionHelper.UnwrapAggregateException(e);
                Console.WriteLine(unwrapped.Message);
                Console.WriteLine(unwrapped.StackTrace);
                return(1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                return(1);
            }

            return(0);
        }
        public int Execute(string[] args, CancellationToken ct)
        {
            try
            {
                ValidateArgs(args);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(GetUsage());
                return(1);
            }

            try
            {
                var apsim = new ParallelAPSIM(
                    Storage.StorageCredentials.FromConfiguration(),
                    Batch.BatchCredentials.FromConfiguration(),
                    Batch.PoolSettings.FromConfiguration());

                apsim.TerminateJob(Guid.Parse(args[0]));
            }
            catch (AggregateException e)
            {
                var unwrapped = ExceptionHelper.UnwrapAggregateException(e);
                Console.WriteLine(unwrapped.Message);
                Console.WriteLine(unwrapped.StackTrace);
                return(1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                return(1);
            }

            return(0);
        }
Пример #4
0
        public void Test()
        {
            var apsim = new ParallelAPSIM(
                Storage.StorageCredentials.FromConfiguration(),
                Batch.BatchCredentials.FromConfiguration(),
                Batch.PoolSettings.FromConfiguration());

            var jobId = apsim.SubmitJob(GetJobParameters(), CancellationToken.None);

            var args = new[]
            {
                "job-manager",
                _batchUrl,
                _batchAccount,
                _batchKey,
                _storageAccount,
                _storageKey,
                jobId.ToString(),
                "D:\\APSIM_Test_Small\\Input"
            };

            Program.Main(args);
        }
Пример #5
0
        public void TestCanSubmitTasks()
        {
            var apsim = new ParallelAPSIM(
                Storage.StorageCredentials.FromConfiguration(),
                Batch.BatchCredentials.FromConfiguration(),
                Batch.PoolSettings.FromConfiguration());

            var jobId = apsim.SubmitJob(GetJobParameters(), CancellationToken.None);

            var taskProvider = new TaskProvider(
                new StorageCredentials {
                Account = _storageAccount, Key = _storageKey
            },
                _inputZip,
                1);

            var jobManager = new JobManager(
                new BatchCredentials {
                Url = _batchUrl, Account = _batchAccount, Key = _batchKey
            },
                taskProvider);

            jobManager.Execute(jobId, true, false, CancellationToken.None);
        }
Пример #6
0
        public int Execute(string[] args, CancellationToken ct)
        {
            try
            {
                ValidateArgs(args);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(GetUsage());
                return(1);
            }

            try
            {
                var apsim = new ParallelAPSIM(
                    Storage.StorageCredentials.FromConfiguration(),
                    Batch.BatchCredentials.FromConfiguration(),
                    Batch.PoolSettings.FromConfiguration());

                var jobs = apsim.ListJobs(ct);

                foreach (var job in jobs)
                {
                    var duration = job.Duration.HasValue ? Convert.ToInt32(job.Duration.Value.TotalMinutes) + " minute(s)" : "";

                    Console.WriteLine("JobId: {0}", job.Id);
                    Console.WriteLine("    Job Info");
                    Console.WriteLine("        Description: {0}", job.DisplayName);
                    Console.WriteLine("        State: {0}", job.State);
                    Console.WriteLine("        StartTime: {0}", job.StartTime != null ? job.StartTime.Value.ToString() : "");
                    Console.WriteLine("        EndTime: {0}", job.EndTime != null ? job.EndTime.Value.ToString() : "");
                    Console.WriteLine("        Duration: {0}", duration);

                    Console.WriteLine("    Pool Info");
                    if (job.PoolSettings != null)
                    {
                        Console.WriteLine("        VM Count: {0}", job.PoolSettings.VMCount);
                        Console.WriteLine("        VM Size: {0}", job.PoolSettings.VMSize);
                        Console.WriteLine("        Allocation State: {0}", job.PoolSettings.State);
                    }
                    else
                    {
                        Console.WriteLine("        Not available");
                    }

                    Console.WriteLine("");
                }
            }
            catch (AggregateException e)
            {
                var unwrapped = ExceptionHelper.UnwrapAggregateException(e);
                Console.WriteLine(unwrapped.Message);
                Console.WriteLine(unwrapped.StackTrace);
                return(1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                return(1);
            }

            return(0);
        }