public JobUI(Job job) { this.jobId = job.getJobId(); this.attempts = FluentIterable.from(job.getAttempts()) .transform(new Function<JobAttempt, JobAttemptUI>() { @Override public JobAttemptUI apply(JobAttempt input) { return toUI(input); } }).toList(); this.data = new JobDataWrapper(job.getData()); }
private JobResult toJobResult(Job job) { return new JobResult().setAttemptsList(job.getAttempts()); }
for(int attemptIndex = 0; attemptIndex < job.getAttempts().size() ; attemptIndex++) { zip.putNextEntry(new ZipEntry(String.format("profile_attempt_%d.json", attemptIndex))); QueryProfile profile = recordProfile(zip, jobId, attemptIndex);
public PartialJobListItem(Job input) { final JobAttempt firstAttempt = input.getAttempts().get(0); final JobAttempt lastAttempt = input.getAttempts().get(input.getAttempts().size() - 1); this.id = input.getJobId().getId(); this.state = lastAttempt.getState(); this.failureInfo = JobDetailsUI.toJobFailureInfo(input.getJobAttempt().getInfo()); this.cancellationInfo = JobDetailsUI.toJobCancellationInfo(input.getJobAttempt()); this.user = firstAttempt.getInfo().getUser(); this.startTime = firstAttempt.getInfo().getStartTime(); this.endTime = lastAttempt.getInfo().getFinishTime(); this.description = firstAttempt.getInfo().getDescription(); this.accelerated = lastAttempt.getInfo().getAcceleration() != null; this.requestType = firstAttempt.getInfo().getRequestType(); this.datasetVersion = firstAttempt.getInfo().getDatasetVersion(); this.isComplete = isComplete(state); AccelerationDetails accelerationDetails = deserialize(lastAttempt.getAccelerationDetails()); this.snowflakeAccelerated = this.accelerated && JobDetailsUI.wasSnowflakeAccelerated(accelerationDetails); this.spilled = lastAttempt.getInfo().getSpillJobDetails() != null; }
public static JobDetailsUI of(Job job) { JobInfo jobInfo = job.getJobAttempt().getInfo(); List<JobAttempt> attempts = job.getAttempts(); AccelerationDetails accelerationDetails = deserialize(Util.last(attempts).getAccelerationDetails()); return new JobDetailsUI( job.getJobId(), job.getJobAttempt().getDetails(), JobResource.getPaginationURL(job.getJobId()), attempts, JobResource.getDownloadURL(job), toJobFailureInfo(jobInfo), toJobCancellationInfo(Util.last(attempts)), job.getJobAttempt().getInfo().getDatasetVersion(), job.hasResults(), accelerationDetails, jobInfo.getSpillJobDetails()); }
@Test public void testSingleCompletedAttempt() throws Exception { final String attemptId = AttemptIdUtils.toString(new AttemptId()); Job job = createJob("A1", Arrays.asList("space1", "ds1"), "v1", "A", "space1", JobState.COMPLETED, "select * from LocalFS1.\"dac-sample1.json\"", 100L, 110L, QueryType.UI_RUN); job.getJobAttempt().setDetails(new JobDetails()); job.getJobAttempt().setAttemptId(attemptId); JobDetailsUI detailsUI = new JobDetailsUI(job.getJobId(), job.getJobAttempt().getDetails(), JobResource.getPaginationURL(job.getJobId()), job.getAttempts(), JobResource.getDownloadURL(job), null, null, null, true, null, null); assertEquals("", detailsUI.getAttemptsSummary()); assertEquals(1, detailsUI.getAttemptDetails().size()); AttemptDetailsUI attemptDetailsUI = detailsUI.getAttemptDetails().get(0); assertEquals("", attemptDetailsUI.getReason()); assertEquals(JobState.COMPLETED, attemptDetailsUI.getResult()); assertEquals("/profiles/" + job.getJobId().getId() + "?attempt=0", attemptDetailsUI.getProfileUrl()); }
@Test public void testSingleFailedAttempt() throws Exception { final String attemptId = AttemptIdUtils.toString(new AttemptId()); Job job = createJob("A1", Arrays.asList("space1", "ds1"), "v1", "A", "space1", JobState.FAILED, "select * from LocalFS1.\"dac-sample1.json\"", 100L, 110L, QueryType.UI_RUN); job.getJobAttempt().setDetails(new JobDetails()); job.getJobAttempt().setAttemptId(attemptId); JobDetailsUI detailsUI = new JobDetailsUI(job.getJobId(), job.getJobAttempt().getDetails(), JobResource.getPaginationURL(job.getJobId()), job.getAttempts(), JobResource.getDownloadURL(job), new JobFailureInfo("Some error message", JobFailureType.UNKNOWN, null), null, null, false, null, null); assertEquals("", detailsUI.getAttemptsSummary()); assertEquals(1, detailsUI.getAttemptDetails().size()); AttemptDetailsUI attemptDetailsUI = detailsUI.getAttemptDetails().get(0); assertEquals("", attemptDetailsUI.getReason()); assertEquals(JobState.FAILED, attemptDetailsUI.getResult()); assertEquals("/profiles/" + job.getJobId().getId() + "?attempt=0", attemptDetailsUI.getProfileUrl()); }
JobDetailsUI detailsUI = new JobDetailsUI(job.getJobId(), new JobDetails(), JobResource.getPaginationURL(job.getJobId()), job.getAttempts(), JobResource.getDownloadURL(job), null, null, null, false, null, null);