Class FederationStateStoreUtils
java.lang.Object
org.apache.hadoop.yarn.server.federation.store.utils.FederationStateStoreUtils
Common utility methods used by the store implementations.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hadoop.security.token.delegation.DelegationKeyConvert MasterKey to DelegationKey.static voiddecodeWritable(org.apache.hadoop.io.Writable w, String idStr) Decode Base64 string to Writable object.static StringencodeWritable(org.apache.hadoop.io.Writable key) Encode for Writable objects.static booleanfilterHomeSubCluster(SubClusterId filterSubCluster, SubClusterId homeSubCluster) Filter HomeSubCluster based on Filter SubCluster.static voidlogAndThrowException(org.slf4j.Logger log, String errMsg, Throwable t) Throws an exception due to an error inFederationStateStore.static voidlogAndThrowInvalidInputException(org.slf4j.Logger log, String errMsg) Throws anFederationStateStoreInvalidInputExceptiondue to an error inFederationStateStore.static voidlogAndThrowRetriableException(Throwable t, org.slf4j.Logger log, String errMsgFormat, Object... args) Throws anFederationStateStoreRetriableExceptiondue to an error inFederationStateStore.static voidlogAndThrowRetriableException(org.slf4j.Logger log, String errMsgFormat, Object... args) Throws anFederationStateStoreRetriableExceptiondue to an error inFederationStateStore.static voidlogAndThrowRetriableException(org.slf4j.Logger log, String errMsg, Throwable t) Throws anFederationStateStoreRetriableExceptiondue to an error inFederationStateStore.static voidlogAndThrowStoreException(Throwable t, org.slf4j.Logger log, String errMsgFormat, Object... args) Throws anFederationStateStoreExceptiondue to an error inFederationStateStore.static voidlogAndThrowStoreException(org.slf4j.Logger log, String errMsg) Throws anFederationStateStoreExceptiondue to an error inFederationStateStore.static voidlogAndThrowStoreException(org.slf4j.Logger log, String errMsgFormat, Object... args) Throws anFederationStateStoreExceptiondue to an error inFederationStateStore.static voidreturnToPool(org.slf4j.Logger log, CallableStatement cstmt) Returns the SQLFederationStateStoreconnections to the pool.static voidreturnToPool(org.slf4j.Logger log, CallableStatement cstmt, Connection conn) Returns the SQLFederationStateStoreconnections to the pool.static voidreturnToPool(org.slf4j.Logger log, CallableStatement cstmt, Connection conn, ResultSet rs) Returns the SQLFederationStateStoreconnections to the pool.static voidsetPassword(com.zaxxer.hikari.HikariDataSource dataSource, String password) Sets a specific password forHikariDataSourceSQL connections.static voidsetProperty(com.zaxxer.hikari.HikariDataSource dataSource, String property, String value) Sets a specific value for a specific property ofHikariDataSourceSQL connections.static voidsetUsername(com.zaxxer.hikari.HikariDataSource dataSource, String userNameDB) Sets a specific username forHikariDataSourceSQL connections.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG -
FEDERATION_STORE_URL
- See Also:
-
-
Method Details
-
returnToPool
public static void returnToPool(org.slf4j.Logger log, CallableStatement cstmt, Connection conn, ResultSet rs) throws org.apache.hadoop.yarn.exceptions.YarnException Returns the SQLFederationStateStoreconnections to the pool.- Parameters:
log- the logger interfacecstmt- the interface used to execute SQL stored proceduresconn- the SQL connectionrs- the ResultSet interface used to execute SQL stored procedures- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
returnToPool
public static void returnToPool(org.slf4j.Logger log, CallableStatement cstmt, Connection conn) throws org.apache.hadoop.yarn.exceptions.YarnException Returns the SQLFederationStateStoreconnections to the pool.- Parameters:
log- the logger interfacecstmt- the interface used to execute SQL stored proceduresconn- the SQL connection- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
returnToPool
public static void returnToPool(org.slf4j.Logger log, CallableStatement cstmt) throws org.apache.hadoop.yarn.exceptions.YarnException Returns the SQLFederationStateStoreconnections to the pool.- Parameters:
log- the logger interfacecstmt- the interface used to execute SQL stored procedures- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowException
public static void logAndThrowException(org.slf4j.Logger log, String errMsg, Throwable t) throws org.apache.hadoop.yarn.exceptions.YarnException Throws an exception due to an error inFederationStateStore.- Parameters:
log- the logger interfaceerrMsg- the error messaget- the throwable raised in the called class.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowStoreException
public static void logAndThrowStoreException(org.slf4j.Logger log, String errMsg) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreExceptiondue to an error inFederationStateStore.- Parameters:
log- the logger interfaceerrMsg- the error message- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowStoreException
public static void logAndThrowStoreException(org.slf4j.Logger log, String errMsgFormat, Object... args) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreExceptiondue to an error inFederationStateStore.- Parameters:
log- the logger interfaceerrMsgFormat- the error message format string.args- referenced by the format specifiers in the format string.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowStoreException
public static void logAndThrowStoreException(Throwable t, org.slf4j.Logger log, String errMsgFormat, Object... args) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreExceptiondue to an error inFederationStateStore.- Parameters:
t- the throwable raised in the called class.log- the logger interface.errMsgFormat- the error message format string.args- referenced by the format specifiers in the format string.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowInvalidInputException
public static void logAndThrowInvalidInputException(org.slf4j.Logger log, String errMsg) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreInvalidInputExceptiondue to an error inFederationStateStore.- Parameters:
log- the logger interfaceerrMsg- the error message- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowRetriableException
public static void logAndThrowRetriableException(org.slf4j.Logger log, String errMsg, Throwable t) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreRetriableExceptiondue to an error inFederationStateStore.- Parameters:
log- the logger interfaceerrMsg- the error messaget- the throwable raised in the called class.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowRetriableException
public static void logAndThrowRetriableException(Throwable t, org.slf4j.Logger log, String errMsgFormat, Object... args) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreRetriableExceptiondue to an error inFederationStateStore.- Parameters:
t- the throwable raised in the called class.log- the logger interface.errMsgFormat- the error message format string.args- referenced by the format specifiers in the format string.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
logAndThrowRetriableException
public static void logAndThrowRetriableException(org.slf4j.Logger log, String errMsgFormat, Object... args) throws org.apache.hadoop.yarn.exceptions.YarnException Throws anFederationStateStoreRetriableExceptiondue to an error inFederationStateStore.- Parameters:
log- the logger interface.errMsgFormat- the error message format string.args- referenced by the format specifiers in the format string.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- on failure
-
setProperty
public static void setProperty(com.zaxxer.hikari.HikariDataSource dataSource, String property, String value) Sets a specific value for a specific property ofHikariDataSourceSQL connections.- Parameters:
dataSource- theHikariDataSourceconnectionsproperty- the property to setvalue- the value to set
-
setUsername
Sets a specific username forHikariDataSourceSQL connections.- Parameters:
dataSource- theHikariDataSourceconnectionsuserNameDB- the value to set
-
setPassword
Sets a specific password forHikariDataSourceSQL connections.- Parameters:
dataSource- theHikariDataSourceconnectionspassword- the value to set
-
filterHomeSubCluster
public static boolean filterHomeSubCluster(SubClusterId filterSubCluster, SubClusterId homeSubCluster) Filter HomeSubCluster based on Filter SubCluster.- Parameters:
filterSubCluster- filter query conditionshomeSubCluster- homeSubCluster- Returns:
- return true, if match filter conditions, return false, if not match filter conditions.
-
encodeWritable
Encode for Writable objects. This method will convert the writable object to a base64 string.- Parameters:
key- Writable Key.- Returns:
- base64 string.
- Throws:
IOException- raised on errors performing I/O.
-
decodeWritable
Decode Base64 string to Writable object.- Parameters:
w- Writable Key.idStr- base64 string.- Throws:
IOException- raised on errors performing I/O.
-
convertMasterKeyToDelegationKey
public static org.apache.hadoop.security.token.delegation.DelegationKey convertMasterKeyToDelegationKey(RouterMasterKeyRequest request) Convert MasterKey to DelegationKey. Before using this function, please use FederationRouterRMTokenInputValidator to verify the request. By default, the request is not empty, and the internal object is not empty.- Parameters:
request- RouterMasterKeyRequest- Returns:
- DelegationKey.
-