Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PECO-1598] Add README for proxy and minor fix #273

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The Databricks SDK for Java includes functionality to accelerate development wit
- [Single-sign-on with OAuth](#single-sign-on-sso-with-oauth)
- [Error handling](#error-handling)
- [Logging](#logging)
- [Proxy](#proxy)
- [Interface stability](#interface-stability)
- [Disclaimer](#disclaimer)

Expand Down Expand Up @@ -410,5 +411,18 @@ This will enable logging at the debug level and above. Developers can adjust the

Overall, the logging capabilities provided by the Databricks SDK for Java can be a powerful tool for monitoring and troubleshooting your Databricks Java projects. Developers can use the various logging methods and configuration options provided by the SDK to customize the logging output to their specific needs.

## Proxy
Databricks SDK for Java supports clients using proxy. Clients can use their proxy setup either by providing the proxy settings in the `DatabricksConfig` configuration object or by creating a `ProxyConfig` object and passing it to the constructor of `CommonsHttpClient`. The following properties can be set in the `.databrickscfg` file to configure the proxy settings:

| DatabricksConfig Attribute | Description | Environment variable |
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| `use_system_properties_http` | _(Boolean)_ Setting this boolean to `true` will cause the http client to automatically use proxy settings set at the system level. Namely under `http/https.proxyHost` etc. | `USE_SYSTEM_PROPERTIES_HTTP` |
| `proxy_host` | _(String)_ The proxy server host | `PROXY_HOST` |
| `proxy_port` | _(Integer)_ The proxy server port | `PROXY_PORT` |
| `proxy_auth_type` | _(Enum: ProxyAuthType)_ This specifies how the client authenticates with the proxy server. Currently, supported auth mechanisms are `BASIC` and `SPNEGO` (only kerberos) | `PROXY_AUTH_TYPE` |
| `proxy_username` | _(String)_ The proxy user to authenticate with, when using `BASIC` auth mechanism | `PROXY_USERNAME` |
| `proxy_password` | _(String)_ The proxy password to authenticate with, when using `BASIC` auth mechanism | `PROXY_PASSWORD` |

Note: when using Kerberos authentication in SPNEGO, the `java.security.krb5.conf` system property must point to the `krb5.conf/krb5.ini` file that contains the Kerberos configuration.
## Disclaimer
Databricks is actively working on stabilizing the Databricks SDK for Java's interfaces. API clients for all services are generated from specification files that are synchronized from the main platform. You are highly encouraged to pin the exact dependency version and read the [changelog](https://github.com/databricks/databricks-sdk-java/blob/main/CHANGELOG.md) where Databricks documents the changes. Databricks may have minor [documented](https://github.com/databricks/databricks-sdk-java/blob/main/CHANGELOG.md) backward-incompatible changes, such as renaming the methods or some type names to bring more consistency.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public enum ProxyAuthType {
SPNEGO
}

public ProxyConfig() {}

public ProxyConfig(DatabricksConfig config) {
this.host = config.getProxyHost();
this.port = config.getProxyPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,26 @@ public static void setupProxy(ProxyConfig config, HttpClientBuilder builder) {
Integer proxyPort = null;
String proxyUser = null;
String proxyPassword = null;
ProxyConfig.ProxyAuthType proxyAuthType = null;
if (config.getUseSystemProperties() != null && config.getUseSystemProperties()) {
builder.useSystemProperties();
String protocol = System.getProperty("https.proxyHost") != null ? "https" : "http";
proxyHost = System.getProperty(protocol + ".proxyHost");
proxyPort = Integer.parseInt(System.getProperty(protocol + ".proxyPort"));
proxyUser = System.getProperty(protocol + ".proxyUser");
proxyPassword = System.getProperty(protocol + ".proxyPassword");
proxyAuthType = ProxyConfig.ProxyAuthType.BASIC;
}
// Override system properties if proxy configuration is explicitly set
if (config.getHost() != null) {
proxyHost = config.getHost();
proxyPort = config.getPort();
proxyUser = config.getUsername();
proxyPassword = config.getPassword();
proxyAuthType = config.getProxyAuthType();
builder.setProxy(new HttpHost(proxyHost, proxyPort));
}
setupProxyAuth(
proxyHost, proxyPort, config.getProxyAuthType(), proxyUser, proxyPassword, builder);
setupProxyAuth(proxyHost, proxyPort, proxyAuthType, proxyUser, proxyPassword, builder);
}

/**
Expand Down
Loading