示例#1
0
        public async Task <IActionResult> OnPostGetCurrentInfoForJobAsync()
        {
            try
            {
                string username = "******";
                string password = "******";

                //AuthenticateUserPassword
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                //GetCurrentInfoForJob
                SubmittedJobInfoExt submittedJobInfo = await GetCurrentInfoForJobAsync(lastSubmittedJobId, sessionCode);

                sb.AppendLine(String.Format("Job {0} info:", submittedJobInfo.Id));
                sb.AppendLine(submittedJobInfo.ToString());

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }

            return(Page());
        }
示例#2
0
        private static async void MonitorJob(SubmittedJobInfoExt submittedJob, string sessionCode)
        {
            bool jobDone = false;

            while (!jobDone)
            {
                submittedJob = await GetCurrentInfoForJobAsync((long)submittedJob.Id, sessionCode);

                switch (submittedJob.State)
                {
                case JobStateExt.Canceled:
                    //DeleteJob
                    sb.AppendLine(String.Format("Cleaning job {0} ...", submittedJob.Id));
                    string deleteJobResponse = await DeleteJobAsync((long)submittedJob.Id, sessionCode);

                    sb.AppendLine(deleteJobResponse);
                    sb.AppendLine(String.Format("Job {0} was canceled.", submittedJob.Id));
                    jobDone = true;
                    break;

                case JobStateExt.Failed:
                    //DeleteJob
                    sb.AppendLine(String.Format("Cleaning job {0} ...", submittedJob.Id));
                    deleteJobResponse = await DeleteJobAsync((long)submittedJob.Id, sessionCode);

                    sb.AppendLine(deleteJobResponse);
                    sb.AppendLine(String.Format("Job {0} failed.", submittedJob.Id));
                    jobDone = true;
                    break;

                case JobStateExt.Running:
                    //    DownloadStdOutAndErrFiles((long)submittedJob.id, sessionCode, (long)submittedJob.tasks.First().id);
                    break;

                case JobStateExt.Finished:
                    //Download output files
                    sb.AppendLine(String.Format("Downloading output files..."));
                    DownloadOutputFilesAsync((long)submittedJob.Id, sessionCode);
                    sb.AppendLine(String.Format("Output files downloaded."));
                    //DeleteJob
                    sb.AppendLine(String.Format("Cleaning job {0} ...", submittedJob.Id));
                    deleteJobResponse = await DeleteJobAsync((long)submittedJob.Id, sessionCode);

                    sb.AppendLine(String.Format("Job {0} finished.", submittedJob.Id));
                    jobDone = true;
                    break;

                default:
                    Thread.Sleep(30000);
                    break;
                }
            }
        }
示例#3
0
        public async Task <IActionResult> OnPostCreateAndSubmitASBJobAsync()
        {
            try
            {
                string username = "******";
                string password = "******";

                //AuthenticateUserPassword
                sb.AppendLine(String.Format("username: {0}, password: {1}", username, password));
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                //string sessionCode = AuthenticateUserKeycloakOpenId(openIdToken);
                sb.AppendLine(String.Format("sessionCode: {0}", sessionCode));

                //CancelJob(2, sessionCode);

                //CreateJobSpecification
                JobSpecificationExt jobSpec = CreateJobSpecification();
                sb.AppendLine(String.Format("JobSpecification created"));
                sb.AppendLine(jobSpec.ToString());

                //CreateJob
                SubmittedJobInfoExt submittedJob = await CreateJobAsync(jobSpec, sessionCode);

                sb.AppendLine(String.Format("Job {0} created", submittedJob.Id));
                sb.AppendLine(submittedJob.ToString());

                //FileUpload
                //UploadInputFiles((long)submittedJob.Id, submittedJob.Tasks?.Select(s => s.Id).ToList(), sessionCode);
                //sb.AppendLine(String.Format("All files uploaded"));

                //SubmitJob
                SubmitJobAsync((long)submittedJob.Id, sessionCode);
                sb.AppendLine(String.Format("Job submitted"));

                AsbSubmittedJob = (long)submittedJob.Id;

                while (submittedJob.State != JobStateExt.Running)
                {
                    Thread.Sleep(30000);
                    submittedJob = await GetCurrentInfoForJobAsync((long)submittedJob.Id, sessionCode);
                }

                sb.AppendLine(String.Format("Job is running"));

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }
            return(Page());
        }
示例#4
0
        public async Task <IActionResult> OnPostCreateAndSubmitTestJobAsync()
        {
            string response = "";

            try
            {
                string username    = "******";
                string password    = "******";
                string openIdToken = ""; // Fill the OpenId token for testing.

                //AuthenticateUserPassword
                sb.AppendLine(String.Format("username: {0}, password: {1}", username, password));
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                //string sessionCode = AuthenticateUserKeycloakOpenId(openIdToken);
                sb.AppendLine(String.Format("sessionCode: {0}", sessionCode));

                //CreateJobSpecification
                JobSpecificationExt jobSpec = CreateJobSpecification();
                sb.AppendLine(String.Format("JobSpecification created"));
                sb.AppendLine(jobSpec.ToString());

                //CreateJob
                SubmittedJobInfoExt submittedJob = await CreateJobAsync(jobSpec, sessionCode);

                sb.AppendLine(String.Format("Job {0} created", submittedJob.Id));
                sb.AppendLine(submittedJob.ToString());

                //FileUpload
                UploadInputFilesAsync((long)submittedJob.Id, submittedJob.Tasks?.Select(s => s.Id).ToList(), sessionCode);
                sb.AppendLine(String.Format("All files uploaded"));

                //SubmitJob
                SubmitJobAsync((long)submittedJob.Id, sessionCode);
                sb.AppendLine(String.Format("Job submitted"));

                //MonitorJob
                lastSubmittedJobId = (long)submittedJob.Id; //TODO remove later - only for getCurrentJobInfo
                MonitorJob(submittedJob, sessionCode);

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }
            return(Page());
        }
示例#5
0
        private static async Task <SubmittedJobInfoExt> SubmitJobAsync(long jobId, string sessionCode)
        {
            var client  = new RestClient(baseUrl);
            var request = new RestRequest("JobManagement/SubmitJob", Method.Post)
            {
                RequestFormat = DataFormat.Json
            }.AddJsonBody(
                new SubmitJobModel
            {
                CreatedJobInfoId = jobId,
                SessionCode      = sessionCode
            });
            var response = await client.ExecuteAsync(request);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new Exception(response.Content.ToString());
            }

            SubmittedJobInfoExt jobInfo = JsonConvert.DeserializeObject <SubmittedJobInfoExt>(response.Content.ToString());

            return(jobInfo);
        }
示例#6
0
        public async Task <IActionResult> OnPostTestSubmitAndCancelJobAsync()
        {
            try
            {
                string username = "******";
                string password = "******";

                //AuthenticateUserPassword
                sb.AppendLine(String.Format("username: {0}, password: {1}", username, password));
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                sb.AppendLine(String.Format("sessionCode: {0}", sessionCode));

                //CreateJobSpecification
                JobSpecificationExt jobSpec = CreateJobSpecification();
                sb.AppendLine(String.Format("JobSpecification created"));
                sb.AppendLine(jobSpec.ToString());

                //CreateJob
                SubmittedJobInfoExt submittedJob = await CreateJobAsync(jobSpec, sessionCode);

                sb.AppendLine(String.Format("Job {0} created", submittedJob.Id));
                sb.AppendLine(submittedJob.ToString());

                //FileUpload
                UploadInputFilesAsync((long)submittedJob.Id, submittedJob.Tasks?.Select(s => s.Id).ToList(), sessionCode);
                sb.AppendLine(String.Format("All files uploaded"));

                //SubmitJob
                SubmitJobAsync((long)submittedJob.Id, sessionCode);
                sb.AppendLine(String.Format("Job submitted"));

                //TODO DELETE LATER - only for getCurrentInfoForJob
                lastSubmittedJobId = (long)submittedJob.Id;

                //wait for job to be in running state and then cancel this job and delete job content on cluster
                while (true)
                {
                    submittedJob = await GetCurrentInfoForJobAsync((long)submittedJob.Id, sessionCode);

                    if (submittedJob.State == JobStateExt.Running)
                    {
                        sb.AppendLine(String.Format("Job {0} state: {1}", submittedJob.Id, submittedJob.State));

                        //CancelJob
                        sb.AppendLine(String.Format("Canceling job {0} ...", submittedJob.Id));
                        submittedJob = await CancelJobAsync((long)submittedJob.Id, sessionCode);

                        sb.AppendLine(String.Format("Job {0} was canceled.", submittedJob.Id));

                        //DeleteJob
                        sb.AppendLine(String.Format("Deleting job {0} ...", submittedJob.Id));
                        string deleteJobResponse = await DeleteJobAsync((long)submittedJob.Id, sessionCode);

                        sb.AppendLine(deleteJobResponse);

                        break;
                    }
                    Thread.Sleep(30000);
                }

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }

            return(Page());
        }