コード例 #1
0
  public void handleQuery(Query query) throws IOException {
    log.info("Reporting query statatistics");
    bout.write(query.getIdentifier() + ";");

    MonitoringService m = MonitoringUtil.getMonitoringService();
    try {
      int total = 0;
      for (Endpoint e : endpoints) {
        try {
          MonitoringInformation mInfo = m.getMonitoringInformation(e);
          int requestCount = mInfo != null ? mInfo.getNumberOfRequests() : 0;

          total += requestCount;

          log.info("## " + e.getId() + " => " + requestCount + " requests");
          bout.write(requestCount + ";");
        } catch (Exception ex) {
          log.warn("Exception (" + ex.getClass() + "):" + ex.getMessage());
          bout.write("-1;");
        }
      }
      bout.write(total + ";");
      bout.write("\r\n");
      bout.flush();
    } finally {
      m.resetMonitoringInformation();
    }
  }
コード例 #2
0
ファイル: SesameEvaluation.java プロジェクト: semagrow/kobe
  @Override
  public int runQueryDebug(Query q, int run, boolean showResult) throws Exception {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, q.getQuery());
    TupleQueryResult res = (TupleQueryResult) query.evaluate();
    int resCounter = 0;

    TupleQueryResultWriter writer = null;
    boolean writerStarted = false;

    if (showResult) {
      OutputStream results =
          new FileOutputStream(
              Config.getConfig().getBaseDir()
                  + "/result/"
                  + q.getIdentifier()
                  + "_"
                  + run
                  + ".csv");
      TupleQueryResultWriterFactory factory = new SPARQLResultsCSVWriterFactory();
      writer = factory.getWriter(results);
    }

    while (res.hasNext()) {
      if (isInterrupted()) throw new QueryEvaluationException("Thread has been interrupted.");
      BindingSet bindings = res.next();
      if (showResult) {
        if (!writerStarted) {
          writer.startQueryResult(res.getBindingNames());
          writerStarted = true;
        }

        writer.handleSolution(bindings);
      }

      resCounter++;
      earlyResults.handleResult(bindings, resCounter);
    }

    if (writerStarted) writer.endQueryResult();

    return resCounter;
  }
コード例 #3
0
ファイル: SesameEvaluation.java プロジェクト: semagrow/kobe
  @Override
  public int runQuery(Query q, int run) throws Exception {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, q.getQuery());
    TupleQueryResult res = (TupleQueryResult) query.evaluate();
    int resCounter = 0;

    try {
      while (res.hasNext()) {
        if (isInterrupted()) throw new QueryEvaluationException("Thread has been interrupted.");
        BindingSet bindings = res.next();
        resCounter++;
        earlyResults.handleResult(bindings, resCounter);
      }
    } finally {
      res.close();
    }
    return resCounter;
  }