示例#1
0
 static String generateProceduresTable(CatalogMap<Procedure> procedures) {
   StringBuilder sb = new StringBuilder();
   for (Procedure procedure : procedures) {
     if (procedure.getDefaultproc()) {
       continue;
     }
     sb.append(generateProcedureRow(procedure));
   }
   return sb.toString();
 }
示例#2
0
  /**
   * Get some embeddable HTML of some generic catalog/application stats that is drawn on the first
   * page of the report.
   */
  static String getStatsHTML(Database db, ArrayList<Feedback> warnings) {
    StringBuilder sb = new StringBuilder();
    sb.append("<table class='table table-condensed'>\n");

    // count things
    int indexes = 0, views = 0, statements = 0;
    int partitionedTables = 0, replicatedTables = 0;
    int partitionedProcs = 0, replicatedProcs = 0;
    int readProcs = 0, writeProcs = 0;
    for (Table t : db.getTables()) {
      if (t.getMaterializer() != null) {
        views++;
      } else {
        if (t.getIsreplicated()) {
          replicatedTables++;
        } else {
          partitionedTables++;
        }
      }

      indexes += t.getIndexes().size();
    }
    for (Procedure p : db.getProcedures()) {
      // skip auto-generated crud procs
      if (p.getDefaultproc()) {
        continue;
      }

      if (p.getSinglepartition()) {
        partitionedProcs++;
      } else {
        replicatedProcs++;
      }

      if (p.getReadonly()) {
        readProcs++;
      } else {
        writeProcs++;
      }

      statements += p.getStatements().size();
    }

    // version
    sb.append("<tr><td>Compiled by VoltDB Version</td><td>");
    sb.append(VoltDB.instance().getVersionString()).append("</td></tr>\n");

    // timestamp
    sb.append("<tr><td>Compiled on</td><td>");
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
    sb.append(sdf.format(m_timestamp)).append("</td></tr>\n");

    // tables
    sb.append("<tr><td>Table Count</td><td>");
    sb.append(
        String.format(
            "%d (%d partitioned / %d replicated)",
            partitionedTables + replicatedTables, partitionedTables, replicatedTables));
    sb.append("</td></tr>\n");

    // views
    sb.append("<tr><td>Materialized View Count</td><td>").append(views).append("</td></tr>\n");

    // indexes
    sb.append("<tr><td>Index Count</td><td>").append(indexes).append("</td></tr>\n");

    // procedures
    sb.append("<tr><td>Procedure Count</td><td>");
    sb.append(
        String.format(
            "%d (%d partitioned / %d replicated) (%d read-only / %d read-write)",
            partitionedProcs + replicatedProcs,
            partitionedProcs,
            replicatedProcs,
            readProcs,
            writeProcs));
    sb.append("</td></tr>\n");

    // statements
    sb.append("<tr><td>SQL Statement Count</td><td>").append(statements).append("</td></tr>\n");
    sb.append("</table>\n\n");

    // warnings, add warning section if any
    if (warnings.size() > 0) {
      sb.append("<h4>Warnings</h4>");
      sb.append("<table class='table table-condensed'>\n");
      for (Feedback warning : warnings) {
        String procName = warning.getFileName().replace(".class", "");
        String nameLink = "";
        // not a warning during compiling procedures, must from the schema
        if (procName.compareToIgnoreCase("null") == 0) {
          String schemaName = "";
          String warningMsg = warning.getMessage().toLowerCase();
          if (warningMsg.contains("table ")) {
            int begin = warningMsg.indexOf("table ") + 6;
            int end = (warningMsg.substring(begin)).indexOf(" ");
            schemaName = warningMsg.substring(begin, begin + end);
          }
          nameLink = "<a href='#s-" + schemaName + "'>" + schemaName.toUpperCase() + "</a>";
        } else {
          nameLink = "<a href='#p-" + procName.toLowerCase() + "'>" + procName + "</a>";
        }
        sb.append("<tr><td>")
            .append(nameLink)
            .append("</td><td>")
            .append(warning.getMessage())
            .append("</td></tr>\n");
      }
      sb.append("").append("</table>\n").append("</td></tr>\n");
    }

    return sb.toString();
  }