Package com.facebook.presto.execution

Examples of com.facebook.presto.execution.QueryInfo


            throws Exception
    {
        URI location = client.execute(preparePost().setUri(uriFor("/v1/query")).setBodyGenerator(createStaticBodyGenerator("query", UTF_8)).build(), new CreatedResponseHandler());
        assertQueryStatus(location, QueryState.RUNNING);

        QueryInfo queryInfo = client.execute(prepareGet().setUri(location).build(), createJsonResponseHandler(jsonCodec(QueryInfo.class)));
        TaskInfo taskInfo = queryInfo.getOutputStage().getTasks().get(0);
        URI outputLocation = uriFor("/v1/task/" + taskInfo.getTaskId() + "/results/out");

        long sequenceId = 0;
        PagesResponse response = client.execute(
                prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
View Full Code Here


        JsonResponse<QueryInfo> response = client.execute(prepareGet().setUri(statusUri).build(), createFullJsonResponseHandler(jsonCodec(QueryInfo.class)));
        if (expectedQueryState == QueryState.FINISHED && response.getStatusCode() == HttpStatus.GONE.code()) {
            // when query finishes the server may delete it
            return;
        }
        QueryInfo queryInfo = response.getValue();
        assertEquals(queryInfo.getState(), expectedQueryState);
    }
View Full Code Here

                    state = QueryState.FAILED;
                    break;
                default:
                    throw new IllegalStateException("Unknown task state " + outputTask.getState());
            }
            return new QueryInfo(outputTaskId.getQueryId(),
                    TEST_SESSION,
                    state,
                    self,
                    ImmutableList.of("out"),
                    "query",
View Full Code Here

            checkNotNull(exchangeClient, "exchangeClient is null");

            this.session = session;
            this.queryManager = queryManager;

            QueryInfo queryInfo = queryManager.createQuery(session, query);
            queryId = queryInfo.getQueryId();
            this.exchangeClient = exchangeClient;
        }
View Full Code Here

        {
            Iterable<List<Object>> data = getData(maxWaitTime);

            // get the query info before returning
            // force update if query manager is closed
            QueryInfo queryInfo = queryManager.getQueryInfo(queryId);

            // if we have received all of the output data and the query is not marked as done, wait for the query to finish
            if (exchangeClient.isClosed() && !queryInfo.getState().isDone()) {
                queryManager.waitForStateChange(queryId, queryInfo.getState(), maxWaitTime);
                queryInfo = queryManager.getQueryInfo(queryId);
            }

            // close exchange client if the query has failed
            if (queryInfo.getState().isDone()) {
                if (queryInfo.getState() != QueryState.FINISHED) {
                    exchangeClient.close();
                }
                else if (queryInfo.getOutputStage() == null) {
                    // For simple executions (e.g. drop table), there will never be an output stage,
                    // so close the exchange as soon as the query is done.
                    exchangeClient.close();

                    // this is a hack to suppress the warn message in the client saying that there are no columns.
                    // The reason for this is that the current API definition assumes that everything is a query,
                    // so statements without results produce an error in the client otherwise.
                    //
                    // TODO: add support to the API for non-query statements.
                    columns = ImmutableList.of(new Column("result", "varchar"));
                    data = ImmutableSet.<List<Object>>of(ImmutableList.<Object>of("true"));
                }
            }

            // only return a next if the query is not done or there is more data to send (due to buffering)
            URI nextResultsUri = null;
            if ((!queryInfo.getState().isDone()) || (!exchangeClient.isClosed())) {
                nextResultsUri = createNextResultsUri(uriInfo);
            }

            // first time through, self is null
            QueryResults queryResults = new QueryResults(
                    queryId.toString(),
                    uriInfo.getRequestUriBuilder().replaceQuery("").replacePath(queryInfo.getSelf().getPath()).build(),
                    findCancelableLeafStage(queryInfo),
                    nextResultsUri,
                    columns,
                    data,
                    toStatementStats(queryInfo),
View Full Code Here

        private synchronized Iterable<List<Object>> getData(Duration maxWait)
                throws InterruptedException
        {
            // wait for query to start
            QueryInfo queryInfo = queryManager.getQueryInfo(queryId);
            while (maxWait.toMillis() > 1 && !isQueryStarted(queryInfo)) {
                maxWait = queryManager.waitForStateChange(queryId, queryInfo.getState(), maxWait);
                queryInfo = queryManager.getQueryInfo(queryId);
            }

            // if query did not finish starting or does not have output, just return
            if (!isQueryStarted(queryInfo) || queryInfo.getOutputStage() == null) {
                return null;
            }

            if (columns == null) {
                columns = createColumnsList(queryInfo);
            }

            updateExchangeClient(queryInfo.getOutputStage());

            ImmutableList.Builder<RowIterable> pages = ImmutableList.builder();
            // wait up to max wait for data to arrive; then try to return at least DESIRED_RESULT_BYTES
            int bytes = 0;
            while (bytes < DESIRED_RESULT_BYTES) {
View Full Code Here

            throws Exception
    {
        URI location = client.execute(preparePost().setUri(uriFor("/v1/query")).setBodyGenerator(createStaticBodyGenerator("query", UTF_8)).build(), new CreatedResponseHandler());
        assertQueryStatus(location, QueryState.RUNNING);

        QueryInfo queryInfo = client.execute(prepareGet().setUri(location).build(), createJsonResponseHandler(jsonCodec(QueryInfo.class)));
        TaskInfo taskInfo = queryInfo.getOutputStage().getTasks().get(0);
        URI outputLocation = uriFor("/v1/task/" + taskInfo.getTaskId() + "/results/out");

        long sequenceId = 0;
        PagesResponse response = client.execute(
                prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
View Full Code Here

        JsonResponse<QueryInfo> response = client.execute(prepareGet().setUri(statusUri).build(), createFullJsonResponseHandler(jsonCodec(QueryInfo.class)));
        if (expectedQueryState == QueryState.FINISHED && response.getStatusCode() == HttpStatus.GONE.code()) {
            // when query finishes the server may delete it
            return;
        }
        QueryInfo queryInfo = response.getValue();
        assertEquals(queryInfo.getState(), expectedQueryState);
    }
View Full Code Here

            throws Exception
    {
        URI location = client.execute(preparePost().setUri(uriFor("/v1/query")).setBodyGenerator(createStaticBodyGenerator("query", UTF_8)).build(), new CreatedResponseHandler());
        assertQueryStatus(location, QueryState.RUNNING);

        QueryInfo queryInfo = client.execute(prepareGet().setUri(location).build(), createJsonResponseHandler(jsonCodec(QueryInfo.class)));
        TaskInfo taskInfo = queryInfo.getOutputStage().getTasks().get(0);
        URI outputLocation = uriFor("/v1/task/" + taskInfo.getTaskId() + "/results/out");

        long sequenceId = 0;
        PagesResponse response = client.execute(
                prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
View Full Code Here

        JsonResponse<QueryInfo> response = client.execute(prepareGet().setUri(statusUri).build(), createFullJsonResponseHandler(jsonCodec(QueryInfo.class)));
        if (expectedQueryState == QueryState.FINISHED && response.getStatusCode() == HttpStatus.GONE.code()) {
            // when query finishes the server may delete it
            return;
        }
        QueryInfo queryInfo = response.getValue();
        assertEquals(queryInfo.getState(), expectedQueryState);
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.execution.QueryInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.