Exemple #1
0
  /** Run and periodically report export measurements to file. */
  public void run() {
    boolean alldone;
    do {
      try {
        sleep(sleeptime);
      } catch (InterruptedException e) {
        // do nothing
      }

      alldone = true;

      // terminate this thread when all the worker threads are done
      for (Thread t : _threads) {
        if (t.getState() != Thread.State.TERMINATED) {
          alldone = false;
        }
      }

      try {
        Measurements.getMeasurements().exportMeasurementsPart(exporter);
      } catch (IOException e) {
        e.printStackTrace();
      }
    } while (!alldone);
    exportOverall();
  }
Exemple #2
0
  /**
   * Exports the measurements to either sysout or a file using the exporter loaded from conf.
   *
   * @throws IOException Either failed to write to output stream or failed to close it.
   */
  private static void exportMeasurements(Properties props, int opcount, long runtime)
      throws IOException {
    MeasurementsExporter exporter = null;
    try {
      // if no destination file is provided the results will be written to stdout
      OutputStream out;
      String exportFile = props.getProperty("exportfile");
      if (exportFile == null) {
        out = System.out;
      } else {
        out = new FileOutputStream(exportFile);
      }

      // if no exporter is provided the default text one will be used
      String exporterStr =
          props.getProperty(
              "exporter", "com.yahoo.ycsb.measurements.exporter.TextMeasurementsExporter");
      try {
        exporter =
            (MeasurementsExporter)
                Class.forName(exporterStr).getConstructor(OutputStream.class).newInstance(out);
      } catch (Exception e) {
        System.err.println(
            "Could not find exporter " + exporterStr + ", will use default text reporter.");
        e.printStackTrace();
        exporter = new TextMeasurementsExporter(out);
      }

      exporter.write("OVERALL", "RunTime(ms)", runtime);
      double throughput = 1000.0 * ((double) opcount) / ((double) runtime);
      exporter.write("OVERALL", "Throughput(ops/sec)", throughput);

      Measurements.getMeasurements().exportMeasurements(exporter);
    } finally {
      if (exporter != null) {
        exporter.close();
      }
    }
  }
Exemple #3
0
 /**
  * Cleanup any state for this DB. Called once per DB instance; there is one DB instance per client
  * thread.
  */
 @Override
 public void cleanup() throws DBException {
   // Get the measurements instance as this is the only client that should
   // count clean up time like an update if client-side buffering is
   // enabled.
   Measurements measurements = Measurements.getMeasurements();
   try {
     long st = System.nanoTime();
     if (bufferedMutator != null) {
       bufferedMutator.close();
     }
     if (currentTable != null) {
       currentTable.close();
     }
     long en = System.nanoTime();
     final String type = clientSideBuffering ? "UPDATE" : "CLEANUP";
     measurements.measure(type, (int) ((en - st) / 1000));
     connection.close();
   } catch (IOException e) {
     throw new DBException(e);
   }
 }
Exemple #4
0
 public void exportOverall() {
   try {
     Measurements.getMeasurements().exportMeasurementsFinal(exporter);
     long opcount = 0;
     long runtime = 0;
     long recon = 0;
     for (Thread t : _threads) {
       ClientThread ct = (ClientThread) t;
       opcount += ct.getOpsDone();
       if (runtime < ct.getRuntime()) {
         runtime = ct.getRuntime();
       }
       recon += ct.getReconnections();
     }
     exporter.write("OVERALL", "Reconnections", recon);
     exporter.write("OVERALL", "RunTime(ms)", runtime);
     exporter.write("OVERALL", "Operations", opcount);
     double throughput = 1000.0 * ((double) opcount) / ((double) runtime);
     exporter.write("OVERALL", "Throughput(ops/sec)", throughput);
     exporter.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Exemple #5
0
  /** Run and periodically report status. */
  public void run() {
    long st = System.currentTimeMillis();

    long lasten = st;
    long lasttotalops = 0;

    boolean alldone;
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");

    do {
      alldone = true;

      int totalops = 0;

      // terminate this thread when all the worker threads are done
      for (Thread t : _threads) {
        if (t.getState() != Thread.State.TERMINATED) {
          alldone = false;
        }

        ClientThread ct = (ClientThread) t;
        totalops += ct.getOpsDone();
      }

      long en = System.currentTimeMillis();

      long interval = en - st;
      // double throughput=1000.0*((double)totalops)/((double)interval);

      double curthroughput =
          1000.0 * (((double) (totalops - lasttotalops)) / ((double) (en - lasten)));

      lasttotalops = totalops;
      lasten = en;

      DecimalFormat d = new DecimalFormat("#.##");

      if (totalops == 0) {
        System.err.println(
            _label
                + " "
                + (interval / 1000)
                + " sec: "
                + totalops
                + " operations; "
                + Measurements.getMeasurements().getSummary());
      } else {
        System.err.println(
            _label
                + " "
                + (interval / 1000)
                + " sec: "
                + totalops
                + " operations; "
                + d.format(curthroughput)
                + " current ops/sec; "
                + Measurements.getMeasurements().getSummary());
      }

      if (_standardstatus) {
        if (totalops == 0) {
          System.out.println(
              _label
                  + " "
                  + (interval / 1000)
                  + " sec: "
                  + totalops
                  + " operations; "
                  + Measurements.getMeasurements().getSummary());
        } else {
          System.out.println(
              _label
                  + " "
                  + (interval / 1000)
                  + " sec: "
                  + totalops
                  + " operations; "
                  + d.format(curthroughput)
                  + " current ops/sec; "
                  + Measurements.getMeasurements().getSummary());
        }
      }

      try {
        sleep(sleeptime);
      } catch (InterruptedException e) {
        // do nothing
      }

    } while (!alldone);
  }