YARN-11328. Refactoring part of the code of SQLFederationStateStore. (#4976)

This commit is contained in:
slfan1989 2022-10-20 07:11:28 +08:00 committed by GitHub
parent 8aa04b0b24
commit 48b6f9f335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 351 additions and 387 deletions

View File

@ -24,10 +24,10 @@ IF OBJECT_ID ( '[sp_addApplicationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_addApplicationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_addApplicationHomeSubCluster]
@applicationId VARCHAR(64), @applicationId_IN VARCHAR(64),
@homeSubCluster VARCHAR(256), @homeSubCluster_IN VARCHAR(256),
@storedHomeSubCluster VARCHAR(256) OUTPUT, @storedHomeSubCluster_OUT VARCHAR(256) OUTPUT,
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -37,21 +37,21 @@ AS BEGIN
-- Otherwise don't change the current mapping. -- Otherwise don't change the current mapping.
IF NOT EXISTS (SELECT TOP 1 * IF NOT EXISTS (SELECT TOP 1 *
FROM [dbo].[applicationsHomeSubCluster] FROM [dbo].[applicationsHomeSubCluster]
WHERE [applicationId] = @applicationId) WHERE [applicationId] = @applicationId_IN)
INSERT INTO [dbo].[applicationsHomeSubCluster] ( INSERT INTO [dbo].[applicationsHomeSubCluster] (
[applicationId], [applicationId],
[homeSubCluster]) [homeSubCluster])
VALUES ( VALUES (
@applicationId, @applicationId_IN,
@homeSubCluster); @homeSubCluster_IN);
-- End of the IF block -- End of the IF block
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
SELECT @storedHomeSubCluster = [homeSubCluster] SELECT @storedHomeSubCluster_OUT = [homeSubCluster]
FROM [dbo].[applicationsHomeSubCluster] FROM [dbo].[applicationsHomeSubCluster]
WHERE [applicationId] = @applicationId; WHERE [applicationId] = @applicationId_IN;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -75,9 +75,9 @@ IF OBJECT_ID ( '[sp_updateApplicationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_updateApplicationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_updateApplicationHomeSubCluster]
@applicationId VARCHAR(64), @applicationId_IN VARCHAR(64),
@homeSubCluster VARCHAR(256), @homeSubCluster_IN VARCHAR(256),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -85,9 +85,9 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
UPDATE [dbo].[applicationsHomeSubCluster] UPDATE [dbo].[applicationsHomeSubCluster]
SET [homeSubCluster] = @homeSubCluster SET [homeSubCluster] = @homeSubCluster_IN
WHERE [applicationId] = @applicationid; WHERE [applicationId] = @applicationId_IN;
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -111,8 +111,8 @@ IF OBJECT_ID ( '[sp_getApplicationsHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_getApplicationsHomeSubCluster] CREATE PROCEDURE [dbo].[sp_getApplicationsHomeSubCluster]
@limit int, @limit_IN int,
@homeSubCluster VARCHAR(256) @homeSubCluster_IN VARCHAR(256)
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -128,8 +128,8 @@ AS BEGIN
[createTime], [createTime],
row_number() over(order by [createTime] desc) AS app_rank row_number() over(order by [createTime] desc) AS app_rank
FROM [dbo].[applicationsHomeSubCluster] FROM [dbo].[applicationsHomeSubCluster]
WHERE [homeSubCluster] = @homeSubCluster OR @homeSubCluster = '') AS applicationsHomeSubCluster WHERE [homeSubCluster] = @homeSubCluster_IN OR @homeSubCluster = '') AS applicationsHomeSubCluster
WHERE app_rank <= @limit; WHERE app_rank <= @limit_IN;
END TRY END TRY
@ -150,16 +150,16 @@ IF OBJECT_ID ( '[sp_getApplicationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_getApplicationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_getApplicationHomeSubCluster]
@applicationId VARCHAR(64), @applicationId_IN VARCHAR(64),
@homeSubCluster VARCHAR(256) OUTPUT @homeSubCluster_OUT VARCHAR(256) OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
BEGIN TRY BEGIN TRY
SELECT @homeSubCluster = [homeSubCluster] SELECT @homeSubCluster_OUT = [homeSubCluster]
FROM [dbo].[applicationsHomeSubCluster] FROM [dbo].[applicationsHomeSubCluster]
WHERE [applicationId] = @applicationid; WHERE [applicationId] = @applicationId_IN;
END TRY END TRY
@ -181,8 +181,8 @@ IF OBJECT_ID ( '[sp_deleteApplicationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_deleteApplicationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_deleteApplicationHomeSubCluster]
@applicationId VARCHAR(64), @applicationId_IN VARCHAR(64),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -190,8 +190,8 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
DELETE FROM [dbo].[applicationsHomeSubCluster] DELETE FROM [dbo].[applicationsHomeSubCluster]
WHERE [applicationId] = @applicationId; WHERE [applicationId] = @applicationId_IN;
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -215,15 +215,15 @@ IF OBJECT_ID ( '[sp_registerSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_registerSubCluster] CREATE PROCEDURE [dbo].[sp_registerSubCluster]
@subClusterId VARCHAR(256), @subClusterId_IN VARCHAR(256),
@amRMServiceAddress VARCHAR(256), @amRMServiceAddress_IN VARCHAR(256),
@clientRMServiceAddress VARCHAR(256), @clientRMServiceAddress_IN VARCHAR(256),
@rmAdminServiceAddress VARCHAR(256), @rmAdminServiceAddress_IN VARCHAR(256),
@rmWebServiceAddress VARCHAR(256), @rmWebServiceAddress_IN VARCHAR(256),
@state VARCHAR(32), @state_IN VARCHAR(32),
@lastStartTime BIGINT, @lastStartTime_IN BIGINT,
@capability VARCHAR(6000), @capability_IN VARCHAR(6000),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -231,7 +231,7 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
DELETE FROM [dbo].[membership] DELETE FROM [dbo].[membership]
WHERE [subClusterId] = @subClusterId; WHERE [subClusterId] = @subClusterId_IN;
INSERT INTO [dbo].[membership] ( INSERT INTO [dbo].[membership] (
[subClusterId], [subClusterId],
[amRMServiceAddress], [amRMServiceAddress],
@ -243,16 +243,16 @@ AS BEGIN
[lastStartTime], [lastStartTime],
[capability] ) [capability] )
VALUES ( VALUES (
@subClusterId, @subClusterId_IN,
@amRMServiceAddress, @amRMServiceAddress_IN,
@clientRMServiceAddress, @clientRMServiceAddress_IN,
@rmAdminServiceAddress, @rmAdminServiceAddress_IN,
@rmWebServiceAddress, @rmWebServiceAddress_IN,
GETUTCDATE(), GETUTCDATE(),
@state, @state_IN,
@lastStartTime, @lastStartTime_IN,
@capability); @capability_IN);
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -303,32 +303,32 @@ IF OBJECT_ID ( '[sp_getSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_getSubCluster] CREATE PROCEDURE [dbo].[sp_getSubCluster]
@subClusterId VARCHAR(256), @subClusterId_IN VARCHAR(256),
@amRMServiceAddress VARCHAR(256) OUTPUT, @amRMServiceAddress_OUT VARCHAR(256) OUTPUT,
@clientRMServiceAddress VARCHAR(256) OUTPUT, @clientRMServiceAddress_OUT VARCHAR(256) OUTPUT,
@rmAdminServiceAddress VARCHAR(256) OUTPUT, @rmAdminServiceAddress_OUT VARCHAR(256) OUTPUT,
@rmWebServiceAddress VARCHAR(256) OUTPUT, @rmWebServiceAddress_OUT VARCHAR(256) OUTPUT,
@lastHeartbeat DATETIME2 OUTPUT, @lastHeartBeat_OUT DATETIME2 OUTPUT,
@state VARCHAR(256) OUTPUT, @state_OUT VARCHAR(256) OUTPUT,
@lastStartTime BIGINT OUTPUT, @lastStartTime_OUT BIGINT OUTPUT,
@capability VARCHAR(6000) OUTPUT @capability_OUT VARCHAR(6000) OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
BEGIN TRY BEGIN TRY
BEGIN TRAN BEGIN TRAN
SELECT @subClusterId = [subClusterId], SELECT @subClusterId_IN = [subClusterId],
@amRMServiceAddress = [amRMServiceAddress], @amRMServiceAddress_OUT = [amRMServiceAddress],
@clientRMServiceAddress = [clientRMServiceAddress], @clientRMServiceAddress_OUT = [clientRMServiceAddress],
@rmAdminServiceAddress = [rmAdminServiceAddress], @rmAdminServiceAddress_OUT = [rmAdminServiceAddress],
@rmWebServiceAddress = [rmWebServiceAddress], @rmWebServiceAddress_OUT = [rmWebServiceAddress],
@lastHeartBeat = [lastHeartBeat], @lastHeartBeat_OUT = [lastHeartBeat],
@state = [state], @state_OUT = [state],
@lastStartTime = [lastStartTime], @lastStartTime_OUT = [lastStartTime],
@capability = [capability] @capability_OUT = [capability]
FROM [dbo].[membership] FROM [dbo].[membership]
WHERE [subClusterId] = @subClusterId WHERE [subClusterId] = @subClusterId_IN
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -353,10 +353,10 @@ IF OBJECT_ID ( '[sp_subClusterHeartbeat]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_subClusterHeartbeat] CREATE PROCEDURE [dbo].[sp_subClusterHeartbeat]
@subClusterId VARCHAR(256), @subClusterId_IN VARCHAR(256),
@state VARCHAR(256), @state_IN VARCHAR(256),
@capability VARCHAR(6000), @capability_IN VARCHAR(6000),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -364,11 +364,11 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
UPDATE [dbo].[membership] UPDATE [dbo].[membership]
SET [state] = @state, SET [state] = @state_IN,
[lastHeartbeat] = GETUTCDATE(), [lastHeartbeat] = GETUTCDATE(),
[capability] = @capability [capability] = @capability_IN
WHERE [subClusterId] = @subClusterId; WHERE [subClusterId] = @subClusterId_IN;
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -392,9 +392,9 @@ IF OBJECT_ID ( '[sp_deregisterSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_deregisterSubCluster] CREATE PROCEDURE [dbo].[sp_deregisterSubCluster]
@subClusterId VARCHAR(256), @subClusterId_IN VARCHAR(256),
@state VARCHAR(256), @state_IN VARCHAR(256),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -402,9 +402,9 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
UPDATE [dbo].[membership] UPDATE [dbo].[membership]
SET [state] = @state SET [state] = @state_IN
WHERE [subClusterId] = @subClusterId; WHERE [subClusterId] = @subClusterId_IN;
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -428,10 +428,10 @@ IF OBJECT_ID ( '[sp_setPolicyConfiguration]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_setPolicyConfiguration] CREATE PROCEDURE [dbo].[sp_setPolicyConfiguration]
@queue VARCHAR(256), @queue_IN VARCHAR(256),
@policyType VARCHAR(256), @policyType_IN VARCHAR(256),
@params VARBINARY(512), @params_IN VARBINARY(512),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -439,16 +439,16 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
DELETE FROM [dbo].[policies] DELETE FROM [dbo].[policies]
WHERE [queue] = @queue; WHERE [queue] = @queue_IN;
INSERT INTO [dbo].[policies] ( INSERT INTO [dbo].[policies] (
[queue], [queue],
[policyType], [policyType],
[params]) [params])
VALUES ( VALUES (
@queue, @queue_IN,
@policyType, @policyType_IN,
@params); @params_IN);
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -472,18 +472,18 @@ IF OBJECT_ID ( '[sp_getPolicyConfiguration]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_getPolicyConfiguration] CREATE PROCEDURE [dbo].[sp_getPolicyConfiguration]
@queue VARCHAR(256), @queue_IN VARCHAR(256),
@policyType VARCHAR(256) OUTPUT, @policyType_OUT VARCHAR(256) OUTPUT,
@params VARBINARY(6000) OUTPUT @params_OUT VARBINARY(6000) OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
BEGIN TRY BEGIN TRY
SELECT @policyType = [policyType], SELECT @policyType_OUT = [policyType],
@params = [params] @params_OUT = [params]
FROM [dbo].[policies] FROM [dbo].[policies]
WHERE [queue] = @queue WHERE [queue] = @queue_IN
END TRY END TRY
@ -524,15 +524,15 @@ AS BEGIN
END; END;
GO GO
IF OBJECT_ID ( '[sp_addApplicationHomeSubCluster]', 'P' ) IS NOT NULL IF OBJECT_ID ( '[sp_addReservationHomeSubCluster]', 'P' ) IS NOT NULL
DROP PROCEDURE [sp_addApplicationHomeSubCluster]; DROP PROCEDURE [sp_addReservationHomeSubCluster];
GO GO
CREATE PROCEDURE [dbo].[sp_addReservationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_addReservationHomeSubCluster]
@reservationId VARCHAR(128), @reservationId_IN VARCHAR(128),
@homeSubCluster VARCHAR(256), @homeSubCluster_IN VARCHAR(256),
@storedHomeSubCluster VARCHAR(256) OUTPUT, @storedHomeSubCluster_OUT VARCHAR(256) OUTPUT,
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -542,21 +542,21 @@ AS BEGIN
-- Otherwise don't change the current mapping. -- Otherwise don't change the current mapping.
IF NOT EXISTS (SELECT TOP 1 * IF NOT EXISTS (SELECT TOP 1 *
FROM [dbo].[reservationsHomeSubCluster] FROM [dbo].[reservationsHomeSubCluster]
WHERE [reservationId] = @reservationId) WHERE [reservationId] = @reservationId_IN)
INSERT INTO [dbo].[reservationsHomeSubCluster] ( INSERT INTO [dbo].[reservationsHomeSubCluster] (
[reservationId], [reservationId],
[homeSubCluster]) [homeSubCluster])
VALUES ( VALUES (
@reservationId, @reservationId_IN,
@homeSubCluster); @homeSubCluster_IN);
-- End of the IF block -- End of the IF block
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
SELECT @storedHomeSubCluster = [homeSubCluster] SELECT @storedHomeSubCluster_OUT = [homeSubCluster]
FROM [dbo].[reservationsHomeSubCluster] FROM [dbo].[reservationsHomeSubCluster]
WHERE [reservationId] = @reservationId; WHERE [reservationId] = @reservationId_IN;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -580,9 +580,9 @@ IF OBJECT_ID ( '[sp_updateReservationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_updateReservationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_updateReservationHomeSubCluster]
@reservationId VARCHAR(128), @reservationId_IN VARCHAR(128),
@homeSubCluster VARCHAR(256), @homeSubCluster_IN VARCHAR(256),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -590,9 +590,9 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
UPDATE [dbo].[reservationsHomeSubCluster] UPDATE [dbo].[reservationsHomeSubCluster]
SET [homeSubCluster] = @homeSubCluster SET [homeSubCluster] = @homeSubCluster_IN
WHERE [reservationId] = @reservationId; WHERE [reservationId] = @reservationId_IN;
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY
@ -641,16 +641,16 @@ IF OBJECT_ID ( '[sp_getReservationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_getReservationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_getReservationHomeSubCluster]
@reservationId VARCHAR(128), @reservationId_IN VARCHAR(128),
@homeSubCluster VARCHAR(256) OUTPUT @homeSubCluster_OUT VARCHAR(256) OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
BEGIN TRY BEGIN TRY
SELECT @homeSubCluster = [homeSubCluster] SELECT @homeSubCluster_OUT = [homeSubCluster]
FROM [dbo].[reservationsHomeSubCluster] FROM [dbo].[reservationsHomeSubCluster]
WHERE [reservationId] = @reservationId; WHERE [reservationId] = @reservationId_IN;
END TRY END TRY
@ -672,8 +672,8 @@ IF OBJECT_ID ( '[sp_deleteReservationHomeSubCluster]', 'P' ) IS NOT NULL
GO GO
CREATE PROCEDURE [dbo].[sp_deleteReservationHomeSubCluster] CREATE PROCEDURE [dbo].[sp_deleteReservationHomeSubCluster]
@reservationId VARCHAR(128), @reservationId_IN VARCHAR(128),
@rowCount int OUTPUT @rowCount_OUT int OUTPUT
AS BEGIN AS BEGIN
DECLARE @errorMessage nvarchar(4000) DECLARE @errorMessage nvarchar(4000)
@ -681,8 +681,8 @@ AS BEGIN
BEGIN TRAN BEGIN TRAN
DELETE FROM [dbo].[reservationsHomeSubCluster] DELETE FROM [dbo].[reservationsHomeSubCluster]
WHERE [reservationId] = @reservationId; WHERE [reservationId] = @reservationId_IN;
SELECT @rowCount = @@ROWCOUNT; SELECT @rowCount_OUT = @@ROWCOUNT;
COMMIT TRAN COMMIT TRAN
END TRY END TRY

View File

@ -177,7 +177,7 @@ public class SQLFederationStateStore implements FederationStateStore {
private HikariDataSource dataSource = null; private HikariDataSource dataSource = null;
private final Clock clock = new MonotonicClock(); private final Clock clock = new MonotonicClock();
@VisibleForTesting @VisibleForTesting
Connection conn = null; private Connection conn = null;
private int maxAppsInStateStore; private int maxAppsInStateStore;
@Override @Override
@ -197,8 +197,7 @@ public class SQLFederationStateStore implements FederationStateStore {
try { try {
Class.forName(driverClass); Class.forName(driverClass);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
FederationStateStoreUtils.logAndThrowException(LOG, FederationStateStoreUtils.logAndThrowException(LOG, "Driver class not found.", e);
"Driver class not found.", e);
} }
// Create the data source to pool connections in a thread-safe manner // Create the data source to pool connections in a thread-safe manner
@ -209,14 +208,14 @@ public class SQLFederationStateStore implements FederationStateStore {
FederationStateStoreUtils.setProperty(dataSource, FederationStateStoreUtils.setProperty(dataSource,
FederationStateStoreUtils.FEDERATION_STORE_URL, url); FederationStateStoreUtils.FEDERATION_STORE_URL, url);
dataSource.setMaximumPoolSize(maximumPoolSize); dataSource.setMaximumPoolSize(maximumPoolSize);
LOG.info("Initialized connection pool to the Federation StateStore " LOG.info("Initialized connection pool to the Federation StateStore database at address: {}.",
+ "database at address: " + url); url);
try { try {
conn = getConnection(); conn = getConnection();
LOG.debug("Connection created"); LOG.debug("Connection created");
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(LOG, "Not able to get Connection", e);
"Not able to get Connection", e);
} }
maxAppsInStateStore = conf.getInt( maxAppsInStateStore = conf.getInt(
@ -226,32 +225,29 @@ public class SQLFederationStateStore implements FederationStateStore {
@Override @Override
public SubClusterRegisterResponse registerSubCluster( public SubClusterRegisterResponse registerSubCluster(
SubClusterRegisterRequest registerSubClusterRequest) SubClusterRegisterRequest registerSubClusterRequest) throws YarnException {
throws YarnException {
// Input validator // Input validator
FederationMembershipStateStoreInputValidator FederationMembershipStateStoreInputValidator.validate(registerSubClusterRequest);
.validate(registerSubClusterRequest);
CallableStatement cstmt = null; CallableStatement cstmt = null;
SubClusterInfo subClusterInfo = SubClusterInfo subClusterInfo = registerSubClusterRequest.getSubClusterInfo();
registerSubClusterRequest.getSubClusterInfo();
SubClusterId subClusterId = subClusterInfo.getSubClusterId(); SubClusterId subClusterId = subClusterInfo.getSubClusterId();
try { try {
cstmt = getCallableStatement(CALL_SP_REGISTER_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_REGISTER_SUBCLUSTER);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, subClusterId.getId()); cstmt.setString("subClusterId_IN", subClusterId.getId());
cstmt.setString(2, subClusterInfo.getAMRMServiceAddress()); cstmt.setString("amRMServiceAddress_IN", subClusterInfo.getAMRMServiceAddress());
cstmt.setString(3, subClusterInfo.getClientRMServiceAddress()); cstmt.setString("clientRMServiceAddress_IN", subClusterInfo.getClientRMServiceAddress());
cstmt.setString(4, subClusterInfo.getRMAdminServiceAddress()); cstmt.setString("rmAdminServiceAddress_IN", subClusterInfo.getRMAdminServiceAddress());
cstmt.setString(5, subClusterInfo.getRMWebServiceAddress()); cstmt.setString("rmWebServiceAddress_IN", subClusterInfo.getRMWebServiceAddress());
cstmt.setString(6, subClusterInfo.getState().toString()); cstmt.setString("state_IN", subClusterInfo.getState().toString());
cstmt.setLong(7, subClusterInfo.getLastStartTime()); cstmt.setLong("lastStartTime_IN", subClusterInfo.getLastStartTime());
cstmt.setString(8, subClusterInfo.getCapability()); cstmt.setString("capability_IN", subClusterInfo.getCapability());
cstmt.registerOutParameter(9, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -260,30 +256,26 @@ public class SQLFederationStateStore implements FederationStateStore {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not add a new subcluster into FederationStateStore // did not add a new subcluster into FederationStateStore
if (cstmt.getInt(9) == 0) { int rowCount = cstmt.getInt("rowCount_OUT");
String errMsg = "SubCluster " + subClusterId if (rowCount == 0) {
+ " was not registered into the StateStore"; FederationStateStoreUtils.logAndThrowStoreException(LOG,
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); "SubCluster %s was not registered into the StateStore.", subClusterId);
} }
// Check the ROWCOUNT value, if it is different from 1 it means the call // Check the ROWCOUNT value, if it is different from 1 it means the call
// had a wrong behavior. Maybe the database is not set correctly. // had a wrong behavior. Maybe the database is not set correctly.
if (cstmt.getInt(9) != 1) { if (rowCount != 1) {
String errMsg = "Wrong behavior during registration of SubCluster " FederationStateStoreUtils.logAndThrowStoreException(LOG,
+ subClusterId + " into the StateStore"; "Wrong behavior during registration of SubCluster %s into the StateStore",
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); subClusterId);
} }
LOG.info( LOG.info("Registered the SubCluster {} into the StateStore.", subClusterId);
"Registered the SubCluster " + subClusterId + " into the StateStore"); FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
FederationStateStoreClientMetrics
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e,
"Unable to register the SubCluster " + subClusterId LOG, "Unable to register the SubCluster %s into the StateStore.", subClusterId);
+ " into the StateStore",
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -294,12 +286,10 @@ public class SQLFederationStateStore implements FederationStateStore {
@Override @Override
public SubClusterDeregisterResponse deregisterSubCluster( public SubClusterDeregisterResponse deregisterSubCluster(
SubClusterDeregisterRequest subClusterDeregisterRequest) SubClusterDeregisterRequest subClusterDeregisterRequest) throws YarnException {
throws YarnException {
// Input validator // Input validator
FederationMembershipStateStoreInputValidator FederationMembershipStateStoreInputValidator.validate(subClusterDeregisterRequest);
.validate(subClusterDeregisterRequest);
CallableStatement cstmt = null; CallableStatement cstmt = null;
@ -310,9 +300,9 @@ public class SQLFederationStateStore implements FederationStateStore {
cstmt = getCallableStatement(CALL_SP_DEREGISTER_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_DEREGISTER_SUBCLUSTER);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, subClusterId.getId()); cstmt.setString("subClusterId_IN", subClusterId.getId());
cstmt.setString(2, state.toString()); cstmt.setString("state_IN", state.toString());
cstmt.registerOutParameter(3, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -321,29 +311,25 @@ public class SQLFederationStateStore implements FederationStateStore {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not deregister the subcluster into FederationStateStore // did not deregister the subcluster into FederationStateStore
if (cstmt.getInt(3) == 0) { int rowCount = cstmt.getInt("rowCount_OUT");
String errMsg = "SubCluster " + subClusterId + " not found"; if (rowCount == 0) {
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); FederationStateStoreUtils.logAndThrowStoreException(LOG,
"SubCluster %s not found.", subClusterId);
} }
// Check the ROWCOUNT value, if it is different from 1 it means the call // Check the ROWCOUNT value, if it is different from 1 it means the call
// had a wrong behavior. Maybe the database is not set correctly. // had a wrong behavior. Maybe the database is not set correctly.
if (cstmt.getInt(3) != 1) { if (rowCount != 1) {
String errMsg = "Wrong behavior during deregistration of SubCluster " FederationStateStoreUtils.logAndThrowStoreException(LOG,
+ subClusterId + " from the StateStore"; "Wrong behavior during deregistration of SubCluster %s from the StateStore.",
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); subClusterId);
} }
LOG.info("Deregistered the SubCluster {} state to {}.", subClusterId, state.toString());
LOG.info("Deregistered the SubCluster " + subClusterId + " state to " FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
+ state.toString());
FederationStateStoreClientMetrics
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to deregister the sub-cluster " + subClusterId + " state to " "Unable to deregister the sub-cluster %s state to %s.", subClusterId, state.toString());
+ state.toString(),
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -353,12 +339,10 @@ public class SQLFederationStateStore implements FederationStateStore {
@Override @Override
public SubClusterHeartbeatResponse subClusterHeartbeat( public SubClusterHeartbeatResponse subClusterHeartbeat(
SubClusterHeartbeatRequest subClusterHeartbeatRequest) SubClusterHeartbeatRequest subClusterHeartbeatRequest) throws YarnException {
throws YarnException {
// Input validator // Input validator
FederationMembershipStateStoreInputValidator FederationMembershipStateStoreInputValidator.validate(subClusterHeartbeatRequest);
.validate(subClusterHeartbeatRequest);
CallableStatement cstmt = null; CallableStatement cstmt = null;
@ -369,10 +353,10 @@ public class SQLFederationStateStore implements FederationStateStore {
cstmt = getCallableStatement(CALL_SP_SUBCLUSTER_HEARTBEAT); cstmt = getCallableStatement(CALL_SP_SUBCLUSTER_HEARTBEAT);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, subClusterId.getId()); cstmt.setString("subClusterId_IN", subClusterId.getId());
cstmt.setString(2, state.toString()); cstmt.setString("state_IN", state.toString());
cstmt.setString(3, subClusterHeartbeatRequest.getCapability()); cstmt.setString("capability_IN", subClusterHeartbeatRequest.getCapability());
cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -381,30 +365,25 @@ public class SQLFederationStateStore implements FederationStateStore {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not update the subcluster into FederationStateStore // did not update the subcluster into FederationStateStore
if (cstmt.getInt(4) == 0) { int rowCount = cstmt.getInt("rowCount_OUT");
String errMsg = "SubCluster " + subClusterId.toString() if (rowCount == 0) {
+ " does not exist; cannot heartbeat"; FederationStateStoreUtils.logAndThrowStoreException(LOG,
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); "SubCluster %s does not exist; cannot heartbeat.", subClusterId);
} }
// Check the ROWCOUNT value, if it is different from 1 it means the call // Check the ROWCOUNT value, if it is different from 1 it means the call
// had a wrong behavior. Maybe the database is not set correctly. // had a wrong behavior. Maybe the database is not set correctly.
if (cstmt.getInt(4) != 1) { if (rowCount != 1) {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(LOG,
"Wrong behavior during the heartbeat of SubCluster " + subClusterId; "Wrong behavior during the heartbeat of SubCluster %s.", subClusterId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.info("Heartbeated the StateStore for the specified SubCluster " LOG.info("Heartbeated the StateStore for the specified SubCluster {}.", subClusterId);
+ subClusterId); FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
FederationStateStoreClientMetrics
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to heartbeat the StateStore for the specified SubCluster " "Unable to heartbeat the StateStore for the specified SubCluster %s.", subClusterId);
+ subClusterId,
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -426,27 +405,27 @@ public class SQLFederationStateStore implements FederationStateStore {
try { try {
cstmt = getCallableStatement(CALL_SP_GET_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_GET_SUBCLUSTER);
cstmt.setString(1, subClusterId.getId()); cstmt.setString("subClusterId_IN", subClusterId.getId());
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.registerOutParameter(2, java.sql.Types.VARCHAR); cstmt.registerOutParameter("amRMServiceAddress_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(3, java.sql.Types.VARCHAR); cstmt.registerOutParameter("clientRMServiceAddress_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(4, java.sql.Types.VARCHAR); cstmt.registerOutParameter("rmAdminServiceAddress_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(5, java.sql.Types.VARCHAR); cstmt.registerOutParameter("rmWebServiceAddress_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(6, java.sql.Types.TIMESTAMP); cstmt.registerOutParameter("lastHeartBeat_OUT", java.sql.Types.TIMESTAMP);
cstmt.registerOutParameter(7, java.sql.Types.VARCHAR); cstmt.registerOutParameter("state_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(8, java.sql.Types.BIGINT); cstmt.registerOutParameter("lastStartTime_OUT", java.sql.Types.BIGINT);
cstmt.registerOutParameter(9, java.sql.Types.VARCHAR); cstmt.registerOutParameter("capability_OUT", java.sql.Types.VARCHAR);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
cstmt.execute(); cstmt.execute();
long stopTime = clock.getTime(); long stopTime = clock.getTime();
String amRMAddress = cstmt.getString(2); String amRMAddress = cstmt.getString("amRMServiceAddress_OUT");
String clientRMAddress = cstmt.getString(3); String clientRMAddress = cstmt.getString("clientRMServiceAddress_OUT");
String rmAdminAddress = cstmt.getString(4); String rmAdminAddress = cstmt.getString("rmAdminServiceAddress_OUT");
String webAppAddress = cstmt.getString(5); String webAppAddress = cstmt.getString("rmWebServiceAddress_OUT");
// first check if the subCluster exists // first check if the subCluster exists
if((amRMAddress == null) || (clientRMAddress == null)) { if((amRMAddress == null) || (clientRMAddress == null)) {
@ -454,36 +433,31 @@ public class SQLFederationStateStore implements FederationStateStore {
return null; return null;
} }
Timestamp heartBeatTimeStamp = cstmt.getTimestamp(6, utcCalendar); Timestamp heartBeatTimeStamp = cstmt.getTimestamp("lastHeartBeat_OUT", utcCalendar);
long lastHeartBeat = long lastHeartBeat = heartBeatTimeStamp != null ? heartBeatTimeStamp.getTime() : 0;
heartBeatTimeStamp != null ? heartBeatTimeStamp.getTime() : 0;
SubClusterState state = SubClusterState.fromString(cstmt.getString(7)); SubClusterState state = SubClusterState.fromString(cstmt.getString("state_OUT"));
long lastStartTime = cstmt.getLong(8); long lastStartTime = cstmt.getLong("lastStartTime_OUT");
String capability = cstmt.getString(9); String capability = cstmt.getString("capability_OUT");
subClusterInfo = SubClusterInfo.newInstance(subClusterId, amRMAddress, subClusterInfo = SubClusterInfo.newInstance(subClusterId, amRMAddress,
clientRMAddress, rmAdminAddress, webAppAddress, lastHeartBeat, state, clientRMAddress, rmAdminAddress, webAppAddress, lastHeartBeat, state,
lastStartTime, capability); lastStartTime, capability);
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
// Check if the output it is a valid subcluster // Check if the output it is a valid subcluster
try { try {
FederationMembershipStateStoreInputValidator FederationMembershipStateStoreInputValidator.checkSubClusterInfo(subClusterInfo);
.checkSubClusterInfo(subClusterInfo);
} catch (FederationStateStoreInvalidInputException e) { } catch (FederationStateStoreInvalidInputException e) {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(e, LOG,
"SubCluster " + subClusterId.toString() + " does not exist"; "SubCluster %s does not exist.", subClusterId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.debug("Got the information about the specified SubCluster {}", LOG.debug("Got the information about the specified SubCluster {}", subClusterInfo);
subClusterInfo);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to obtain the SubCluster information for " + subClusterId, e); "Unable to obtain the SubCluster information for %s.", subClusterId);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -496,7 +470,7 @@ public class SQLFederationStateStore implements FederationStateStore {
GetSubClustersInfoRequest subClustersRequest) throws YarnException { GetSubClustersInfoRequest subClustersRequest) throws YarnException {
CallableStatement cstmt = null; CallableStatement cstmt = null;
ResultSet rs = null; ResultSet rs = null;
List<SubClusterInfo> subClusters = new ArrayList<SubClusterInfo>(); List<SubClusterInfo> subClusters = new ArrayList<>();
try { try {
cstmt = getCallableStatement(CALL_SP_GET_SUBCLUSTERS); cstmt = getCallableStatement(CALL_SP_GET_SUBCLUSTERS);
@ -509,15 +483,15 @@ public class SQLFederationStateStore implements FederationStateStore {
while (rs.next()) { while (rs.next()) {
// Extract the output for each tuple // Extract the output for each tuple
String subClusterName = rs.getString(1); String subClusterName = rs.getString("subClusterId");
String amRMAddress = rs.getString(2); String amRMAddress = rs.getString("amRMServiceAddress");
String clientRMAddress = rs.getString(3); String clientRMAddress = rs.getString("clientRMServiceAddress");
String rmAdminAddress = rs.getString(4); String rmAdminAddress = rs.getString("rmAdminServiceAddress");
String webAppAddress = rs.getString(5); String webAppAddress = rs.getString("rmWebServiceAddress");
long lastHeartBeat = rs.getTimestamp(6, utcCalendar).getTime(); long lastHeartBeat = rs.getTimestamp("lastHeartBeat", utcCalendar).getTime();
SubClusterState state = SubClusterState.fromString(rs.getString(7)); SubClusterState state = SubClusterState.fromString(rs.getString("state"));
long lastStartTime = rs.getLong(8); long lastStartTime = rs.getLong("lastStartTime");
String capability = rs.getString(9); String capability = rs.getString("capability");
SubClusterId subClusterId = SubClusterId.newInstance(subClusterName); SubClusterId subClusterId = SubClusterId.newInstance(subClusterName);
SubClusterInfo subClusterInfo = SubClusterInfo.newInstance(subClusterId, SubClusterInfo subClusterInfo = SubClusterInfo.newInstance(subClusterId,
@ -527,15 +501,12 @@ public class SQLFederationStateStore implements FederationStateStore {
FederationStateStoreClientMetrics FederationStateStoreClientMetrics
.succeededStateStoreCall(stopTime - startTime); .succeededStateStoreCall(stopTime - startTime);
// Check if the output it is a valid subcluster // Check if the output it is a valid subcluster
try { try {
FederationMembershipStateStoreInputValidator FederationMembershipStateStoreInputValidator.checkSubClusterInfo(subClusterInfo);
.checkSubClusterInfo(subClusterInfo);
} catch (FederationStateStoreInvalidInputException e) { } catch (FederationStateStoreInvalidInputException e) {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(e, LOG,
"SubCluster " + subClusterId.toString() + " is not valid"; "SubCluster %s is not valid.", subClusterId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
// Filter the inactive // Filter the inactive
@ -575,68 +546,61 @@ public class SQLFederationStateStore implements FederationStateStore {
cstmt = getCallableStatement(CALL_SP_ADD_APPLICATION_HOME_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_ADD_APPLICATION_HOME_SUBCLUSTER);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, appId.toString()); cstmt.setString("applicationId_IN", appId.toString());
cstmt.setString(2, subClusterId.getId()); cstmt.setString("homeSubCluster_IN", subClusterId.getId());
cstmt.registerOutParameter(3, java.sql.Types.VARCHAR); cstmt.registerOutParameter("storedHomeSubCluster_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
cstmt.executeUpdate(); cstmt.executeUpdate();
long stopTime = clock.getTime(); long stopTime = clock.getTime();
subClusterHome = cstmt.getString(3); subClusterHome = cstmt.getString("storedHomeSubCluster_OUT");
SubClusterId subClusterIdHome = SubClusterId.newInstance(subClusterHome); SubClusterId subClusterIdHome = SubClusterId.newInstance(subClusterHome);
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
// For failover reason, we check the returned SubClusterId. // For failover reason, we check the returned SubClusterId.
// If it is equal to the subclusterId we sent, the call added the new // If it is equal to the subclusterId we sent, the call added the new
// application into FederationStateStore. If the call returns a different // application into FederationStateStore. If the call returns a different
// SubClusterId it means we already tried to insert this application but a // SubClusterId it means we already tried to insert this application but a
// component (Router/StateStore/RM) failed during the submission. // component (Router/StateStore/RM) failed during the submission.
int rowCount = cstmt.getInt("rowCount_OUT");
if (subClusterId.equals(subClusterIdHome)) { if (subClusterId.equals(subClusterIdHome)) {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not add a new application into FederationStateStore // did not add a new application into FederationStateStore
if (cstmt.getInt(4) == 0) { if (rowCount == 0) {
LOG.info( LOG.info("The application {} was not inserted in the StateStore because it"
"The application {} was not inserted in the StateStore because it" + " was already present in SubCluster {}", appId, subClusterHome);
+ " was already present in SubCluster {}", } else if (cstmt.getInt("rowCount_OUT") != 1) {
appId, subClusterHome);
} else if (cstmt.getInt(4) != 1) {
// Check the ROWCOUNT value, if it is different from 1 it means the // Check the ROWCOUNT value, if it is different from 1 it means the
// call had a wrong behavior. Maybe the database is not set correctly. // call had a wrong behavior. Maybe the database is not set correctly.
String errMsg = "Wrong behavior during the insertion of SubCluster " FederationStateStoreUtils.logAndThrowStoreException(LOG,
+ subClusterId; "Wrong behavior during the insertion of SubCluster %s.", subClusterId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.info("Insert into the StateStore the application: " + appId LOG.info("Insert into the StateStore the application: {} in SubCluster: {}.",
+ " in SubCluster: " + subClusterHome); appId, subClusterHome);
} else { } else {
// Check the ROWCOUNT value, if it is different from 0 it means the call // Check the ROWCOUNT value, if it is different from 0 it means the call
// did edited the table // did edited the table
if (cstmt.getInt(4) != 0) { if (rowCount != 0) {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(LOG,
"The application " + appId + " does exist but was overwritten"; "The application %s does exist but was overwritten.", appId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.info("Application: " + appId + " already present with SubCluster: " LOG.info("Application: {} already present with SubCluster: {}.", appId, subClusterHome);
+ subClusterHome);
} }
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
.logAndThrowRetriableException(LOG, "Unable to insert the newly generated application %s.", appId);
"Unable to insert the newly generated application "
+ request.getApplicationHomeSubCluster().getApplicationId(),
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
} }
return AddApplicationHomeSubClusterResponse return AddApplicationHomeSubClusterResponse
.newInstance(SubClusterId.newInstance(subClusterHome)); .newInstance(SubClusterId.newInstance(subClusterHome));
} }
@ -659,9 +623,9 @@ public class SQLFederationStateStore implements FederationStateStore {
cstmt = getCallableStatement(CALL_SP_UPDATE_APPLICATION_HOME_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_UPDATE_APPLICATION_HOME_SUBCLUSTER);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, appId.toString()); cstmt.setString("applicationId_IN", appId.toString());
cstmt.setString(2, subClusterId.getId()); cstmt.setString("homeSubCluster_IN", subClusterId.getId());
cstmt.registerOutParameter(3, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -670,31 +634,25 @@ public class SQLFederationStateStore implements FederationStateStore {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not update the application into FederationStateStore // did not update the application into FederationStateStore
if (cstmt.getInt(3) == 0) { int rowCount = cstmt.getInt("rowCount_OUT");
String errMsg = "Application " + appId + " does not exist"; if (rowCount == 0) {
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); FederationStateStoreUtils.logAndThrowStoreException(LOG,
"Application %s does not exist.", appId);
} }
// Check the ROWCOUNT value, if it is different from 1 it means the call // Check the ROWCOUNT value, if it is different from 1 it means the call
// had a wrong behavior. Maybe the database is not set correctly. // had a wrong behavior. Maybe the database is not set correctly.
if (cstmt.getInt(3) != 1) { if (cstmt.getInt("rowCount_OUT") != 1) {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(LOG,
"Wrong behavior during the update of SubCluster " + subClusterId; "Wrong behavior during the update of SubCluster %s.", subClusterId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.info( LOG.info("Update the SubCluster to {} for application {} in the StateStore",
"Update the SubCluster to {} for application {} in the StateStore",
subClusterId, appId); subClusterId, appId);
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
.logAndThrowRetriableException(LOG, "Unable to update the application %s.", appId);
"Unable to update the application "
+ request.getApplicationHomeSubCluster().getApplicationId(),
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -712,44 +670,43 @@ public class SQLFederationStateStore implements FederationStateStore {
SubClusterId homeRM = null; SubClusterId homeRM = null;
ApplicationId applicationId = request.getApplicationId();
try { try {
cstmt = getCallableStatement(CALL_SP_GET_APPLICATION_HOME_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_GET_APPLICATION_HOME_SUBCLUSTER);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, request.getApplicationId().toString()); cstmt.setString("applicationId_IN", applicationId.toString());
cstmt.registerOutParameter(2, java.sql.Types.VARCHAR); cstmt.registerOutParameter("homeSubCluster_OUT", java.sql.Types.VARCHAR);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
cstmt.execute(); cstmt.execute();
long stopTime = clock.getTime(); long stopTime = clock.getTime();
if (cstmt.getString(2) != null) { String homeSubCluster = cstmt.getString("homeSubCluster_OUT");
homeRM = SubClusterId.newInstance(cstmt.getString(2)); if (homeSubCluster != null) {
homeRM = SubClusterId.newInstance(homeSubCluster);
} else { } else {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(LOG,
"Application " + request.getApplicationId() + " does not exist"; "Application %s does not exist.", applicationId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.debug("Got the information about the specified application {}." LOG.debug("Got the information about the specified application {}."
+ " The AM is running in {}", request.getApplicationId(), homeRM); + " The AM is running in {}", applicationId, homeRM);
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to obtain the application information " "Unable to obtain the application information for the specified application %s.",
+ "for the specified application " + request.getApplicationId(), applicationId);
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
} }
return GetApplicationHomeSubClusterResponse return GetApplicationHomeSubClusterResponse.newInstance(request.getApplicationId(), homeRM);
.newInstance(request.getApplicationId(), homeRM);
} }
@Override @Override
@ -790,8 +747,7 @@ public class SQLFederationStateStore implements FederationStateStore {
SubClusterId.newInstance(homeSubCluster))); SubClusterId.newInstance(homeSubCluster)));
} }
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
@ -813,13 +769,13 @@ public class SQLFederationStateStore implements FederationStateStore {
FederationApplicationHomeSubClusterStoreInputValidator.validate(request); FederationApplicationHomeSubClusterStoreInputValidator.validate(request);
CallableStatement cstmt = null; CallableStatement cstmt = null;
ApplicationId applicationId = request.getApplicationId();
try { try {
cstmt = getCallableStatement(CALL_SP_DELETE_APPLICATION_HOME_SUBCLUSTER); cstmt = getCallableStatement(CALL_SP_DELETE_APPLICATION_HOME_SUBCLUSTER);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, request.getApplicationId().toString()); cstmt.setString("applicationId_IN", applicationId.toString());
cstmt.registerOutParameter(2, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -828,28 +784,25 @@ public class SQLFederationStateStore implements FederationStateStore {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not delete the application from FederationStateStore // did not delete the application from FederationStateStore
if (cstmt.getInt(2) == 0) { int rowCount = cstmt.getInt("rowCount_OUT");
String errMsg = if (rowCount == 0) {
"Application " + request.getApplicationId() + " does not exist"; FederationStateStoreUtils.logAndThrowStoreException(LOG,
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); "Application %s does not exist.", applicationId);
} }
// Check the ROWCOUNT value, if it is different from 1 it means the call // Check the ROWCOUNT value, if it is different from 1 it means the call
// had a wrong behavior. Maybe the database is not set correctly. // had a wrong behavior. Maybe the database is not set correctly.
if (cstmt.getInt(2) != 1) { if (cstmt.getInt("rowCount_OUT") != 1) {
String errMsg = "Wrong behavior during deleting the application " FederationStateStoreUtils.logAndThrowStoreException(LOG,
+ request.getApplicationId(); "Wrong behavior during deleting the application %s.", applicationId);
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.info("Delete from the StateStore the application: {}", LOG.info("Delete from the StateStore the application: {}", request.getApplicationId());
request.getApplicationId()); FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
FederationStateStoreClientMetrics
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to delete the application " + request.getApplicationId(), e); "Unable to delete the application %s.", applicationId);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -871,9 +824,9 @@ public class SQLFederationStateStore implements FederationStateStore {
cstmt = getCallableStatement(CALL_SP_GET_POLICY_CONFIGURATION); cstmt = getCallableStatement(CALL_SP_GET_POLICY_CONFIGURATION);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, request.getQueue()); cstmt.setString("queue_IN", request.getQueue());
cstmt.registerOutParameter(2, java.sql.Types.VARCHAR); cstmt.registerOutParameter("policyType_OUT", java.sql.Types.VARCHAR);
cstmt.registerOutParameter(3, java.sql.Types.VARBINARY); cstmt.registerOutParameter("params_OUT", java.sql.Types.VARBINARY);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -881,10 +834,11 @@ public class SQLFederationStateStore implements FederationStateStore {
long stopTime = clock.getTime(); long stopTime = clock.getTime();
// Check if the output it is a valid policy // Check if the output it is a valid policy
if (cstmt.getString(2) != null && cstmt.getBytes(3) != null) { String policyType = cstmt.getString("policyType_OUT");
subClusterPolicyConfiguration = byte[] param = cstmt.getBytes("params_OUT");
SubClusterPolicyConfiguration.newInstance(request.getQueue(), if (policyType != null && param != null) {
cstmt.getString(2), ByteBuffer.wrap(cstmt.getBytes(3))); subClusterPolicyConfiguration = SubClusterPolicyConfiguration.newInstance(
request.getQueue(), policyType, ByteBuffer.wrap(param));
LOG.debug("Selected from StateStore the policy for the queue: {}", LOG.debug("Selected from StateStore the policy for the queue: {}",
subClusterPolicyConfiguration); subClusterPolicyConfiguration);
} else { } else {
@ -892,20 +846,17 @@ public class SQLFederationStateStore implements FederationStateStore {
return null; return null;
} }
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to select the policy for the queue :" + request.getQueue(), "Unable to select the policy for the queue : %s." + request.getQueue());
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
} }
return GetSubClusterPolicyConfigurationResponse return GetSubClusterPolicyConfigurationResponse.newInstance(subClusterPolicyConfiguration);
.newInstance(subClusterPolicyConfiguration);
} }
@Override @Override
@ -923,10 +874,10 @@ public class SQLFederationStateStore implements FederationStateStore {
cstmt = getCallableStatement(CALL_SP_SET_POLICY_CONFIGURATION); cstmt = getCallableStatement(CALL_SP_SET_POLICY_CONFIGURATION);
// Set the parameters for the stored procedure // Set the parameters for the stored procedure
cstmt.setString(1, policyConf.getQueue()); cstmt.setString("queue_IN", policyConf.getQueue());
cstmt.setString(2, policyConf.getType()); cstmt.setString("policyType_IN", policyConf.getType());
cstmt.setBytes(3, getByteArray(policyConf.getParams())); cstmt.setBytes("params_IN", getByteArray(policyConf.getParams()));
cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.registerOutParameter("rowCount_OUT", java.sql.Types.INTEGER);
// Execute the query // Execute the query
long startTime = clock.getTime(); long startTime = clock.getTime();
@ -935,30 +886,25 @@ public class SQLFederationStateStore implements FederationStateStore {
// Check the ROWCOUNT value, if it is equal to 0 it means the call // Check the ROWCOUNT value, if it is equal to 0 it means the call
// did not add a new policy into FederationStateStore // did not add a new policy into FederationStateStore
if (cstmt.getInt(4) == 0) { int rowCount = cstmt.getInt("rowCount_OUT");
String errMsg = "The policy " + policyConf.getQueue() if (rowCount == 0) {
+ " was not insert into the StateStore"; FederationStateStoreUtils.logAndThrowStoreException(LOG,
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); "The policy %s was not insert into the StateStore.", policyConf.getQueue());
} }
// Check the ROWCOUNT value, if it is different from 1 it means the call // Check the ROWCOUNT value, if it is different from 1 it means the call
// had a wrong behavior. Maybe the database is not set correctly. // had a wrong behavior. Maybe the database is not set correctly.
if (cstmt.getInt(4) != 1) { if (rowCount != 1) {
String errMsg = FederationStateStoreUtils.logAndThrowStoreException(LOG,
"Wrong behavior during insert the policy " + policyConf.getQueue(); "Wrong behavior during insert the policy %s.", policyConf.getQueue());
FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg);
} }
LOG.info("Insert into the state store the policy for the queue: " LOG.info("Insert into the state store the policy for the queue: {}.", policyConf.getQueue());
+ policyConf.getQueue()); FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
FederationStateStoreClientMetrics
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
FederationStateStoreUtils.logAndThrowRetriableException(LOG, FederationStateStoreUtils.logAndThrowRetriableException(e, LOG,
"Unable to insert the newly generated policy for the queue :" "Unable to insert the newly generated policy for the queue : %s.", policyConf.getQueue());
+ policyConf.getQueue(),
e);
} finally { } finally {
// Return to the pool the CallableStatement // Return to the pool the CallableStatement
FederationStateStoreUtils.returnToPool(LOG, cstmt); FederationStateStoreUtils.returnToPool(LOG, cstmt);
@ -972,8 +918,7 @@ public class SQLFederationStateStore implements FederationStateStore {
CallableStatement cstmt = null; CallableStatement cstmt = null;
ResultSet rs = null; ResultSet rs = null;
List<SubClusterPolicyConfiguration> policyConfigurations = List<SubClusterPolicyConfiguration> policyConfigurations = new ArrayList<>();
new ArrayList<SubClusterPolicyConfiguration>();
try { try {
cstmt = getCallableStatement(CALL_SP_GET_POLICIES_CONFIGURATIONS); cstmt = getCallableStatement(CALL_SP_GET_POLICIES_CONFIGURATIONS);
@ -984,20 +929,17 @@ public class SQLFederationStateStore implements FederationStateStore {
long stopTime = clock.getTime(); long stopTime = clock.getTime();
while (rs.next()) { while (rs.next()) {
// Extract the output for each tuple // Extract the output for each tuple
String queue = rs.getString(1); String queue = rs.getString("queue");
String type = rs.getString(2); String type = rs.getString("policyType");
byte[] policyInfo = rs.getBytes(3); byte[] policyInfo = rs.getBytes("params");
SubClusterPolicyConfiguration subClusterPolicyConfiguration = SubClusterPolicyConfiguration subClusterPolicyConfiguration =
SubClusterPolicyConfiguration.newInstance(queue, type, SubClusterPolicyConfiguration.newInstance(queue, type, ByteBuffer.wrap(policyInfo));
ByteBuffer.wrap(policyInfo));
policyConfigurations.add(subClusterPolicyConfiguration); policyConfigurations.add(subClusterPolicyConfiguration);
} }
FederationStateStoreClientMetrics FederationStateStoreClientMetrics.succeededStateStoreCall(stopTime - startTime);
.succeededStateStoreCall(stopTime - startTime);
} catch (SQLException e) { } catch (SQLException e) {
FederationStateStoreClientMetrics.failedStateStoreCall(); FederationStateStoreClientMetrics.failedStateStoreCall();
@ -1008,8 +950,7 @@ public class SQLFederationStateStore implements FederationStateStore {
FederationStateStoreUtils.returnToPool(LOG, cstmt, null, rs); FederationStateStoreUtils.returnToPool(LOG, cstmt, null, rs);
} }
return GetSubClusterPoliciesConfigurationsResponse return GetSubClusterPoliciesConfigurationsResponse.newInstance(policyConfigurations);
.newInstance(policyConfigurations);
} }
@Override @Override

View File

@ -162,6 +162,29 @@ public final class FederationStateStoreUtils {
throw new FederationStateStoreException(errMsg); throw new FederationStateStoreException(errMsg);
} }
/**
* Throws an <code>FederationStateStoreException</code> due to an error in
* <code>FederationStateStore</code>.
*
* @param t the throwable raised in the called class.
* @param log the logger interface.
* @param errMsgFormat the error message format string.
* @param args referenced by the format specifiers in the format string.
* @throws YarnException on failure
*/
public static void logAndThrowStoreException(
Throwable t, Logger log, String errMsgFormat, Object... args) throws YarnException {
String errMsg = String.format(errMsgFormat, args);
if (t != null) {
log.error(errMsg, t);
throw new FederationStateStoreException(errMsg, t);
} else {
log.error(errMsg);
throw new FederationStateStoreException(errMsg);
}
}
/** /**
* Throws an <code>FederationStateStoreInvalidInputException</code> due to an * Throws an <code>FederationStateStoreInvalidInputException</code> due to an
* error in <code>FederationStateStore</code>. * error in <code>FederationStateStore</code>.

View File

@ -325,7 +325,7 @@ public class HSQLDBFederationStateStore extends SQLFederationStateStore {
try { try {
conf.setInt(YarnConfiguration.FEDERATION_STATESTORE_MAX_APPLICATIONS, 10); conf.setInt(YarnConfiguration.FEDERATION_STATESTORE_MAX_APPLICATIONS, 10);
super.init(conf); super.init(conf);
conn = super.conn; conn = super.getConn();
LOG.info("Database Init: Start"); LOG.info("Database Init: Start");
@ -365,7 +365,7 @@ public class HSQLDBFederationStateStore extends SQLFederationStateStore {
public void initConnection(Configuration conf) { public void initConnection(Configuration conf) {
try { try {
super.init(conf); super.init(conf);
conn = super.conn; conn = super.getConn();
} catch (YarnException e1) { } catch (YarnException e1) {
LOG.error("ERROR: failed open connection to HSQLDB DB {}.", e1.getMessage()); LOG.error("ERROR: failed open connection to HSQLDB DB {}.", e1.getMessage());
} }

View File

@ -447,7 +447,7 @@ public class TestSQLFederationStateStore extends FederationStateStoreBaseTest {
SQLFederationStateStore sqlFederationStateStore = (SQLFederationStateStore) stateStore; SQLFederationStateStore sqlFederationStateStore = (SQLFederationStateStore) stateStore;
Connection conn = sqlFederationStateStore.conn; Connection conn = sqlFederationStateStore.getConn();
conn.prepareStatement(SP_DROP_ADDRESERVATIONHOMESUBCLUSTER).execute(); conn.prepareStatement(SP_DROP_ADDRESERVATIONHOMESUBCLUSTER).execute();
conn.prepareStatement(SP_ADDRESERVATIONHOMESUBCLUSTER2).execute(); conn.prepareStatement(SP_ADDRESERVATIONHOMESUBCLUSTER2).execute();
@ -484,7 +484,7 @@ public class TestSQLFederationStateStore extends FederationStateStoreBaseTest {
SQLFederationStateStore sqlFederationStateStore = (SQLFederationStateStore) stateStore; SQLFederationStateStore sqlFederationStateStore = (SQLFederationStateStore) stateStore;
Connection conn = sqlFederationStateStore.conn; Connection conn = sqlFederationStateStore.getConn();
conn.prepareStatement(SP_DROP_UPDATERESERVATIONHOMESUBCLUSTER).execute(); conn.prepareStatement(SP_DROP_UPDATERESERVATIONHOMESUBCLUSTER).execute();
conn.prepareStatement(SP_UPDATERESERVATIONHOMESUBCLUSTER2).execute(); conn.prepareStatement(SP_UPDATERESERVATIONHOMESUBCLUSTER2).execute();
@ -530,7 +530,7 @@ public class TestSQLFederationStateStore extends FederationStateStoreBaseTest {
SQLFederationStateStore sqlFederationStateStore = (SQLFederationStateStore) stateStore; SQLFederationStateStore sqlFederationStateStore = (SQLFederationStateStore) stateStore;
Connection conn = sqlFederationStateStore.conn; Connection conn = sqlFederationStateStore.getConn();
conn.prepareStatement(SP_DROP_DELETERESERVATIONHOMESUBCLUSTER).execute(); conn.prepareStatement(SP_DROP_DELETERESERVATIONHOMESUBCLUSTER).execute();
conn.prepareStatement(SP_DELETERESERVATIONHOMESUBCLUSTER2).execute(); conn.prepareStatement(SP_DELETERESERVATIONHOMESUBCLUSTER2).execute();