Esempio n. 1
0
  private static List<Column> getColumns(StatementClient client) {
    while (client.isValid()) {
      List<Column> columns = client.current().getColumns();
      if (columns != null) {
        return columns;
      }
      client.advance();
    }

    if (!client.isFailed()) {
      throw internalServerError("No columns");
    }
    throw internalServerError(failureMessage(client.finalResults()));
  }
Esempio n. 2
0
    @Override
    protected Iterable<List<Object>> computeNext() {
      while (client.isValid()) {
        Iterable<List<Object>> data = client.current().getData();
        client.advance();
        if (data != null) {
          return data;
        }
      }

      if (client.isFailed()) {
        throw internalServerError(failureMessage(client.finalResults()));
      }

      return endOfData();
    }
Esempio n. 3
0
  public void printInitialStatusUpdates() {
    long lastPrint = System.nanoTime();
    try {
      while (client.isValid()) {
        try {
          // exit status loop if there is there is pending output
          if (client.current().getData() != null) {
            return;
          }

          // check if time to update screen
          boolean update = nanosSince(lastPrint).getValue(SECONDS) >= 0.5;

          // check for keyboard input
          int key = readKey();
          if (key == CTRL_P) {
            partialCancel();
          } else if (key == CTRL_C) {
            updateScreen();
            update = false;
            client.close();
          } else if (toUpperCase(key) == 'D') {
            debug = !debug;
            console.resetScreen();
            update = true;
          }

          // update screen
          if (update) {
            updateScreen();
            lastPrint = System.nanoTime();
          }

          // fetch next results (server will wait for a while if no data)
          client.advance();
        } catch (RuntimeException e) {
          log.debug(e, "error printing status");
          if (debug) {
            e.printStackTrace(out);
          }
        }
      }
    } finally {
      console.resetScreen();
    }
  }
Esempio n. 4
0
 private void waitForData() {
   while (client.isValid() && (client.current().getData() == null)) {
     client.advance();
   }
 }