Class FederationQueryRunner

java.lang.Object
org.apache.hadoop.yarn.server.federation.store.sql.FederationQueryRunner

public class FederationQueryRunner extends Object
QueryRunner is used to execute stored procedure SQL and parse the returned results.
  • Field Details

  • Constructor Details

    • FederationQueryRunner

      public FederationQueryRunner()
  • Method Details

    • execute

      public <T> T execute(Connection conn, String procedure, ResultSetHandler<T> rsh, Object... params) throws SQLException
      Execute Stored Procedure SQL.
      Type Parameters:
      T - Generic T.
      Parameters:
      conn - Database Connection.
      procedure - Stored Procedure SQL.
      rsh - Result Set handler.
      params - List of stored procedure parameters.
      Returns:
      Stored Procedure Result Set.
      Throws:
      SQLException - An exception occurred when calling a stored procedure.
    • getCallableStatement

      @VisibleForTesting protected CallableStatement getCallableStatement(Connection conn, String procedure) throws SQLException
      Get CallableStatement from Conn.
      Parameters:
      conn - Database Connection.
      procedure - Stored Procedure SQL.
      Returns:
      CallableStatement.
      Throws:
      SQLException - An exception occurred when calling a stored procedure.
    • fillStatement

      public void fillStatement(CallableStatement stmt, Object... params) throws SQLException
      Set Statement parameters.
      Parameters:
      stmt - CallableStatement.
      params - Stored procedure parameters.
      Throws:
      SQLException - An exception occurred when calling a stored procedure.
    • close

      public void close(Statement stmt) throws SQLException
      Close Statement.
      Parameters:
      stmt - CallableStatement.
      Throws:
      SQLException - An exception occurred when calling a stored procedure.
    • rethrow

      protected void rethrow(SQLException cause, String sql, Object... params) throws SQLException
      Re-throw SQL exception.
      Parameters:
      cause - SQLException.
      sql - Stored Procedure SQL.
      params - Stored procedure parameters.
      Throws:
      SQLException - An exception occurred when calling a stored procedure.
    • selectOrUpdateSequenceTable

      public int selectOrUpdateSequenceTable(Connection connection, String sequenceName, boolean isUpdate) throws SQLException
      We query or update the SequenceTable.
      Parameters:
      connection - database conn.
      sequenceName - sequenceName, We currently have 2 sequences, YARN_ROUTER_SEQUENCE_NUM and YARN_ROUTER_CURRENT_KEY_ID.
      isUpdate - true, means we will update the SequenceTable, false, we query the SequenceTable.
      Returns:
      SequenceValue.
      Throws:
      SQLException - An exception occurred when calling a stored procedure.
    • updateSequenceTable

      public void updateSequenceTable(Connection connection, String sequenceName, int sequenceValue) throws SQLException
      Throws:
      SQLException
    • deletePolicyByQueue

      public void deletePolicyByQueue(Connection connection, String queue) throws SQLException
      Drop a queue from the policy.
      Parameters:
      connection - DB connection
      queue - queue name
      Throws:
      SQLException - failure
    • truncateTable

      public void truncateTable(Connection connection, String tableName) throws SQLException
      Throws:
      SQLException