src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/HsqlDriver.java
public void createTable() throws SQLException {
    String sqlCreate =
        "CREATE CACHED TABLE IF NOT EXISTS HISTORY"
            + "  (ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) "
            + "   NOT NULL PRIMARY KEY,"
            + "   STDATE TIMESTAMP NOT NULL,"
            + "   SYS_DATE DATE NOT NULL,"
            + "   EMPTYDIRS BIGINT,"
            + "   TINYFILES BIGINT,"
            + "   EMPTYFILES BIGINT,"
            + "   SMALLFILES BIGINT,"
            + "   DISKSPACE BIGINT,"
            + "   NUMFILES BIGINT,"
            + "   NUMDIRS BIGINT,"
            + "   USER VARCHAR(100) NOT NULL)";
    try (PreparedStatement preparedStatement = con.prepareStatement(sqlCreate)) {
      preparedStatement.execute();
    }

    String columnCheck =
        "SELECT COUNT(*) AS \"Count\" FROM INFORMATION_SCHEMA.SYSTEM_COLUMNS "
            + "WHERE TABLE_NAME = 'HISTORY' and COLUMN_NAME = 'MEDIUMFILES'";
    boolean columnExists = false;
    try (PreparedStatement colCheckStatement = con.prepareStatement(columnCheck)) {
      try (ResultSet resultSet = colCheckStatement.executeQuery()) {
        while (resultSet.next()) {
          columnExists = (resultSet.getInt(1) != 0);
        }
      }
    }

    if (!columnExists) {
      LOG.info("Adding MediumFiles to History embedded DB table.");
      String addColumn = "ALTER TABLE HISTORY ADD MEDIUMFILES BIGINT";
      try (PreparedStatement columnStatement = con.prepareStatement(addColumn)) {
        columnStatement.execute();
      }
    }
    con.commit();
  }
/**
   * Create the table for maintaining embedded DB trending data.
   *
   * @throws SQLException error in creating table
   */
Create the table for maintaining embedded DB trending data.
@throws SQLException error in creating table
Create the table for maintaining embedded DB trending data . @throws SQLException error in creating table
public void createTable() throws SQLException {
    String sqlCreate =
        "CREATE CACHED TABLE IF NOT EXISTS HISTORY"
            + "  (ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) "
            + "   NOT NULL PRIMARY KEY,"
            + "   STDATE TIMESTAMP NOT NULL,"
            + "   SYS_DATE DATE NOT NULL,"
            + "   EMPTYDIRS BIGINT,"
            + "   TINYFILES BIGINT,"
            + "   EMPTYFILES BIGINT,"
            + "   SMALLFILES BIGINT,"
            + "   DISKSPACE BIGINT,"
            + "   NUMFILES BIGINT,"
            + "   NUMDIRS BIGINT,"
            + "   USER VARCHAR(100) NOT NULL)";
    try (PreparedStatement preparedStatement = con.prepareStatement(sqlCreate)) {
      preparedStatement.execute();
    }
    String columnCheck =
        "SELECT COUNT(*) AS \"Count\" FROM INFORMATION_SCHEMA.SYSTEM_COLUMNS "
            + "WHERE TABLE_NAME = 'HISTORY' and COLUMN_NAME = 'MEDIUMFILES'";
    boolean columnExists = false;
    try (PreparedStatement colCheckStatement = con.prepareStatement(columnCheck)) {
      try (ResultSet resultSet = colCheckStatement.executeQuery()) {
        while (resultSet.next()) {
          columnExists = (resultSet.getInt(1) != 0);
        }
      }
    }
    if (!columnExists) {
      LOG.info("Adding MediumFiles to History embedded DB table.");
      String addColumn = "ALTER TABLE HISTORY ADD MEDIUMFILES BIGINT";
      try (PreparedStatement columnStatement = con.prepareStatement(addColumn)) {
        columnStatement.execute();
      }
    }
    con.commit();
  }
public void createTable ( ) throws SQLException { String sqlCreate = "CREATE CACHED TABLE IF NOT EXISTS HISTORY" + "  (ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) " + "   NOT NULL PRIMARY KEY," + "   STDATE TIMESTAMP NOT NULL," + "   SYS_DATE DATE NOT NULL," + "   EMPTYDIRS BIGINT," + "   TINYFILES BIGINT," + "   EMPTYFILES BIGINT," + "   SMALLFILES BIGINT," + "   DISKSPACE BIGINT," + "   NUMFILES BIGINT," + "   NUMDIRS BIGINT," + "   USER VARCHAR(100) NOT NULL)" ; try ( PreparedStatement preparedStatement = con . prepareStatement ( sqlCreate ) ) { preparedStatement . execute ( ) ; } String columnCheck = "SELECT COUNT(*) AS \"Count\" FROM INFORMATION_SCHEMA.SYSTEM_COLUMNS " + "WHERE TABLE_NAME = 'HISTORY' and COLUMN_NAME = 'MEDIUMFILES'" ; boolean columnExists = false ; try ( PreparedStatement colCheckStatement = con . prepareStatement ( columnCheck ) ) { try ( ResultSet resultSet = colCheckStatement . executeQuery ( ) ) { while ( resultSet . next ( ) ) { columnExists = ( resultSet . getInt ( 1 ) != 0 ) ; } } } if ( ! columnExists ) { LOG . info ( "Adding MediumFiles to History embedded DB table." ) ; String addColumn = "ALTER TABLE HISTORY ADD MEDIUMFILES BIGINT" ; try ( PreparedStatement columnStatement = con . prepareStatement ( addColumn ) ) { columnStatement . execute ( ) ; } } con . commit ( ) ; }
Create the table for maintaining embedded DB trending data.
Create the table for maintaining embedded DB trending data .