@Override public byte[] convert(AttemptId v) { return StringSerializer.INSTANCE.convert(AttemptIdUtils.toString(v)); }
@Override public AttemptId revert(byte[] v) { return AttemptIdUtils.fromString(StringSerializer.INSTANCE.revert(v)); } }
@Override public String toJson(AttemptId v) throws IOException { return StringSerializer.INSTANCE.toJson(AttemptIdUtils.toString(v)); }
@Override public AttemptId fromJson(String v) throws IOException { return AttemptIdUtils.fromString(StringSerializer.INSTANCE.fromJson(v)); }
@Override public AttemptObserver newAttempt(AttemptId attemptId, AttemptReason reason) { // first attempt is already part of the job if (attemptId.getAttemptNum() > 0) { // create a new JobAttempt for the new attempt final JobInfo jobInfo = ProtostuffUtil.copy(job.getJobAttempt().getInfo()) .setStartTime(System.currentTimeMillis()) // use different startTime for every attempt .setFailureInfo(null) .setDetailedFailureInfo(null) .setResultMetadataList(new ArrayList<ArrowFileMetadata>()); final JobAttempt jobAttempt = new JobAttempt() .setInfo(jobInfo) .setReason(reason) .setEndpoint(identity) .setDetails(new JobDetails()) .setState(ENQUEUED); job.addAttempt(jobAttempt); } job.getJobAttempt().setAttemptId(AttemptIdUtils.toString(attemptId)); if (isInternal) { attemptObserver = new JobResultListener(attemptId, job, allocator, statusListener, listeners); } else { attemptObserver = new ExternalJobResultListener(attemptId, responseHandler, job, allocator); } return attemptObserver; }
profileStore.put(AttemptIdUtils.fromString(job.getJobAttempt().getAttemptId()), profile);
@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()); }
AttemptId attemptId = AttemptId.of(externalId); job.getJobAttempt() .setAttemptId(AttemptIdUtils.toString(attemptId)) .setState(JobState.FAILED) .setDetails(new JobDetails()); final JobAttempt jobAttempt = new JobAttempt() .setInfo(newJobInfo(job.getJobAttempt().getInfo(), 100L+2*i, 100L+2*i+1, "failed")) .setAttemptId(AttemptIdUtils.toString(attemptId)) .setState(JobState.FAILED) .setReason(i == 0 ? AttemptReason.OUT_OF_MEMORY : AttemptReason.SCHEMA_CHANGE) final JobAttempt jobAttempt = new JobAttempt() .setInfo(newJobInfo(job.getJobAttempt().getInfo(), 106, 107, null)) .setAttemptId(AttemptIdUtils.toString(attemptId)) .setState(JobState.COMPLETED) .setReason(AttemptReason.SCHEMA_CHANGE)