public JobProgressUpdate(Job job) { this.id = job.getJobId(); this.update = new PartialJobListItem(job); }
ExternalJobResultListener(AttemptId attemptId, UserResponseHandler connection, Job job, BufferAllocator allocator) { super(attemptId, job, allocator, NoOpJobStatusListener.INSTANCE); this.connection = connection; this.externalId = JobsServiceUtil.getJobIdAsExternalId(job.getJobId()); }
public String getId() { return job.getJobId().getId(); }
@GET @Path("download") @Produces(APPLICATION_JSON) public InitialDownloadResponse downloadDataset(@QueryParam("downloadFormat") @DefaultValue("JSON") DownloadFormat downloadFormat, @QueryParam("limit") @DefaultValue("1000000") int limit) throws IOException, DatasetVersionNotFoundException { final Job job = datasetService.prepareDownload(datasetPath, version, downloadFormat, limit, securityContext.getUserPrincipal().getName()); return new InitialDownloadResponse(job.getJobId(), JobResource.getDownloadURL(job)); }
private QueryListener(Job job, UserResponseHandler connection) { this.job = job; externalId = JobsServiceUtil.getJobIdAsExternalId(job.getJobId()); this.responseHandler = Preconditions.checkNotNull(connection, "handler cannot be null"); this.statusListener = null; isInternal = false; setupJobData(); }
private QueryListener(Job job, JobStatusListener statusListener) { this.job = job; externalId = JobsServiceUtil.getJobIdAsExternalId(job.getJobId()); this.responseHandler = null; this.statusListener = Preconditions.checkNotNull(statusListener, "statusListener cannot be null"); isInternal = true; setupJobData(); }
private void setupJobData() { final JobLoader jobLoader = isInternal ? new InternalJobLoader(exception, completionLatch, job.getJobId(), jobResultsStore, store) : new ExternalJobLoader(completionLatch, exception); final JobData result = jobResultsStore.cacheNewJob(job.getJobId(), new JobDataImpl(jobLoader, job.getJobId())); job.setData(result); }
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()); }
@VisibleForTesting void storeJob(Job job) { store.put(job.getJobId(), toJobResult(job)); }
@Override public void profileUpdated(Job job) { final JobDetailsUpdate update = new JobDetailsUpdate(job.getJobId()); socket.send(update); }
JobResultListener(AttemptId attemptId, Job job, BufferAllocator allocator, JobStatusListener statusListener, ExternalListenerManager externalListenerManager) { Preconditions.checkNotNull(jobResultsStore); this.attemptId = attemptId; this.job = job; this.jobId = job.getJobId(); this.allocator = allocator; this.builder = QueryMetadata.builder(namespaceService); this.statusListener = statusListener; this.detailsPopulator = contextProvider.get().getAccelerationManager().newPopulator(); this.externalListenerManager = externalListenerManager; }
@Override public void queryCompleted(Job job) { final JobDetailsUpdate update = new JobDetailsUpdate(job.getJobId()); socket.send(update); }
@Override public Job submitJob(JobRequest jobRequest, JobStatusListener statusListener) { checkNotNull(statusListener, "a status listener must be provided"); final Job job = startJob(jobRequest, statusListener); logger.debug("Submitted new job. Id: {} Type: {} Sql: {}", job.getJobId().getId(), jobRequest.getQueryType(), jobRequest.getSqlQuery()); return job; }
public static String getDownloadURL(Job job) { final JobInfo jobInfo = job.getJobAttempt().getInfo(); if (jobInfo.getQueryType() == QueryType.UI_EXPORT) { return format("/job/%s/download", job.getJobId().getId()); } return null; }
private void refreshMetadata(ReflectionEntry entry, Materialization materialization) { final String sql = String.format("LOAD MATERIALIZATION METADATA \"%s\".\"%s\"", materialization.getReflectionId().getId(), materialization.getId().getId()); final Job job = submitRefreshJob(jobsService, namespaceService, entry, materialization, sql, new WakeUpManagerWhenJobDone(wakeUpCallback, "metadata refresh job done")); entry.setState(METADATA_REFRESH) .setRefreshJobId(job.getJobId()); reflectionStore.save(entry); logger.debug("started job {} to load materialization metadata {}", job.getJobId().getId(), getId(materialization)); }
private void createAndSaveRefresh(final JobDetails details, final RefreshDecision decision) { final boolean isFull = decision.getAccelerationSettings().getMethod() == RefreshMethod.FULL; final long updateId = isFull ? -1L : getUpdateId(job.getJobId(), job.getData()); final MaterializationMetrics metrics = ReflectionUtils.computeMetrics(job); final List<DataPartition> dataPartitions = ReflectionUtils.computeDataPartitions(job.getJobAttempt().getInfo()); final List<String> refreshPath = ReflectionUtils.getRefreshPath(job.getJobId(), job.getData(), accelerationBasePath); final Refresh refresh = ReflectionUtils.createRefresh(reflection.getId(), refreshPath, decision.getSeriesId(), decision.getSeriesOrdinal(), updateId, details, metrics, dataPartitions); logger.trace("Refresh created: {}", refresh); materializationStore.save(refresh); logger.debug("materialization {} was written to {}", ReflectionUtils.getId(materialization), PathUtils.constructFullPath(refreshPath)); }
@POST public QueryDetails runQuery(CreateFromSQL sql) { SqlQuery query = new SqlQuery(sql.getSql(), sql.getContext(), securityContext); Job job = jobs.submitJob(JobRequest.newBuilder() .setSqlQuery(query) .setQueryType(QueryType.REST) .build(), NoOpJobStatusListener.INSTANCE); return new QueryDetails(job.getJobId().getId()); } }
@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()); }
private static QueryProfile getQueryProfile(final String query) throws JobNotFoundException { final Job job = getJobsService().submitJob(JobRequest.newBuilder() .setSqlQuery(new SqlQuery(query, DEFAULT_USERNAME)) .setQueryType(QueryType.UI_INTERNAL_RUN) .setDatasetPath(DatasetPath.NONE.toNamespaceKey()) .setDatasetVersion(DatasetVersion.NONE) .build(), new NoOpJobStatusListener()); job.getData().loadIfNecessary(); return getJobsService().getProfile(job.getJobId(), 0); }