Java 类com.facebook.presto.client.QueryError 实例源码

项目:airpal    文件:Job.java   
@JsonCreator
public Job(@JsonProperty("user") final String user,
        @JsonProperty("query") final String query,
        @JsonProperty("uuid") final UUID uuid,
        @JsonProperty("output") final PersistentJobOutput output,
        @JsonProperty("queryStats") final QueryStats queryStats,
        @JsonProperty("state") final JobState state,
        @JsonProperty("columns") final List<Column> columns,
        @JsonProperty("tablesUsed") final Set<Table> tablesUsed,
        @JsonProperty("queryStarted") final DateTime queryStarted,
        @JsonProperty("error") final QueryError error,
        @JsonProperty("queryFinished") final DateTime queryFinished)
{
    this.user = user;
    this.query = query;
    this.uuid = uuid;
    this.output = output;
    this.queryStats = queryStats;
    this.state = state;
    this.columns = columns;
    this.tablesUsed = tablesUsed;
    this.queryStarted = queryStarted;
    this.error = error;
    this.queryFinished = queryFinished;
}
项目:airpal    文件:Job.java   
public Job(final String user,
        final String query,
        final UUID uuid,
        final PersistentJobOutput output,
        final QueryStats stats,
        final JobState state,
        final List<Column> columns,
        final QueryError error,
        final DateTime queryFinished)
{
    this(user,
         query,
         uuid,
         output,
         stats,
         state,
         columns,
         Sets.<Table>newConcurrentHashSet(),
         new DateTime(),
         error,
         queryFinished
    );
}
项目:presto    文件:StatementResource.java   
private static QueryError toQueryError(QueryInfo queryInfo)
{
    FailureInfo failure = queryInfo.getFailureInfo();
    if (failure == null) {
        QueryState state = queryInfo.getState();
        if ((!state.isDone()) || (state == QueryState.FINISHED)) {
            return null;
        }
        log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state);
        failure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state))).toFailureInfo();
    }

    ErrorCode errorCode;
    if (queryInfo.getErrorCode() != null) {
        errorCode = queryInfo.getErrorCode();
    }
    else {
        errorCode = INTERNAL_ERROR.toErrorCode();
        log.warn("Failed query %s has no error code", queryInfo.getQueryId());
    }
    return new QueryError(
            failure.getMessage(),
            null,
            errorCode.getCode(),
            errorCode.getName(),
            toErrorType(errorCode.getCode()).toString(),
            failure.getErrorLocation(),
            failure);
}
项目:presto    文件:BenchmarkQueryRunner.java   
private StatementStats execute(ClientSession session, String name, String query)
{
    // start query
    StatementClient client = new StatementClient(httpClient, queryResultsCodec, session, query);

    // read query output
    while (client.isValid() && client.advance()) {
        // we do not process the output
    }

    // verify final state
    if (client.isClosed()) {
        throw new IllegalStateException("Query aborted by user");
    }

    if (client.isGone()) {
        throw new IllegalStateException("Query is gone (server restarted?)");
    }

    QueryError resultsError = client.finalResults().getError();
    if (resultsError != null) {
        RuntimeException cause = null;
        if (resultsError.getFailureInfo() != null) {
            cause = resultsError.getFailureInfo().toException();
        }

        throw new BenchmarkDriverExecutionException(format("Query %s failed: %s", name, resultsError.getMessage()), cause);
    }

    return client.finalResults().getStats();
}
项目:presto    文件:PrestoResultSet.java   
static SQLException resultsException(QueryResults results)
{
    QueryError error = requireNonNull(results.getError());
    String message = format("Query failed (#%s): %s", results.getId(), error.getMessage());
    Throwable cause = (error.getFailureInfo() == null) ? null : error.getFailureInfo().toException();
    return new SQLException(message, error.getSqlState(), error.getErrorCode(), cause);
}
项目:presto    文件:Query.java   
public void renderFailure(PrintStream out)
{
    QueryResults results = client.finalResults();
    QueryError error = results.getError();
    checkState(error != null);

    out.printf("Query %s failed: %s%n", results.getId(), error.getMessage());
    if (client.isDebug() && (error.getFailureInfo() != null)) {
        error.getFailureInfo().toException().printStackTrace(out);
    }
    if (error.getErrorLocation() != null) {
        renderErrorLocation(client.getQuery(), error.getErrorLocation(), out);
    }
    out.println();
}
项目:airpal    文件:Execution.java   
/**
 * Rate Limited updateJobInfo
 */
protected void rlUpdateJobInfo(
        Set<Table> usedTables,
        List<Column> columns,
        QueryStats queryStats,
        JobState state,
        QueryError error,
        List<List<Object>> outputPreview)
{
    if (updateLimiter.tryAcquire(1)) {
        updateJobInfo(usedTables, columns, queryStats, state, error, outputPreview, true);
    } else {
        updateJobInfo(usedTables, columns, queryStats, state, error, outputPreview, false);
    }
}
项目:presto    文件:BenchmarkQueryRunner.java   
public List<String> getSchemas(ClientSession session)
{
    failures = 0;
    while (true) {
        // start query
        StatementClient client = new StatementClient(httpClient, queryResultsCodec, session, "show schemas");

        // read query output
        ImmutableList.Builder<String> schemas = ImmutableList.builder();
        while (client.isValid() && client.advance()) {
            // we do not process the output
            Iterable<List<Object>> data = client.current().getData();
            if (data != null) {
                for (List<Object> objects : data) {
                    schemas.add(objects.get(0).toString());
                }
            }
        }

        // verify final state
        if (client.isClosed()) {
            throw new IllegalStateException("Query aborted by user");
        }

        if (client.isGone()) {
            throw new IllegalStateException("Query is gone (server restarted?)");
        }

        QueryError resultsError = client.finalResults().getError();
        if (resultsError != null) {
            RuntimeException cause = null;
            if (resultsError.getFailureInfo() != null) {
                cause = resultsError.getFailureInfo().toException();
            }
            handleFailure(cause);

            continue;
        }

        return schemas.build();
    }
}
项目:airpal    文件:Execution.java   
protected void updateJobInfo(
        Set<Table> usedTables,
        List<Column> columns,
        QueryStats queryStats,
        JobState state,
        QueryError error,
        List<List<Object>> outputPreview,
        boolean postUpdate)
{
    if ((usedTables != null) && (usedTables.size() > 0)) {
        job.getTablesUsed().addAll(usedTables);
    }

    if ((columns != null) && (columns.size() > 0)) {
        job.setColumns(columns);
    }

    if (queryStats != null) {
        job.setQueryStats(queryStats);
    }

    if ((state != null) && (job.getState() != JobState.FINISHED) && (job.getState() != JobState.FAILED)) {
        job.setState(state);
    }

    if (error != null) {
        FailureInfo failureInfo = new FailureInfo(
                error.getFailureInfo().getType(),
                error.getFailureInfo().getMessage(),
                null,
                Collections.<FailureInfo>emptyList(),
                Collections.<String>emptyList(),
                error.getFailureInfo().getErrorLocation());

        QueryError queryError = new QueryError(
                error.getMessage(),
                error.getSqlState(),
                error.getErrorCode(),
                error.getErrorName(),
                error.getErrorType(),
                error.getErrorLocation(),
                failureInfo);

        job.setError(queryError);
    }

    if (postUpdate) {
        eventBus.post(new JobUpdateEvent(job, outputPreview));
    }
}