Example #1
0
        /// <summary>
        /// Method that waits for a jobDetails to complete.
        /// </summary>
        /// <param name="client">The Hadoop client to use.</param>
        /// <param name="jobId">The id of the job to wait for.</param>
        /// <param name="duration">The duration to wait before timing out.</param>
        /// <param name="cancellationToken">
        /// The Cancellation Token for the request.
        /// </param>
        /// <returns>An awaitable task that represents the action.</returns>
        public static async Task <JobDetails> WaitForJobCompletionAsync(
            this IJobSubmissionClient client, string jobId, TimeSpan duration, CancellationToken cancellationToken)
        {
            client.ArgumentNotNull("client");
            jobId.ArgumentNotNull("jobId");
            JobDetails jobDetailsResults = new JobDetails()
            {
                JobId = jobId, StatusCode = JobStatusCode.Unknown
            };
            var pollingInterval = GetPollingInterval();
            var startTime       = DateTime.UtcNow;
            var endTime         = DateTime.UtcNow;

            while (jobDetailsResults.IsNotNull() && ((endTime = DateTime.UtcNow) - startTime) < duration &&
                   !(jobDetailsResults.StatusCode == JobStatusCode.Completed || jobDetailsResults.StatusCode == JobStatusCode.Failed ||
                     jobDetailsResults.StatusCode == JobStatusCode.Canceled))
            {
                client.HandleClusterWaitNotifyEvent(jobDetailsResults);
                if (jobDetailsResults.StatusCode == JobStatusCode.Completed || jobDetailsResults.StatusCode == JobStatusCode.Failed)
                {
                    break;
                }
                Thread.Sleep(pollingInterval);
                jobDetailsResults = await GetJobWithRetry(client, jobId, cancellationToken);
            }

            if (jobDetailsResults.StatusCode != JobStatusCode.Completed && jobDetailsResults.StatusCode != JobStatusCode.Failed &&
                jobDetailsResults.StatusCode != JobStatusCode.Canceled && (endTime - startTime) >= duration)
            {
                throw new TimeoutException(string.Format(CultureInfo.InvariantCulture, "The requested task failed to complete in the allotted time ({0}).", duration));
            }

            return(jobDetailsResults);
        }
Example #2
0
        private static async Task <JobDetails> GetJobWithRetry(IJobSubmissionClient client, string jobId, CancellationToken cancellationToken)
        {
            JobDetails jobDetailsResults = null;
            var        pollingInterval   = GetPollingInterval();
            int        retryCount        = 0;

            while (jobDetailsResults.IsNull())
            {
                try
                {
                    jobDetailsResults = await client.GetJobAsync(jobId);

                    break;
                }
                catch (HttpLayerException)
                {
                    if (retryCount >= Constants.RetryCount)
                    {
                        throw;
                    }
                    cancellationToken.WaitForInterval(TimeSpan.FromMilliseconds(pollingInterval));
                    retryCount++;
                }
            }
            return(jobDetailsResults);
        }
Example #3
0
 public ActionResult EditJob(JobDetails jobdetails, int id, string jobtitle, string companyname, string address, HttpPostedFileBase upload,
                             string jobtype, string educationlevel, string languages, string vacancies, string salary, string jobrequirements)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jobdetails).State = EntityState.Modified;
         jobdetails             = db.JobDetails.Where(a => a.JobId == id).FirstOrDefault();
         jobdetails.JobTitle    = jobtitle;
         jobdetails.CompanyName = companyname;
         jobdetails.DateJob     = DateTime.Now;
         jobdetails.Address     = address;
         string path = Path.Combine(Server.MapPath("~/images"), upload.FileName);
         upload.SaveAs(path);
         jobdetails.JobImage        = upload.FileName;
         jobdetails.JobType         = jobtype;
         jobdetails.EducationLevel  = educationlevel;
         jobdetails.Languages       = languages;
         jobdetails.Salary          = salary;
         jobdetails.Vacancies       = vacancies;
         jobdetails.JobRequirements = jobrequirements;
         db.SaveChanges();
         return(RedirectToAction("Index1"));
     }
     else
     {
         ViewBag.Result = "something wrong please enter your info correctly";
     }
     return(View(jobdetails));
 }
Example #4
0
        public bool Update(JobDetails jobDetails)
        {
            bool retVal = false;

            try
            {
                using (IDbConnection dbConnect = Database.CreateOpenConnection())
                {
                    using (IDbCommand command =
                               Database.CreateStoredProcCommand(JobDetailsSP.UpdateJob.ToString(), dbConnect))
                    {
                        command.Parameters.Add(Database.CreateParameter("jId", jobDetails.JobId));
                        command.Parameters.Add(Database.CreateParameter("@StartD", jobDetails.StartTime));
                        command.Parameters.Add(Database.CreateParameter("@EndD", jobDetails.EndTime));

                        command.ExecuteNonQuery();
                        retVal = true;
                    }
                    dbConnect.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                retVal = false;
            }
            return(retVal);
        }
        public void NextTriggerMisfireThreshold_GetterAndSetter()
        {
            JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);

            jobDetails.NextTriggerMisfireThreshold = new TimeSpan(0, 1, 0);
            Assert.AreEqual(new TimeSpan(0, 1, 0), jobDetails.NextTriggerMisfireThreshold);
        }
        public async Task <IActionResult> Edit(int id, [Bind("JobId,JobTitle,Category,Location,Jobtype,MaxSalary,MinSalary,JobDescription,PayPeriod,NumberOfPosition,JobPostDate,JobExpiryDate,CompnayId")] JobDetails jobDetails)
        {
            if (id != jobDetails.JobId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobDetailsExists(jobDetails.JobId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompnayId"] = new SelectList(_context.CompanyDetails, "CompanyId", "CompanyId", jobDetails.CompnayId);
            return(View(jobDetails));
        }
Example #7
0
		public override void SetUp()
		{
			base.SetUp();

			mockJobStore = Mocks.CreateMock<IJobStore>();
			mockJobRunner = Mocks.CreateMock<IJobRunner>();
			mockLogger = Mocks.CreateMock<ILogger>();
			mockTrigger = Mocks.PartialMock<Trigger>();
			scheduler = new DefaultScheduler(mockJobStore, mockJobRunner);

			dummyJobData = new JobData();
			dummyJobSpec = new JobSpec("foo", "bar", "key", mockTrigger);
			dummyJobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);

			isWoken = false;

			// Ensure the scheduler is initialized.
			mockJobStore.RegisterScheduler(scheduler.Guid, scheduler.Name);
			Mocks.Replay(mockJobStore);
			scheduler.Initialize();
			Mocks.Verify(mockJobStore);
			Mocks.BackToRecord(mockJobStore);

			mockJobStore.UnregisterScheduler(scheduler.Guid);

			// Create a separate uninitialized scheduler for certain tests.
			uninitializedScheduler = new DefaultScheduler(mockJobStore, mockJobRunner);
		}
 private void ProcessGCode_EndGCode(GCodeFileWriter output_writer, JobDetails jobdetails, InternalPrinterProfile printerProfile)
 {
     foreach (var s in GCodeInitializationPreprocessor.GenerateEndGCode(jobdetails, printerProfile, true))
     {
         output_writer.Write(new GCode(s));
     }
 }
        public void ICanGetAJob()
        {
            var expectedJob = new JobDetails()
            {
                ExitCode = 12, Name = "some jobDetails", StatusCode = Hadoop.Client.JobStatusCode.Completed, JobId = "2345"
            };

            var factory  = new MockRemotePocoLayerFactory();
            var pocoMock = new MockRemotePoco {
                JobId = string.Empty, JobDetails = expectedJob
            };

            factory.Mock = pocoMock;

            ServiceLocator.Instance.Locate <IServiceLocationIndividualTestManager>().Override <IRemoteHadoopJobSubmissionPocoClientFactory>(factory);

            var creds = new BasicAuthCredential()
            {
                Password = "******",
                Server   = new Uri("http://somewhere"),
                UserName = "******"
            };

            var poco = new HDInsightJobSubmissionPocoClient(creds, GetAbstractionContext(), false, pocoMock.GetUserAgentString());
            var task = poco.GetJob("2345");

            task.Wait();

            Assert.AreEqual("2345", task.Result.JobId);
            Assert.IsTrue(pocoMock.GetJobCalled);
            Assert.AreEqual(expectedJob, task.Result);
        }
Example #10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Employeenumber,Payment,History,JobLevel,JobRole,JobSatisfaction,OverTime,AccessLevel")] JobDetails jobDetails)
        {
            if (id != jobDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobDetailsExists(jobDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobDetails));
        }
Example #11
0
        public Response Put(string jobId, [FromBody] JobDetails jobDetails)
        {
            if (jobId == null ||
                jobDetails == null)
            {
                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EParameterError);
                return(response);
            }

            // update the job base on input
            jobDetails.jobId = jobId;
            if (false == jobDetailsDao.Update(jobDetails))
            {
                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                return(response);
            }

            // TODO: update the address



            // TODO: inform job delivery company and driver if any changes


            response = Utility.Utils.SetResponse(response, true, Constant.ErrorCode.ESuccess);
            return(response);
        }
Example #12
0
		public void JobState_GetterAndSetter()
		{
			JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);

			jobDetails.JobState = JobState.Scheduled;
			Assert.AreEqual(JobState.Scheduled, jobDetails.JobState);
		}
        public JobDetails GetJobDetails(System.Guid jobid, bool extendedInfo)
        {
            var job = this.RestClients._JobRest.JobGet(this.Account, jobid);

            var jobinfo = new JobInfo(job, this.Account);

            var jobdetails = new JobDetails();

            jobdetails.JobInfo = jobinfo;

            jobdetails.StateAuditRecords = job.StateAuditRecords;
            jobdetails.Properties        = job.Properties;
            jobdetails.ErrorMessage      = job.ErrorMessage;
            jobdetails.LogFilePatterns   = job.LogFilePatterns;

            if (extendedInfo)
            {
                jobdetails.JobDetailsExtended            = new JobDetailsExtended();
                jobdetails.JobDetailsExtended.Statistics = this.RestClients._JobRest.GetStatistics(this.Account, jobid);

                // jobdetails.JobDetailsExtended.DebugDataPath = this.clients._JobRest.GetDebugDataPath(this.account, jobid);
            }

            return(jobdetails);
        }
Example #14
0
        public void CreationTimeUtc_GetterAndSetter()
        {
            JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);

            jobDetails.CreationTimeUtc = new DateTime(1970, 1, 1);
            DateTimeAssert.AreEqualIncludingKind(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), jobDetails.CreationTimeUtc);
        }
Example #15
0
        public IActionResult Get(string jobUuid)
        {
            var jobCol  = this.dbFactory.GetCollectionAsQueryable <JobSpec <dynamic> >(CollectionNames.Jobs);
            var jobSpec = jobCol.Where(j => j.Uuid == jobUuid).Select(j => new { Status = j.Status, Type = j.Type, Start = j.StartTimestamp, End = j.EndTimestamp, Children = j.Children }).FirstOrDefault();

            if (jobSpec == null)
            {
                var respData = new ApiResponse <JobDetails>();
                respData.Messages.Add("Not Found");
                return(this.NotFound(respData));
            }

            var messagesCol = this.dbFactory.GetCollectionAsQueryable <JobMessage>(CollectionNames.JobMessages);
            var messages    = messagesCol.Where(m => (m.JobUuid == jobUuid || m.MasterJobUuid == jobUuid) && m.Level > (ushort)JobMessageLevel.Debug)
                              .OrderBy(x => x.Timestamp)
                              .Select(m => m.Message)
                              .ToList();

            var details = new JobDetails
            {
                Uuid           = jobUuid,
                Status         = jobSpec.Status,
                Type           = jobSpec.Type,
                StartTimestamp = jobSpec.Start,
                EndTimestamp   = jobSpec.End,
            };

            details.Messages.AddRange(messages);

            return(this.Ok(new ApiResponse <JobDetails>
            {
                Result = details
            }));
        }
Example #16
0
        /// <summary>Add a row to the ListView.</summary>
        /// <param name="job">The job to use to populate the row.</param>
        private void AddRowToJobListView(JobDetails job)
        {
            if (!showMyJobsOnlyCheckbox.Checked ||
                string.Equals(job.Owner, Environment.UserName, StringComparison.InvariantCultureIgnoreCase))
            {
                filteredJobList.Add(job);
                string startTime = null;
                string endTime   = null;
                if (job.StartTime != null)
                {
                    startTime = ((DateTime)job.StartTime).ToLocalTime().ToString(dateFormat);
                }
                if (job.EndTime != null)
                {
                    endTime = ((DateTime)job.EndTime).ToLocalTime().ToString(dateFormat);
                }

                jobListView.AddRow(new object[]
                {
                    job.DisplayName,
                    job.Owner,
                    job.State,
                    job.NumSims.ToString(),
                    job.Progress.ToString("F0"),
                    startTime,
                    endTime,
                    job.Duration().ToString(timespanFormat),
                    job.CpuTime.ToString(timespanFormat)
                });
            }
        }
        public void TestExecuteFailure()
        {
            var details = new JobDetails <CheckScannerBatch>
            {
                Data = new CheckScannerBatch
                {
                    Name      = "batch123",
                    ProgramId = 111,
                    MinistryPlatformContactId = 222,
                    MinistryPlatformUserId    = 333
                },
                EnqueuedDateTime  = DateTime.Now,
                RetrievedDateTime = DateTime.Now.AddMinutes(1)
            };

            _checkScannerService.Setup(mocked => mocked.CreateDonationsForBatch(details.Data)).Throws(new Exception());
            _emailService.Setup(
                mocked => mocked.SendEmail(
                    It.Is <EmailCommunicationDTO>(
                        o =>
                        o.FromUserId == 333 && o.FromContactId == 222 && o.TemplateId == 456 && o.ToContactId == 222 && (int)o.MergeData["programId"] == 111 &&
                        o.MergeData["batchName"].Equals("batch123") && o.MergeData.ContainsKey("error")
                        ),
                    null));

            _fixture.Execute(details);
        }
        public void CreationTimeUtc_GetterAndSetter()
        {
            JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);

            jobDetails.CreationTimeUtc = new DateTime(1970, 1, 1);
            DateTimeAssert.AreEqualIncludingKind(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), jobDetails.CreationTimeUtc);
        }
        public void JobState_GetterAndSetter()
        {
            JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);

            jobDetails.JobState = JobState.Scheduled;
            Assert.AreEqual(JobState.Scheduled, jobDetails.JobState);
        }
        /// <summary>
        /// Method that waits for a jobDetails to complete.
        /// </summary>
        /// <param name="client">The Hadoop client to use.</param>
        /// <param name="jobId">The id of the job to wait for.</param>
        /// <param name="duration">The duration to wait before timing out.</param>
        /// <param name="cancellationToken">
        /// The Cancellation Token for the request.
        /// </param>
        /// <returns>An awaitable task that represents the action.</returns>
        public static async Task<JobDetails> WaitForJobCompletionAsync(
            this IJobSubmissionClient client, string jobId, TimeSpan duration, CancellationToken cancellationToken)
        {
            client.ArgumentNotNull("client");
            jobId.ArgumentNotNull("jobId");
            JobDetails jobDetailsResults = new JobDetails() { JobId = jobId, StatusCode = JobStatusCode.Unknown };
            var pollingInterval = GetPollingInterval();
            var startTime = DateTime.UtcNow;
            var endTime = DateTime.UtcNow;

            while (jobDetailsResults.IsNotNull() && ((endTime = DateTime.UtcNow) - startTime) < duration &&
                   !(jobDetailsResults.StatusCode == JobStatusCode.Completed || jobDetailsResults.StatusCode == JobStatusCode.Failed ||
                     jobDetailsResults.StatusCode == JobStatusCode.Canceled))
            {
                client.HandleClusterWaitNotifyEvent(jobDetailsResults);
                if (jobDetailsResults.StatusCode == JobStatusCode.Completed || jobDetailsResults.StatusCode == JobStatusCode.Failed)
                {
                    break;
                }
                Thread.Sleep(pollingInterval);
                jobDetailsResults = await GetJobWithRetry(client, jobId, cancellationToken);
            }

            if (jobDetailsResults.StatusCode != JobStatusCode.Completed && jobDetailsResults.StatusCode != JobStatusCode.Failed &&
                jobDetailsResults.StatusCode != JobStatusCode.Canceled && (endTime - startTime) >= duration)
            {
                throw new TimeoutException(string.Format(CultureInfo.InvariantCulture, "The requested task failed to complete in the allotted time ({0}).", duration));
            }

            return jobDetailsResults;
        }
        public void TestExecuteFailure()
        {
            var details = new JobDetails<CheckScannerBatch>
            {
                Data = new CheckScannerBatch
                {
                    Name = "batch123",
                    ProgramId = 111,
                    MinistryPlatformContactId = 222,
                    MinistryPlatformUserId = 333
                },
                EnqueuedDateTime = DateTime.Now,
                RetrievedDateTime = DateTime.Now.AddMinutes(1)
            };

            _checkScannerService.Setup(mocked => mocked.CreateDonationsForBatch(details.Data)).Throws(new Exception());
            _emailService.Setup(
                mocked => mocked.SendEmail(
                    It.Is<EmailCommunicationDTO>(
                        o =>
                            o.FromUserId == 333 && o.FromContactId == 222 && o.TemplateId == 456 && o.ToContactId == 222 && (int)o.MergeData["programId"] == 111 &&
                            o.MergeData["batchName"].Equals("batch123") && o.MergeData.ContainsKey("error")
                        ),
                    null));

            _fixture.Execute(details);
        }
        private JobCreationResults CreateJobSuccessResult(JobDetails jobDetailsHistoryEntry, string jobName)
        {
            if (this.cluster.IsNull())
            {
                throw new InvalidOperationException("The cluster could not be found.");
            }

            //if (this.credentials.UserName != this.cluster.Cluster.HttpUserName && this.credentials.Password != this.cluster.Cluster.HttpPassword)
            //{
            //    throw new UnauthorizedAccessException("The supplied credential do not have access to the server.");
            //}
            lock (this.cluster.JobQueue)
            {
                this.LogMessage("Starting jobDetails '{0}'.", jobName);
                var jobCreationResults = new JobCreationResults {
                    JobId = "job_" + Guid.NewGuid().ToString(), HttpStatusCode = HttpStatusCode.OK
                };

                jobDetailsHistoryEntry.Name            = jobName;
                jobDetailsHistoryEntry.JobId           = jobCreationResults.JobId;
                jobDetailsHistoryEntry.PercentComplete = "map 0% reduce 0%";
                this.cluster.JobQueue.Add(jobDetailsHistoryEntry.JobId, jobDetailsHistoryEntry);

                return(jobCreationResults);
            }
        }
Example #23
0
        /// <summary>
        /// Performs HQL query and returns the query results.
        /// </summary>
        /// <param name="jobParams">The query parameters.</param>
        /// <returns>The query result.</returns>
        public string Query(HiveJobCreateParameters jobParams)
        {
            // Assign status folder
            jobParams.StatusFolder = RootDirectory + "/status";

            JobCreationResults jobDetails = null;

            try
            {
                // Create Hive job
                jobDetails = this.job.CreateHiveJob(jobParams);
            }
            catch (Exception e)
            {
                AvroHdiSample.ReportError("Error while creating a Hive job\n" + e);
            }

            JobDetails jobInProgress = null;

            try
            {
                // Get job status
                jobInProgress = this.job.GetJob(jobDetails.JobId);
            }
            catch (Exception e)
            {
                AvroHdiSample.ReportError("Error while getting Hive job status\n" + e);
            }


            // If job is not finished then sleep until the next client polling interval
            while (jobInProgress.StatusCode != JobStatusCode.Completed &&
                   jobInProgress.StatusCode != JobStatusCode.Failed)
            {
                try
                {
                    // Get job status
                    jobInProgress = this.job.GetJob(jobDetails.JobId);
                }
                catch (Exception e)
                {
                    AvroHdiSample.ReportError("Error while getting Hive job status\n" + e);
                }

                Thread.Sleep(this.client.PollingInterval);
            }

            try
            {
                // Job is finished; get its output stream, read it, and return the value
                return(new StreamReader(this.job.GetJobOutput(jobDetails.JobId)).ReadToEnd());
            }
            catch (Exception e)
            {
                AvroHdiSample.ReportError("Error while reading Hibe job result\n" + e);
            }

            return(string.Empty);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            JobDetails jobDetails = db.JobDetails.Find(id);

            db.JobDetails.Remove(jobDetails);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #25
0
        public ActionResult DeleteJob(int?JobId)
        {
            JobDetails jobDetails = db.JobDetails.Find(JobId);

            db.JobDetails.Remove(jobDetails);
            db.SaveChanges();
            return(RedirectToAction("Index1"));
        }
Example #26
0
		public void JobSpec_GetterAndSetter()
		{
			JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);

			JobSpec newJobSpec = jobSpec.Clone();
			jobDetails.JobSpec = newJobSpec;
			Assert.AreSame(newJobSpec, jobDetails.JobSpec);
		}
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudJob"/> class.
        /// </summary>
        /// <param name="workspace">The workspace.</param>
        /// <param name="jobDetails">The job details.</param>
        public CloudJob(IWorkspace workspace, JobDetails jobDetails)
        {
            Ensure.NotNull(workspace, nameof(workspace));
            Ensure.NotNull(jobDetails, nameof(jobDetails));

            Workspace = workspace;
            Details   = jobDetails;
        }
        public void SaveJobDetails_ThrowsIfDisposed()
        {
            jobStore.CreateJob(dummyJobSpec, DateTime.UtcNow, CreateJobConflictAction.Throw);
            JobDetails savedJobDetails = jobStore.GetJobDetails(dummyJobSpec.Name);

            jobStore.Dispose();
            jobStore.SaveJobDetails(savedJobDetails);
        }
        protected JobDetails CreateStoppedJob(string jobName)
        {
            JobDetails job = CreatePendingJob(jobName, new DateTime(1970, 1, 1));

            job.JobState = JobState.Stopped;
            jobStore.SaveJobDetails(job);
            return(job);
        }
        public void Remove_JobWithEmptyName_Throws()
        {
            var mockJob = new JobDetails("", 1000);

            IDynamicQueue <JobDetails> queue = new JobQueue(null);

            queue.Remove(mockJob);
        }
        public void Remove_JobInEmptyQueue_Throws()
        {
            var mockJob = new JobDetails("TestName", 1000);

            IDynamicQueue <JobDetails> queue = new JobQueue(null);

            int index = queue.MoveUp(mockJob);
        }
Example #32
0
        private JobDetails getJobDetails()
        {
            var jobDetails = new JobDetails();

            jobDetails.ideal_temperature = printingTemperature;
            jobDetails.filament_type     = FilamentProfile.StringToFilamentType(filamentType);
            return(jobDetails);
        }
        public void Dequeue_EmptyInitialQueue_ReturnNull()
        {
            IDynamicQueue <JobDetails> queue = new JobQueue(null);

            JobDetails topJob = queue.Dequeue();

            Assert.IsNull(topJob);
        }
        private bool ShouldFail(JobDetails jobDetailsHistoryItem)
        {
            if (jobDetailsHistoryItem.Name.IsNotNullOrEmpty() && jobDetailsHistoryItem.Name.Contains("Fail"))
            {
                return(true);
            }

            return(jobDetailsHistoryItem.Query.IsNotNullOrEmpty() && jobDetailsHistoryItem.Query.Contains("Fail"));
        }
        public void SaveJobDetails_WrapsExceptionIfDbConnectionFailureOccurs()
        {
            Mocks.ReplayAll();

            JobDetails jobDetails = CreatePendingJob("job", DateTime.UtcNow);

            SetBrokenConnectionMocking(JobStore, true);
            JobStore.SaveJobDetails(jobDetails);
        }
    private void BindPageFields()
    {
        QuoteRequestService objQuoteService      = new QuoteRequestService();
        JobDetailsService   objJobDetailsService = new JobDetailsService();

        QuoteRequest objQuoteReq = DataRepository.QuoteRequestProvider.GetByQuoteRequestId(QuoteRequestID);

        objQuoteService.DeepLoad(objQuoteReq, true, DeepLoadType.IncludeChildren
                                 , typeof(TList <JobDetails>), typeof(TList <CraQualifications>), typeof(TList <QuoteCandidates>));

        objJobDetailsService.DeepLoad(objQuoteReq.JobDetailsCollection[0], true,
                                      DeepLoadType.IncludeChildren, typeof(TList <JobDetailsStates>), typeof(TList <JobDetailsCountries>));

        JobDetails        objJobDetails = objQuoteReq.JobDetailsCollection[0];
        CraQualifications objCRAQual    = objQuoteReq.CraQualificationsCollection[0];

        txtJobDuties.Text = objJobDetails.JobDuties;
        if (objJobDetails.TentativeStartDate != null)
        {
            txtTentativeDate.Text = DateTime.Parse(objJobDetails.TentativeStartDate.ToString()).ToString("MM-dd-yyyy");
        }
        txtDurationContract.Text = objJobDetails.DurationContract;
        txtAvgDays.Text          = objJobDetails.AvgDays;

        foreach (JobDetailsCountries objJobDetailsCountries in objJobDetails.JobDetailsCountriesCollection)
        {
            lstBoxCountries.Items.FindByValue(objJobDetailsCountries.CountryId.ToString()).Selected = true;
        }

        foreach (JobDetailsStates objJobDetailsStates in objJobDetails.JobDetailsStatesCollection)
        {
            lstStates.Items.FindByValue(objJobDetailsStates.StateId.ToString()).Selected = true;
        }

        txtMinimumExp.Text        = objCRAQual.MinYearsExperience;
        txtTherapicExp.Text       = objCRAQual.ReqTherapeuticExperience;
        ddlFieldExp.SelectedValue = objCRAQual.FieldTypeExperience;
        txtPositionTitle.Text     = objCRAQual.PositionTitle;

        TList <QuoteCandidates> selectedCandidatesList = objQuoteReq.QuoteCandidatesCollection;

        //CachedCandidates = selectedCandidatesList.ToDataSet(false);
        BindCandidatesGrid();
        DataSet ds = CachedCandidates;

        foreach (QuoteCandidates qc in selectedCandidatesList)
        {
            ds.Tables[0].Rows.Find(qc.CandidateId);
            DataRow dr = ds.Tables[0].Rows.Find(qc.CandidateId);
            if (dr != null)
            {
                dr["Selected"] = true;
            }
        }
        CachedCandidates = ds;
        BindCandidatesGrid();//again bind grid
    }
Example #37
0
 public void ConstructorSetsProperties()
 {
     JobDetails jobDetails = new JobDetails(jobSpec, new DateTime(2000, 4, 2));
     Assert.AreSame(jobSpec, jobDetails.JobSpec);
     DateTimeAssert.AreEqualIncludingKind(new DateTime(2000, 4, 2, 0, 0, 0, DateTimeKind.Utc), jobDetails.CreationTimeUtc);
     Assert.AreEqual(JobState.Pending, jobDetails.JobState);
     Assert.IsNull(jobDetails.NextTriggerFireTimeUtc);
     Assert.IsNull(jobDetails.NextTriggerMisfireThreshold);
     Assert.IsNull(jobDetails.LastJobExecutionDetails);
 }
        /// <summary>
        ///     Initializes a new instance of the AzureHDInsightJob class.
        /// </summary>
        /// <param name="jobDetails">The HDInsight jobDetails.</param>
        /// <param name="cluster">The cluster that the jobDetails was created against.</param>
        public AzureHDInsightJob(JobDetails jobDetails, string cluster) : base(jobDetails)
        {
            jobDetails.ArgumentNotNull("jobDetails");
            this.ExitCode = jobDetails.ExitCode;
            this.Name = jobDetails.Name;
            this.Query = jobDetails.Query;
            this.State = jobDetails.StatusCode.ToString();

            this.Cluster = cluster;
            this.StatusDirectory = jobDetails.StatusDirectory;
            this.SubmissionTime = jobDetails.SubmissionTime;
            this.PercentComplete = jobDetails.PercentComplete;
        }
        public virtual void WaitForInvalidJobDoesNotThrow()
        {
            var jobDetails = new JobDetails { JobId = Guid.NewGuid().ToString() };
            var invalidJob = new AzureHDInsightJob(jobDetails, TestCredentials.WellKnownCluster.DnsName);

            // IHadoopClientExtensions.GetPollingInterval = () => 0;
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            using (IRunspace runspace = this.GetPowerShellRunspace())
            {
                runspace.NewPipeline()
                                      .AddCommand(CmdletConstants.WaitAzureHDInsightJob)
                        .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                        .WithParameter(CmdletConstants.Job, invalidJob)
                                      .Invoke();
            }
        }
Example #40
0
        public static void AreEqual(JobDetails expected, JobDetails actual)
        {
            if (expected == null)
            {
                Assert.IsNull(actual);
                return;
            }

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.CreationTimeUtc, actual.CreationTimeUtc);
            AreEqual(expected.JobSpec, actual.JobSpec);
            Assert.AreEqual(expected.JobState, actual.JobState);
            AreEqualUpToErrorLimit(expected.NextTriggerFireTimeUtc, actual.NextTriggerFireTimeUtc);
            Assert.AreEqual(expected.NextTriggerMisfireThreshold, actual.NextTriggerMisfireThreshold);
            AreEqual(expected.LastJobExecutionDetails, actual.LastJobExecutionDetails);
        }
Example #41
0
        public void ClonePerformsADeepCopy(bool useGenericClonable)
        {
            JobDetails jobDetails = new JobDetails(jobSpec, DateTime.UtcNow);
            jobDetails.LastJobExecutionDetails = new JobExecutionDetails(SchedulerGuid, DateTime.UtcNow);
            jobDetails.JobState = JobState.Scheduled;
            jobDetails.NextTriggerFireTimeUtc = DateTime.UtcNow;
            jobDetails.NextTriggerMisfireThreshold = TimeSpan.MaxValue;

            JobDetails clone = useGenericClonable
                               	? jobDetails.Clone()
                               	: (JobDetails) ((ICloneable) jobDetails).Clone();

            Assert.AreNotSame(jobDetails, clone);
            Assert.AreNotSame(jobDetails.JobSpec, clone.JobSpec);
            Assert.AreNotSame(jobDetails.LastJobExecutionDetails, clone.LastJobExecutionDetails);

            JobAssert.AreEqual(jobDetails, clone);
        }
Example #42
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            ArrayList list = new ArrayList();

            foreach (XmlNode node in section)
            {
                if (node.Name.ToLower() == "job")
                {
                    JobDetails detail = new JobDetails();
                    foreach (XmlAttribute attr in node.Attributes)
                    {
                        if (attr.Name.ToLower() == "spec")
                            detail.ReferencePath = attr.InnerText;
                    }
                    if (detail.Name.Equals("") && !detail.ReferencePath.Equals(""))
                        detail.Name = detail.ReferencePath.Replace(".xml", "");
                    detail.IsEditable = false;
                    list.Add(detail);
                }
            }
            return list;
        }
        public virtual void WaitForInvalidJobIdDoesNotThrow()
        {
            var jobDetails = new JobDetails()
            {
                JobId = Guid.NewGuid().ToString()
            };

            var cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            using (var runspace = this.GetPowerShellRunspace())
            {
                runspace.NewPipeline()
                .AddCommand(CmdletConstants.WaitAzureHDInsightJob)
                .WithParameter(CmdletConstants.Credential, IntegrationTestBase.GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                .WithParameter(CmdletConstants.JobId, jobDetails.JobId)
                .WithParameter(CmdletConstants.Cluster, jobDetails.JobId)
                .Invoke();
            }
        }
Example #44
0
        public void SchedulerTriggeredJob_WithSkipAction(bool misfire,
            bool nextTriggerFireTimeNotNull,
            bool nextTriggerMisfireThresholdNotNull)
        {
            // Create a job scheduled to fire 3 minutes in the past.
            // We cause a misfire by setting a threshold for 2 seconds which clearly is
            // in the past.  Otherwise we set the threshold to 1 minute which clearly is satisfiable.
            DateTime schedTime = DateTime.UtcNow.AddSeconds(-3);
            JobDetails jobDetails = new JobDetails(dummyJobSpec, schedTime.AddSeconds(-5));
            jobDetails.JobState = JobState.Triggered;

            if (nextTriggerFireTimeNotNull)
                jobDetails.NextTriggerFireTimeUtc = schedTime;
            if (nextTriggerMisfireThresholdNotNull)
                jobDetails.NextTriggerMisfireThreshold = misfire ? new TimeSpan(0, 0, 2) : new TimeSpan(0, 1, 0);

            PrepareMockJobWatcher(jobDetails);

            TriggerScheduleCondition expectedCondition = misfire
                                                         	? TriggerScheduleCondition.Misfire
                                                         	: TriggerScheduleCondition.Fire;

            Expect.Call(mockTrigger.Schedule(expectedCondition, DateTime.MinValue, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(expectedCondition), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Return(TriggerScheduleAction.Skip);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(new DateTime(1970, 1, 5, 0, 0, 0, DateTimeKind.Utc));
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(new TimeSpan(0, 2, 0));

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) WakeOnSaveJobDetails);

            Mocks.ReplayAll();

            RunSchedulerUntilWake();

            Assert.AreEqual(JobState.Scheduled, jobDetails.JobState);
            DateTimeAssert.AreEqualIncludingKind(new DateTime(1970, 1, 5, 0, 0, 0, DateTimeKind.Utc),
                                                 jobDetails.NextTriggerFireTimeUtc);
            Assert.AreEqual(new TimeSpan(0, 2, 0), jobDetails.NextTriggerMisfireThreshold);
            Assert.IsNull(jobDetails.JobSpec.JobData);
            Assert.IsNull(jobDetails.LastJobExecutionDetails);
        }
        public void ICanListJobs()
        {
            var expectedJob = new JobDetails() { ExitCode = 12, Name = "some jobDetails", StatusCode = JobStatusCode.Completed, JobId = "2345" };

            var factory = new MockRemotePocoLayerFactory();
            var pocoMock = new MockRemotePoco { JobId = string.Empty, JobDetails = expectedJob };
            factory.Mock = pocoMock;

            ServiceLocator.Instance.Locate<IServiceLocationIndividualTestManager>().Override<IRemoteHadoopJobSubmissionPocoClientFactory>(factory);

            // var creds = new JobSubmissionCertificateCredential(Guid.NewGuid(), null, "someCluster");
            var creds = new BasicAuthCredential()
            {
                Password = "******",
                Server = new Uri("http://somewhere"),
                UserName = "******"
            };

            var poco = new HDInsightJobSubmissionPocoClient(creds, GetAbstractionContext(), false, pocoMock.GetUserAgentString());
            var task = poco.ListJobs();
            task.Wait();

            Assert.IsNotNull(task.Result);
            Assert.IsTrue(pocoMock.ListJobsCalled);
            Assert.AreEqual(1, task.Result.Jobs.Count);

            var job = task.Result.Jobs.First();
            Assert.AreEqual("2345", job.JobId);
            Assert.AreEqual(expectedJob, job);
        }
Example #46
0
        public void SchedulerHandlesJobStoreExceptionByInsertingAnErrorRecoveryDelay()
        {
            // The mock job watcher will return job detail on the first GetNextJobToProcess
            // but the mock job store will throw Expection during SaveJobDetails.
            // On the second call to GetNextJobToProcess the mock job watcher will cause us to wake up.
            // There should be a total delay at least as big as the error recovery delay.
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Pending;

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.UtcNow, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Return(TriggerScheduleAction.Stop);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(new DateTime(1970, 1, 5, 0, 0, 0, DateTimeKind.Utc));
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(new TimeSpan(0, 1, 0));

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Throw(new Exception("Uh oh!"));

            IJobWatcher mockJobWatcher = Mocks.CreateMock<IJobWatcher>();

            Expect.Call(mockJobWatcher.GetNextJobToProcess()).Return(jobDetails);
            Expect.Call(mockJobWatcher.GetNextJobToProcess()).Do((GetNextJobToProcessDelegate) delegate
            {
                Wake();
                return null;
            });

            mockJobWatcher.Dispose();
            LastCall.Repeat.AtLeastOnce();

            Expect.Call(mockJobStore.CreateJobWatcher(scheduler.Guid)).Return(mockJobWatcher);

            Mocks.ReplayAll();

            scheduler.ErrorRecoveryDelayInSeconds = 2;

            Stopwatch stopWatch = Stopwatch.StartNew();
            RunSchedulerUntilWake();
            Assert.That(stopWatch.ElapsedMilliseconds, NUnit.Framework.Is.GreaterThanOrEqualTo(2000).And.LessThanOrEqualTo(10000));
        }
Example #47
0
        public void SchedulerHandlesUnexpectedJobStateReceivedFromWatcherByStoppingTheTrigger(JobState jobState)
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = jobState;

            PrepareMockJobWatcher(jobDetails);

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) WakeOnSaveJobDetails);

            Mocks.ReplayAll();

            RunSchedulerUntilWake();

            Assert.AreEqual(JobState.Stopped, jobDetails.JobState);
            Assert.IsNull(jobDetails.NextTriggerFireTimeUtc);
            Assert.IsNull(jobDetails.NextTriggerMisfireThreshold);
            Assert.IsNull(jobDetails.LastJobExecutionDetails);
            Assert.IsNull(jobDetails.JobSpec.JobData);
        }
        private bool ShouldFail(JobDetails jobDetailsHistoryItem)
        {
            if (jobDetailsHistoryItem.Name.IsNotNullOrEmpty() && jobDetailsHistoryItem.Name.Contains("Fail"))
            {
                return true;
            }

            return jobDetailsHistoryItem.Query.IsNotNullOrEmpty() && jobDetailsHistoryItem.Query.Contains("Fail");
        }
Example #49
0
        public void SchedulerHandlesJobStoreConcurrentModificationExceptionByIgnoringTheJob()
        {
            // The mock job watcher will return job detail on the first GetNextJobToProcess
            // but the mock job store will throw ConcurrentModificationException during SaveJobDetails.
            // On the second call to GetNextJobToProcess the mock job watcher will cause us to wake up.
            // There should be no noticeable delay, particularly not one as big as the error recovery delay.
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Pending;

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.UtcNow, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Return(TriggerScheduleAction.Stop);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(new DateTime(1970, 1, 5, 0, 0, 0, DateTimeKind.Utc));
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(new TimeSpan(0, 1, 0));

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Throw(new ConcurrentModificationException("Another scheduler grabbed it."));

            IJobWatcher mockJobWatcher = Mocks.CreateMock<IJobWatcher>();

            Expect.Call(mockJobWatcher.GetNextJobToProcess()).Return(jobDetails);
            Expect.Call(mockJobWatcher.GetNextJobToProcess()).Do((GetNextJobToProcessDelegate) delegate
            {
                Wake();
                return null;
            });

            mockJobWatcher.Dispose();
            LastCall.Repeat.AtLeastOnce();

            Expect.Call(mockJobStore.CreateJobWatcher(scheduler.Guid)).Return(mockJobWatcher);

            Mocks.ReplayAll();

            scheduler.ErrorRecoveryDelayInSeconds = 2;

            Stopwatch stopWatch = Stopwatch.StartNew();
            RunSchedulerUntilWake();
            Assert.Less(stopWatch.ElapsedMilliseconds, 2000);
        }
Example #50
0
        public void ScheduleHandlesTriggerExceptionByStoppingTheTrigger()
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Pending;

            PrepareMockJobWatcher(jobDetails);

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.UtcNow, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Throw(new Exception("Oh no!")); // throw an exception from the trigger

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) WakeOnSaveJobDetails);

            Mocks.ReplayAll();

            RunSchedulerUntilWake();

            Assert.AreEqual(JobState.Stopped, jobDetails.JobState);
            Assert.IsNull(jobDetails.NextTriggerFireTimeUtc);
            Assert.IsNull(jobDetails.NextTriggerMisfireThreshold);
            Assert.IsNull(jobDetails.LastJobExecutionDetails);
            Assert.IsNull(jobDetails.JobSpec.JobData);
        }
Example #51
0
        public void ScheduleOrphanJob_WithStopAction(bool lastExecutionDetailsNotNull,
            bool lastExecutionSucceeded, bool lastEndTimeNotNull)
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Orphaned;

            if (lastExecutionDetailsNotNull)
            {
                jobDetails.LastJobExecutionDetails = new JobExecutionDetails(scheduler.Guid, DateTime.UtcNow);
                jobDetails.LastJobExecutionDetails.Succeeded = lastExecutionSucceeded;

                if (lastEndTimeNotNull)
                    jobDetails.LastJobExecutionDetails.EndTimeUtc = DateTime.UtcNow;
            }

            PrepareMockJobWatcher(jobDetails);

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.UtcNow, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Property.Value("Succeeded", false))
                .Return(TriggerScheduleAction.DeleteJob);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(null);
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(null);

            mockJobStore.DeleteJob(jobDetails.JobSpec.Name);
            LastCall.Do((DeleteJobDelegate) WakeOnDeleteJob);

            Mocks.ReplayAll();

            RunSchedulerUntilWake();

            Assert.AreEqual(JobState.Orphaned, jobDetails.JobState);
            Assert.IsNull(jobDetails.NextTriggerFireTimeUtc);
            Assert.IsNull(jobDetails.NextTriggerMisfireThreshold);
            Assert.IsNull(jobDetails.JobSpec.JobData);
            Assert.IsNotNull(jobDetails.LastJobExecutionDetails);
            Assert.AreEqual(scheduler.Guid, jobDetails.LastJobExecutionDetails.SchedulerGuid);
            Assert.AreEqual(false, jobDetails.LastJobExecutionDetails.Succeeded);
            Assert.IsNotNull(jobDetails.LastJobExecutionDetails.EndTimeUtc);
        }
Example #52
0
 private void WakeOnSaveJobDetails(JobDetails jobDetails)
 {
     Wake();
 }
Example #53
0
            public MockJobWatcher(JobDetails jobDetails)
            {
                this.jobDetails = jobDetails;

                firstTime = true;
            }
Example #54
0
 /// <summary>
 /// Sets the mock job store to provide a watcher that yields the specified job details
 /// on its first access then waits to be disposed.
 /// </summary>
 /// <param name="jobDetails">The job details to yield</param>
 private void PrepareMockJobWatcher(JobDetails jobDetails)
 {
     Expect.Call(mockJobStore.CreateJobWatcher(scheduler.Guid)).
         Return(new MockJobWatcher(jobDetails));
 }
Example #55
0
        /// <summary>
        /// Schedules a job that is guaranteed to be executed.
        /// </summary>
        private void PrepareJobForExecution(BeingExecuteDelegate beginExecute,
            EndExecuteDelegate endExecute)
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Pending;

            PrepareMockJobWatcher(jobDetails);

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.MinValue, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Return(TriggerScheduleAction.ExecuteJob);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(null);
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(null);

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) delegate
            {
                Assert.AreEqual(JobState.Running, jobDetails.JobState);
                Assert.IsNotNull(jobDetails.LastJobExecutionDetails);
                Assert.AreEqual(scheduler.Guid, jobDetails.LastJobExecutionDetails.SchedulerGuid);
                Assert.GreaterOrEqual(jobDetails.LastJobExecutionDetails.StartTimeUtc, jobDetails.CreationTimeUtc);
                Assert.IsNull(jobDetails.LastJobExecutionDetails.EndTimeUtc);
                Assert.IsFalse(jobDetails.LastJobExecutionDetails.Succeeded);
            });

            Expect.Call(mockJobRunner.BeginExecute(null, null, null))
                .IgnoreArguments().Repeat.Any().Do(beginExecute);
            Expect.Call(mockJobRunner.EndExecute(null))
                .IgnoreArguments().Repeat.Any().Do(endExecute);
        }
        private static JobDetails SimulateInspectionResultsToMonitorDurableJobStorageBehavior(JobQueueAction<object> [] inspectionResults)
        {
            var details = new JobDetails()
            {
                DurableStorage = A.Fake<IDurableJobQueue<int, object>>(),
                Inspector = A.Fake<IJobResultInspector<int, int, object>>(),
                Log = A.Fake<ILog>()
            };
            var observable = Enumerable.Repeat(new JobResult<int, int>(1, 1), inspectionResults.Length)
            .ToObservable();

            int counter = 0;
            using (var wait = new ManualResetEventSlim(false))
            {
                A.CallTo(() => details.Inspector.Inspect(A<JobResult<int, int>>.Ignored))
                .Invokes(call =>
                    {
                        if (Interlocked.Increment(ref counter) == inspectionResults.Length)
                        {
                            wait.Set();
                        }
                    })
                .ReturnsNextFromSequence(inspectionResults);

                details.JournalingJobResultQueue = new JobResultJournalWriter<int, int, object>(observable, details.Inspector,
                    details.DurableStorage, details.Log, Scheduler.Immediate);

                wait.Wait(TimeSpan.FromSeconds(5));

                return details;
            }
        }
        private JobDetails ChangeJobState(JobDetails jobDetailsHistoryItem)
        {
            if (jobDetailsHistoryItem.StatusCode == JobStatusCode.Unknown)
            {
                jobDetailsHistoryItem.StatusCode = JobStatusCode.Initializing;
            }
            else
            {
                switch (jobDetailsHistoryItem.StatusCode)
                {
                    case JobStatusCode.Initializing:
                        jobDetailsHistoryItem.StatusCode = JobStatusCode.Running;
                        jobDetailsHistoryItem.PercentComplete = "map 5% reduce 0%";
                        break;
                    case JobStatusCode.Running:
                        jobDetailsHistoryItem.StatusCode = JobStatusCode.Completed;
                        jobDetailsHistoryItem.PercentComplete = "map 100% reduce 100%";
                        jobDetailsHistoryItem.ExitCode = 0;
                        if ((jobDetailsHistoryItem.Name.IsNotNullOrEmpty() && string.Equals(jobDetailsHistoryItem.Name, "show tables", StringComparison.OrdinalIgnoreCase)) ||
                            string.Equals(jobDetailsHistoryItem.Query, "show tables", StringComparison.OrdinalIgnoreCase))
                        {
                            this.WriteJobOutput(jobDetailsHistoryItem.StatusDirectory, "hivesampletable");
                            this.WriteJobError(jobDetailsHistoryItem.StatusDirectory, JobSuccesful);
                        }
                        else if (jobDetailsHistoryItem.Name.IsNotNullOrEmpty() && string.Equals(jobDetailsHistoryItem.Name, "pi estimation job", StringComparison.OrdinalIgnoreCase))
                        {
                            this.WriteJobOutput(jobDetailsHistoryItem.StatusDirectory, "3.142");
                            this.WriteJobError(jobDetailsHistoryItem.StatusDirectory, JobSuccesful);
                        }
                        else
                        {
                            this.WriteJobOutput(jobDetailsHistoryItem.StatusDirectory, JobSuccesful);
                            this.WriteJobError(jobDetailsHistoryItem.StatusDirectory, JobSuccesful);
                        }

                        this.WriteJobLogSummary(jobDetailsHistoryItem.StatusDirectory, jobDetailsHistoryItem.JobId);
                        break;
                }
            }

            var jobDeletionTime = this.cluster.JobDeletionQueue.FirstOrDefault(deletedJob => deletedJob.Key == jobDetailsHistoryItem.JobId);
            if (jobDeletionTime.Value != DateTime.MinValue && jobDeletionTime.Value != DateTime.MaxValue && jobDeletionTime.Value <= DateTime.Now)
            {
                jobDetailsHistoryItem.StatusCode = JobStatusCode.Canceled;
            }
            else
            {
                if (this.ShouldFail(jobDetailsHistoryItem))
                {
                    if (jobDetailsHistoryItem.StatusCode == JobStatusCode.Running)
                    {
                        jobDetailsHistoryItem.StatusCode = JobStatusCode.Failed;
                        jobDetailsHistoryItem.ExitCode = 4000;
                        this.WriteJobOutput(jobDetailsHistoryItem.StatusDirectory, JobFailed);
                        this.WriteJobError(jobDetailsHistoryItem.StatusDirectory, JobFailed);
                    }
                }
                else if (jobDetailsHistoryItem.Name.IsNotNullOrEmpty() && jobDetailsHistoryItem.Name.Contains("Unknown"))
                {
                    if (jobDetailsHistoryItem.StatusCode == JobStatusCode.Running)
                    {
                        jobDetailsHistoryItem.StatusCode = JobStatusCode.Unknown;
                    }
                }
            }

            return jobDetailsHistoryItem;
        }
Example #58
0
        public void SchedulePendingJob_WithSkipAction()
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Pending;

            PrepareMockJobWatcher(jobDetails);

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.UtcNow, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Return(TriggerScheduleAction.Skip);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(new DateTime(1970, 1, 5, 0, 0, 0, DateTimeKind.Utc));
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(new TimeSpan(0, 1, 0));

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) WakeOnSaveJobDetails);

            Mocks.ReplayAll();

            RunSchedulerUntilWake();

            Assert.AreEqual(JobState.Scheduled, jobDetails.JobState);
            DateTimeAssert.AreEqualIncludingKind(new DateTime(1970, 1, 5, 0, 0, 0, DateTimeKind.Utc),
                                                 jobDetails.NextTriggerFireTimeUtc);
            Assert.AreEqual(new TimeSpan(0, 1, 0), jobDetails.NextTriggerMisfireThreshold);
            Assert.IsNull(jobDetails.JobSpec.JobData);
            Assert.IsNull(jobDetails.LastJobExecutionDetails);
        }
 /// <summary>
 ///     Initializes a new instance of the AzureHDInsightJobBase class.
 /// </summary>
 /// <param name="jobDetails">The HDInsight jobDetails.</param>
 public AzureHDInsightJobBase(JobDetails jobDetails)
 {
     jobDetails.ArgumentNotNull("jobDetails");
     this.JobId = jobDetails.JobId;
 }
        private JobCreationResults CreateJobSuccessResult(JobDetails jobDetailsHistoryEntry, string jobName)
        {
            if (this.cluster.IsNull())
            {
                throw new InvalidOperationException("The cluster could not be found.");
            }
            if (this.credentials.UserName != this.cluster.Cluster.HttpUserName && this.credentials.Password != this.cluster.Cluster.HttpPassword)
            {
                throw new UnauthorizedAccessException("The supplied credential do not have access to the server.");
            }
            lock (this.cluster.JobQueue)
            {
                this.LogMessage("Starting jobDetails '{0}'.", jobName);
                var jobCreationResults = new JobCreationResults()
                {
                    JobId = "job_" + Guid.NewGuid().ToString(),
                    HttpStatusCode = HttpStatusCode.OK
                };

                jobDetailsHistoryEntry.Name = jobName;
                jobDetailsHistoryEntry.JobId = jobCreationResults.JobId;
                jobDetailsHistoryEntry.PercentComplete = "map 0% reduce 0%";
                this.cluster.JobQueue.Add(jobDetailsHistoryEntry.JobId, jobDetailsHistoryEntry);

                return jobCreationResults;
            }
        }