/**
  * Add data to ES given a query execution service
  *
  * @param qExec query execution service
  */
 private void harvest(QueryExecution qExec) {
   boolean retry;
   do {
     retry = false;
     try {
       Model model = getModel(qExec);
       addModelToES(model, client.prepareBulk(), true);
     } catch (QueryExceptionHTTP e) {
       if (e.getResponseCode() >= 500) {
         retry = true;
         logger.error("Encountered an internal server error " + "while harvesting. Retrying!");
       } else {
         throw e;
       }
     }
   } while (retry);
 }
 protected Model executeConstructQuery(String query) {
   logger.trace("Sending query\n{} ...", query);
   QueryExecution qe = qef.createQueryExecution(query);
   try {
     Model model = qe.execConstruct();
     timeout = false;
     if (model.size() == 0) {
       fullDataLoaded = true;
     }
     logger.debug("Got " + model.size() + " triples.");
     return model;
   } catch (QueryExceptionHTTP e) {
     if (e.getCause() instanceof SocketTimeoutException) {
       logger.warn("Got timeout");
     } else {
       logger.error("Exception executing query", e);
     }
     return ModelFactory.createDefaultModel();
   }
 }
  protected ResultSet executeSelectQuery(String query) {
    logger.trace("Sending query\n{} ...", query);

    QueryExecution qe = qef.createQueryExecution(query);
    try {
      ResultSet rs = qe.execSelect();
      timeout = false;
      return rs;
    } catch (QueryExceptionHTTP e) {
      if (e.getCause() instanceof SocketTimeoutException) {
        if (timeout) {
          logger.warn("Got timeout");
          throw e;
        } else {
          logger.trace("Got local timeout");
        }

      } else {
        logger.error("Exception executing query", e);
      }
      return new ResultSetMem();
    }
  }
Beispiel #4
0
 public static void ARQ_Exception(Source source, QueryExceptionHTTP ie) {
   throw new EldaException(
       "Problem running query for " + source + ": " + ie.getMessage(), "", SERVER_ERROR, ie);
 }