Exemplo n.º 1
0
  public boolean killQuery(QueryId queryId) throws ServiceException, IOException {

    QueryStatus status = getQueryStatus(queryId);

    try {
      /* send a kill to the TM */
      service.killQuery(null, queryId.getProto());
      long currentTimeMillis = System.currentTimeMillis();
      long timeKillIssued = currentTimeMillis;
      while ((currentTimeMillis < timeKillIssued + 10000L)
          && (status.getState() != QueryState.QUERY_KILLED)) {
        try {
          Thread.sleep(1000L);
        } catch (InterruptedException ie) {
          /** interrupted, just break */
          break;
        }
        currentTimeMillis = System.currentTimeMillis();
        status = getQueryStatus(queryId);
      }
    } catch (ServiceException io) {
      LOG.debug("Error when checking for application status", io);
      return false;
    }

    return true;
  }
Exemplo n.º 2
0
  public ResultSet getQueryResultAndWait(QueryId queryId) throws ServiceException, IOException {
    if (queryId.equals(TajoIdUtils.NullQueryId)) {
      return null;
    }
    QueryStatus status = getQueryStatus(queryId);

    while (status != null && isQueryRunnning(status.getState())) {
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      status = getQueryStatus(queryId);
    }

    if (status.getState() == QueryState.QUERY_SUCCEEDED) {
      if (status.hasResult()) {
        return getQueryResult(queryId);
      } else {
        return null;
      }

    } else {
      LOG.error(status.getErrorMessage());

      return null;
    }
  }