protected CommandCreator newCommandCreator(QueryContext queryContext, AttemptObserver observer, Pointer<QueryId> prepareId) { return new CommandCreator(this.sabotContext, queryContext, tunnelCreator, queryRequest, observer, plans, prepareId, attemptId.getAttemptNum(), queryResourceManager); }
protected Foreman( final SabotContext context, final Executor executor, final CompletionListener listener, final ExternalId externalId, final QueryObserver observer, final UserSession session, final UserRequest request, final OptionProvider config, final ReAttemptHandler attemptHandler, final CoordToExecTunnelCreator tunnelCreator, Cache<Long, PreparedPlan> plans, final ResourceAllocator queryResourceManager) { this.attemptId = AttemptId.of(externalId); this.executor = executor; this.context = context; this.listener = listener; this.session = session; this.request = request; this.config = config; this.observer = observer; this.attemptHandler = attemptHandler; this.tunnelCreator = tunnelCreator; this.plans = plans; this.queryResourceManager = queryResourceManager; }
public AttemptId nextAttempt() { return new AttemptId(externalId, attempt + 1); } }
public static String toString(AttemptId attemptId) { return QueryIdHelper.getQueryId(attemptId.toQueryId()); }
@Override public QueryProfile getProfile(JobId jobId, int attempt) throws JobNotFoundException { Job job = getJob(jobId); final AttemptId attemptId = new AttemptId(JobsServiceUtil.getJobIdAsExternalId(jobId), attempt); if(jobIsDone(job.getJobAttempt())){ return profileStore.get(attemptId); } // Check if the profile for given attempt already exists. Even if the job is not done, it is possible that // profile exists for previous attempts final QueryProfile queryProfile = profileStore.get(attemptId); if (queryProfile != null) { return queryProfile; } final NodeEndpoint endpoint = job.getJobAttempt().getEndpoint(); if(endpoint.equals(identity)){ final ForemenTool tool = this.foremenTool.get(); Optional<QueryProfile> profile = tool.getProfile(attemptId.getExternalId()); return profile.orNull(); } try{ CoordTunnel tunnel = coordTunnelCreator.get().getTunnel(JobsServiceUtil.toPB(endpoint)); return tunnel.requestQueryProfile(attemptId.getExternalId()).checkedGet(15, TimeUnit.SECONDS); }catch(TimeoutException | RpcException | RuntimeException e){ logger.info("Unable to retrieve remote query profile for external id: {}", ExternalIdHelper.toString(attemptId.getExternalId()), e); return null; } }
final AttemptId attemptId = AttemptId.of(queryId); materialization.getId().getId() + "_" + attemptId.getAttemptNum());
AttemptId attemptId = AttemptId.of(externalId); job.getJobAttempt() .setAttemptId(AttemptIdUtils.toString(attemptId)) attemptId = attemptId.nextAttempt(); final JobAttempt jobAttempt = new JobAttempt() .setInfo(newJobInfo(job.getJobAttempt().getInfo(), 100L+2*i, 100L+2*i+1, "failed")) attemptId = attemptId.nextAttempt(); final JobAttempt jobAttempt = new JobAttempt() .setInfo(newJobInfo(job.getJobAttempt().getInfo(), 106, 107, null)) attemptId = AttemptId.of(externalId); for (int i = 0; i < 5; i++, attemptId = attemptId.nextAttempt()) { final AttemptDetailsUI attemptDetails = detailsUI.getAttemptDetails().get(i); final String reason = i == 0 ? "" : (i == 1 ? AttemptsUIHelper.OUT_OF_MEMORY_TEXT : AttemptsUIHelper.SCHEMA_CHANGE_TEXT);
public ExternalId getExternalId() { return attemptId.getExternalId(); }
private boolean recoverFromFailure(AttemptReason reason, Predicate<DatasetConfig> datasetValidityChecker) { // request a new attemptId attemptId = attemptId.nextAttempt(); logger.info("{}: Starting new attempt because of {}", attemptId, reason); synchronized (this) { if (canceled) { return false; // no need to run a new attempt } newAttempt(reason, datasetValidityChecker); } return true; }
/** * Convert an external id to an attempt id, assuming this is its first attempt * @param externalId * @return */ public static AttemptId of(final ExternalId externalId) { return new AttemptId(externalId, 0); }
protected AttemptManager newAttemptManager(SabotContext context, AttemptId attemptId, UserRequest queryRequest, AttemptObserver observer, UserSession session, OptionProvider options, CoordToExecTunnelCreator tunnelCreator, Cache<Long, PreparedPlan> plans, Predicate<DatasetConfig> datasetValidityChecker) { final QueryContext queryContext = new QueryContext(session, context, attemptId.toQueryId(), queryRequest.getPriority(), queryRequest.getMaxAllocation(), datasetValidityChecker); return new AttemptManager(context, attemptId, queryRequest, observer, options, tunnelCreator, plans, queryContext, queryResourceManager); }
logger.error("{}: something went wrong when re-attempting the query", attemptId.getExternalId(), e);
/** * Convert a query id to an attemp id * @param queryId * @return */ public static AttemptId of(final QueryId queryId) { ExternalId externalId = ExternalIdHelper.toExternal(queryId); int attempt = (int) (queryId.getPart2() & MASK); return new AttemptId(externalId, attempt); }
private static String toTableName(String schema1, String schema2, final AttemptId id) { return PathUtils.constructFullPath(Arrays.asList(schema1, schema2, QueryIdHelper.getQueryId(id.toQueryId()))); } }
if (attemptId.getAttemptNum() == MAX_ATTEMPTS-1) { logger.info("{}: reached maximum allowed number of attempts", attemptId); return AttemptReason.NONE; // we exceeded max allowed attempts
public static AttemptId fromString(final String attemptIdStr) { final UUID uuid = UUID.fromString(attemptIdStr); final long part1 = uuid.getMostSignificantBits(); final long part2 = uuid.getLeastSignificantBits(); final ExternalId externalId = ExternalId.newBuilder() .setPart1(part1) .setPart2(part2 & ExternalIdHelper.MASK) .build(); final int attempt = (int) part2 & 0xFF; return new AttemptId(externalId, attempt); } }
) { this.attemptId = attemptId; this.queryId = attemptId.toQueryId(); this.queryIdString = QueryIdHelper.getQueryId(queryId); this.queryRequest = queryRequest;