Exemple #1
0
 protected String getExceptionMessage(Exception e) {
   String className = e.getClass().getSimpleName();
   String message =
       (e instanceof InvalidRequestException)
           ? ((InvalidRequestException) e).getWhy()
           : e.getMessage();
   return (message == null)
       ? "(" + className + ")"
       : String.format("(%s): %s", className, message);
 }
Exemple #2
0
  public void timeWithRetry(RunOp run) throws IOException {
    timer.start();

    boolean success = false;
    String exceptionMessage = null;

    int tries = 0;
    for (; tries < settings.errors.tries; tries++) {
      try {
        success = run.run();
        break;
      } catch (Exception e) {
        switch (settings.log.level) {
          case MINIMAL:
            break;

          case NORMAL:
            System.err.println(e);
            break;

          case VERBOSE:
            e.printStackTrace(System.err);
            break;

          default:
            throw new AssertionError();
        }
        exceptionMessage = getExceptionMessage(e);
      }
    }

    timer.stop(run.partitionCount(), run.rowCount());

    if (!success) {
      error(
          String.format(
              "Operation x%d on key(s) %s: %s%n",
              tries,
              key(),
              (exceptionMessage == null)
                  ? "Data returned was not validated"
                  : "Error executing: " + exceptionMessage));
    }
  }