Package org.apache.drill.exec.proto.UserBitShared

Examples of org.apache.drill.exec.proto.UserBitShared.QueryResult


//      logger.debug("Screen Outcome {}", outcome);
      switch(outcome){
      case STOP: {
          sendCount.waitForSendComplete();
        boolean verbose = context.getOptions().getOption(ExecConstants.ENABLE_VERBOSE_ERRORS_KEY).bool_val;
        QueryResult header = QueryResult.newBuilder() //
              .setQueryId(context.getHandle().getQueryId()) //
              .setRowCount(0) //
              .setQueryState(QueryState.FAILED)
              .addError(ErrorHelper.logAndConvertError(context.getIdentity(), "Screen received stop request sent.",
                context.getFailureCause(), logger, verbose))
              .setDef(RecordBatchDef.getDefaultInstance()) //
              .setIsLastChunk(true) //
              .build();
          QueryWritableBatch batch = new QueryWritableBatch(header);
          stats.startWait();
          try {
            connection.sendResult(listener, batch);
          } finally {
            stats.stopWait();
          }
          sendCount.increment();

          return false;
      }
      case NONE: {
        sendCount.waitForSendComplete();
//        context.getStats().batchesCompleted.inc(1);
        QueryWritableBatch batch;
        if (!first) {
          QueryResult header = QueryResult.newBuilder() //
              .setQueryId(context.getHandle().getQueryId()) //
              .setRowCount(0) //
              .setDef(RecordBatchDef.getDefaultInstance()) //
              .setIsLastChunk(true) //
              .build();
View Full Code Here


    List<SerializedField> fields = Lists.newArrayList();
    for (MaterializedField field : schema) {
      fields.add(field.getAsBuilder().build());
    }
    RecordBatchDef def = RecordBatchDef.newBuilder().addAllField(fields).build();
    QueryResult header = QueryResult.newBuilder() //
            .setQueryId(queryId) //
            .setRowCount(rowCount) //
            .setDef(def) //
            .setIsLastChunk(isLastChunk) //
            .build();
View Full Code Here

      logger.warn("Tried to update query state to FAILED, but was not RUNNING");
    }

    boolean verbose = getContext().getOptions().getOption(ExecConstants.ENABLE_VERBOSE_ERRORS_KEY).bool_val;
    DrillPBError error = ErrorHelper.logAndConvertError(context.getCurrentEndpoint(), message, t, logger, verbose);
    QueryResult result = QueryResult //
        .newBuilder() //
        .addError(error) //
        .setIsLastChunk(true) //
        .setQueryState(QueryState.FAILED) //
        .setQueryId(queryId) //
View Full Code Here

    }

    // cancel remote fragments.
    fragmentManager.cancel();

    QueryResult result = QueryResult.newBuilder().setQueryState(QueryState.CANCELED).setIsLastChunk(true).setQueryId(queryId).build();
    cleanupAndSendResult(result);
  }
View Full Code Here

  private void finished(FragmentStatus status){
    int remaining = remainingFragmentCount.decrementAndGet();
    if(remaining == 0){
      logger.info("Outcome status: {}", this.status);
      QueryResult result = QueryResult.newBuilder() //
              .setQueryState(QueryState.COMPLETED) //
              .setQueryId(queryId) //
              .build();
      foremanManagerListener.cleanupAndSendResult(result);
      workBus.removeFragmentStatusListener(queryId);
View Full Code Here

    updateStatus(status, true);
  }

  private void fail(FragmentStatus status){
    stopQuery();
    QueryResult result = QueryResult.newBuilder().setQueryId(queryId).setQueryState(QueryState.FAILED).addError(status.getProfile().getError()).build();
    foremanManagerListener.cleanupAndSendResult(result);
    this.status.setEndTime(System.currentTimeMillis());
    updateStatus(status, true);
  }
View Full Code Here

  public RpcOutcomeListener<QueryId> getWrappedListener(UserResultsListener listener){
    return new SubmissionListener(listener);
  }

  public void batchArrived(ConnectionThrottle throttle, ByteBuf pBody, ByteBuf dBody) throws RpcException {
    final QueryResult result = RpcBus.get(pBody, QueryResult.PARSER);
    final QueryResultBatch batch = new QueryResultBatch(result, dBody);
    final boolean failed = (batch.getHeader().getQueryState() == QueryState.FAILED);

    assert failed || batch.getHeader().getErrorCount() == 0 : "Error count for the query batch is non-zero but QueryState != FAILED";

    UserResultsListener l = resultsListener.get(result.getQueryId());
    // logger.debug("For QueryId [{}], retrieved result listener {}", result.getQueryId(), l);
    if (l == null) {
      BufferingListener bl = new BufferingListener();
      l = resultsListener.putIfAbsent(result.getQueryId(), bl);
      // if we had a succesful insert, use that reference.  Otherwise, just throw away the new bufering listener.
      if (l == null) l = bl;
      if (result.getQueryId().toString().equals("")) {
        failAll();
      }
    }

    if(failed) {
      String message = buildErrorMessage(batch);
      l.submissionFailed(new RpcException(message));
      resultsListener.remove(result.getQueryId(), l);
    }else{
      try {
        l.resultArrived(batch, throttle);
      } catch (Exception e) {
        batch.release();
        l.submissionFailed(new RpcException(e));
      }
    }

    if (
        (failed || result.getIsLastChunk())
        &&
        (!(l instanceof BufferingListener) || ((BufferingListener)l).output != null)
        ) {
      resultsListener.remove(result.getQueryId(), l);
    }
  }
View Full Code Here

  public QueryWritableBatch convertNext(boolean isLast) {
    //batch.getWritableBatch().getDef().getRecordCount()
    WritableBatch w = batch.getWritableBatch();

    QueryResult header = QueryResult.newBuilder() //
        .setQueryId(queryId) //
        .setRowCount(batch.getRecordCount()) //
        .setDef(w.getDef()).setIsLastChunk(isLast).build();
    QueryWritableBatch batch = new QueryWritableBatch(header, w.getBuffers());
    return batch;
View Full Code Here

  private void finished(FragmentStatus status){
    int remaining = remainingFragmentCount.decrementAndGet();
    if(remaining == 0){
      logger.info("Outcome status: {}", this.status);
      QueryResult result = QueryResult.newBuilder() //
              .setQueryState(QueryState.COMPLETED) //
              .setQueryId(queryId) //
              .build();
      this.status.setEndTime(System.currentTimeMillis());
      foremanManagerListener.cleanupAndSendResult(result);
View Full Code Here

    logger.warn("Fragment faild : {}", status);
    updateFragmentStatus(status);
    int failed = this.failedFragmentCount.incrementAndGet();
    if (failed == 1) { // only first failed fragment need notify foreman (?)
      stopQuery();
      QueryResult result = QueryResult.newBuilder().setQueryId(queryId).setQueryState(QueryState.FAILED).addError(status.getProfile().getError()).build();
      foremanManagerListener.cleanupAndSendResult(result);
      this.status.setEndTime(System.currentTimeMillis());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.proto.UserBitShared.QueryResult

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.