Class ClientConfigurator


  • public class ClientConfigurator
    extends Object
    This class is responsible for configuring the Databricks config based on the connection context. The databricks config is then used to create the SDK or Thrift client.
    • Method Detail

      • getTokenCachePath

        public static Path getTokenCachePath​(String host,
                                             String clientId,
                                             List<String> scopes)
        Returns the path for the token cache file based on host, client ID, and scopes. This creates a unique cache path using a hash of these parameters.
        Parameters:
        host - The host URL
        clientId - The OAuth client ID
        scopes - The OAuth scopes
        Returns:
        The path for the token cache file
      • setupProxyConfig

        public void setupProxyConfig​(com.databricks.sdk.core.commons.CommonsHttpClient.Builder httpClientBuilder)
        Setup proxy settings in the databricks config.
      • getWorkspaceClient

        public com.databricks.sdk.WorkspaceClient getWorkspaceClient()
      • setupAuthConfig

        public void setupAuthConfig()
        Setup the workspace authentication settings in the databricks config.
      • findAvailablePort

        public int findAvailablePort​(List<Integer> initialPorts)
        Finds the first available port from the provided list of ports. If a single port is provided, it tries incremental ports (port, port+1, port+2, etc.) If multiple ports are provided, it tries each port in the list.
        Parameters:
        initialPorts - List of ports to try
        Returns:
        The first available port
        Throws:
        com.databricks.sdk.core.DatabricksException - if no available port is found
      • resetAccessTokenInConfig

        public void resetAccessTokenInConfig​(String newAccessToken)
      • convertNonProxyHostConfigToBeSystemPropertyCompliant

        public static String convertNonProxyHostConfigToBeSystemPropertyCompliant​(String nonProxyHosts)
        Currently, the ODBC driver takes in nonProxyHosts as a comma separated list of suffix of non-proxy hosts i.e. suffix1|suffix2|suffix3. Whereas, the SDK takes in nonProxyHosts as a list of patterns separated by '|'. This pattern conforms to the system property format in the Java Proxy Guide.
        Parameters:
        nonProxyHosts - Comma separated list of suffix of non-proxy hosts
        Returns:
        nonProxyHosts in system property compliant format from Java Proxy Guide
      • getDatabricksConfig

        public com.databricks.sdk.core.DatabricksConfig getDatabricksConfig()