Java Code Examples for org.influxdb.dto.QueryResult.Result#getError()

The following examples show how to use org.influxdb.dto.QueryResult.Result#getError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InfluxDbSources.java    From hazelcast-jet-contrib with Apache License 2.0 6 votes vote down vote up
private static boolean throwExceptionIfResultWithErrorOrNull(final QueryResult queryResult) {
    if (queryResult == null) {
        throw new RuntimeException("InfluxDB returned null query result");
    }
    if (queryResult.getResults() == null && "DONE".equals(queryResult.getError())) {
        return true;
    }
    if (queryResult.getError() != null) {
        throw new RuntimeException("InfluxDB returned an error: " + queryResult.getError());
    }
    if (queryResult.getResults() == null) {
        throw new RuntimeException("InfluxDB returned null query results");
    }
    for (Result seriesResult : queryResult.getResults()) {
        if (seriesResult.getError() != null) {
            throw new RuntimeException("InfluxDB returned an error with Series: " + seriesResult.getError());
        }
    }
    return false;
}
 
Example 2
Source File: InfluxDB.java    From iotdb-benchmark with Apache License 2.0 6 votes vote down vote up
private Status executeQueryAndGetStatus(String sql) {
  LOGGER.debug("{} query SQL: {}", Thread.currentThread().getName(), sql);

  QueryResult results = influxDbInstance.query(new Query(sql, influxDbName));
  int cnt = 0;
  for (Result result : results.getResults()) {
    List<Series> series = result.getSeries();
    if (series == null) {
      continue;
    }
    if (result.getError() != null) {
      return new Status(false, cnt, new Exception(result.getError()), sql);
    }
    for (Series serie : series) {
      List<List<Object>> values = serie.getValues();
      cnt += values.size() * (serie.getColumns().size() - 1);
    }
  }

  LOGGER.debug("{} 查到数据点数: {}", Thread.currentThread().getName(), cnt);
  return new Status(true, cnt);
}