Class FederationStateStoreUtils

java.lang.Object
org.apache.hadoop.yarn.server.federation.store.utils.FederationStateStoreUtils

public final class FederationStateStoreUtils extends Object
Common utility methods used by the store implementations.
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
    • FEDERATION_STORE_URL

      public static final String 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 SQL FederationStateStore connections to the pool.
      Parameters:
      log - the logger interface
      cstmt - the interface used to execute SQL stored procedures
      conn - the SQL connection
      rs - 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 SQL FederationStateStore connections to the pool.
      Parameters:
      log - the logger interface
      cstmt - the interface used to execute SQL stored procedures
      conn - 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 SQL FederationStateStore connections to the pool.
      Parameters:
      log - the logger interface
      cstmt - 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 in FederationStateStore.
      Parameters:
      log - the logger interface
      errMsg - the error message
      t - 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 an FederationStateStoreException due to an error in FederationStateStore.
      Parameters:
      log - the logger interface
      errMsg - 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 an FederationStateStoreException due to an error in FederationStateStore.
      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
    • logAndThrowStoreException

      public static void logAndThrowStoreException(Throwable t, org.slf4j.Logger log, String errMsgFormat, Object... args) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws an FederationStateStoreException due to an error in FederationStateStore.
      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 an FederationStateStoreInvalidInputException due to an error in FederationStateStore.
      Parameters:
      log - the logger interface
      errMsg - 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 an FederationStateStoreRetriableException due to an error in FederationStateStore.
      Parameters:
      log - the logger interface
      errMsg - the error message
      t - 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 an FederationStateStoreRetriableException due to an error in FederationStateStore.
      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 an FederationStateStoreRetriableException due to an error in FederationStateStore.
      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 of HikariDataSource SQL connections.
      Parameters:
      dataSource - the HikariDataSource connections
      property - the property to set
      value - the value to set
    • setUsername

      public static void setUsername(com.zaxxer.hikari.HikariDataSource dataSource, String userNameDB)
      Sets a specific username for HikariDataSource SQL connections.
      Parameters:
      dataSource - the HikariDataSource connections
      userNameDB - the value to set
    • setPassword

      public static void setPassword(com.zaxxer.hikari.HikariDataSource dataSource, String password)
      Sets a specific password for HikariDataSource SQL connections.
      Parameters:
      dataSource - the HikariDataSource connections
      password - the value to set
    • filterHomeSubCluster

      public static boolean filterHomeSubCluster(SubClusterId filterSubCluster, SubClusterId homeSubCluster)
      Filter HomeSubCluster based on Filter SubCluster.
      Parameters:
      filterSubCluster - filter query conditions
      homeSubCluster - homeSubCluster
      Returns:
      return true, if match filter conditions, return false, if not match filter conditions.
    • encodeWritable

      public static String encodeWritable(org.apache.hadoop.io.Writable key) throws IOException
      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

      public static void decodeWritable(org.apache.hadoop.io.Writable w, String idStr) throws IOException
      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.