Class FederationQueryRunner
java.lang.Object
org.apache.hadoop.yarn.server.federation.store.sql.FederationQueryRunner
QueryRunner is used to execute stored procedure SQL and parse the returned results.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClose Statement.voiddeletePolicyByQueue(Connection connection, String queue) Drop a queue from the policy.<T> Texecute(Connection conn, String procedure, ResultSetHandler<T> rsh, Object... params) Execute Stored Procedure SQL.voidfillStatement(CallableStatement stmt, Object... params) Set Statement parameters.protected CallableStatementgetCallableStatement(Connection conn, String procedure) Get CallableStatement from Conn.protected voidrethrow(SQLException cause, String sql, Object... params) Re-throw SQL exception.intselectOrUpdateSequenceTable(Connection connection, String sequenceName, boolean isUpdate) We query or update the SequenceTable.voidtruncateTable(Connection connection, String tableName) voidupdateSequenceTable(Connection connection, String sequenceName, int sequenceValue)
-
Field Details
-
YARN_ROUTER_SEQUENCE_NUM
- See Also:
-
YARN_ROUTER_CURRENT_KEY_ID
- See Also:
-
QUERY_SEQUENCE_TABLE_SQL
- See Also:
-
INSERT_SEQUENCE_TABLE_SQL
- See Also:
-
UPDATE_SEQUENCE_TABLE_SQL
- See Also:
-
DELETE_QUEUE_SQL
- See Also:
-
LOG
public static final org.slf4j.Logger LOG
-
-
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
Set Statement parameters.- Parameters:
stmt- CallableStatement.params- Stored procedure parameters.- Throws:
SQLException- An exception occurred when calling a stored procedure.
-
close
Close Statement.- Parameters:
stmt- CallableStatement.- Throws:
SQLException- An exception occurred when calling a stored procedure.
-
rethrow
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
Drop a queue from the policy.- Parameters:
connection- DB connectionqueue- queue name- Throws:
SQLException- failure
-
truncateTable
- Throws:
SQLException
-