private QueryProfile recordProfile(OutputStream out, JobId id, int attempt) throws IOException, JobNotFoundException { QueryProfile profile = jobsService.get().getProfile(id, attempt); ProtostuffUtil.toJSON(out, profile, SchemaUserBitShared.QueryProfile.WRITE, false); return profile; }
@GET @Path("/{queryid}.json") @Produces(APPLICATION_JSON) public String getProfileJSON(@PathParam("queryid") String queryId, @QueryParam("attempt") @DefaultValue("0") int attempt) throws IOException { final QueryProfile profile; try { profile = jobsService.getProfile(new JobId(queryId), attempt); } catch (JobNotFoundException ignored) { // TODO: should this be JobResourceNotFoundException? throw new NotFoundException(format("Profile for JobId [%s] and Attempt [%d] not found.", queryId, attempt)); } return new String(SERIALIZER.serialize(profile)); }
@GET @Path("/{queryid}") @Produces(TEXT_HTML) public Viewable getProfile(@PathParam("queryid") String queryId, @QueryParam("attempt") @DefaultValue("0") int attempt) { final QueryProfile profile; try { profile = jobsService.getProfile(new JobId(queryId), attempt); } catch (JobNotFoundException ignored) { // TODO: should this be JobResourceNotFoundException? throw new NotFoundException(format("Profile for JobId [%s] and Attempt [%d] not found.", queryId, attempt)); } final boolean debug = context.getOptionManager().getOption(ExecConstants.DEBUG_QUERY_PROFILE); return renderProfile(profile, debug); }
private boolean recordHeader(OutputStream output, JobId id, User user, String submissionId) throws UserNotFoundException, IOException, JobNotFoundException { SupportHeader header = new SupportHeader(); header.setClusterInfo(getClusterInfo()); header.setJob(jobsService.get().getJob(id).getJobAttempt()); Submission submission = new Submission() .setSubmissionId(submissionId) .setDate(System.currentTimeMillis()) .setEmail(user.getEmail()) .setFirst(user.getFirstName()) .setLast(user.getLastName()); header.setSubmission(submission); // record the dremio version that was used to run the query in the header header.setDremioVersion(jobsService.get().getProfile(id, 0).getDremioVersion()); ProtostuffUtil.toJSON(output, header, SupportHeader.getSchema(), false); return true; }
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); }