forked from snowflakedb/snowflake-ingest-java
-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] CC-33579 - use connector level proxy configs and make HttpClient keyed on proxy #35
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
Draft
sangeet259
wants to merge
3
commits into
v2.1.0-hotfix-x
Choose a base branch
from
proxy-server-support
base: v2.1.0-hotfix-x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/main/java/net/snowflake/ingest/utils/HttpClientSettingsKey.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright (c) 2012-2017 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
package net.snowflake.ingest.utils; | ||
|
||
import static net.snowflake.ingest.utils.Utils.isNullOrEmpty; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
/** | ||
* This class defines all parameters needed to create an HttpClient object for the ingest service. | ||
* It is used as the key for the static hashmap of reusable http clients. | ||
*/ | ||
public class HttpClientSettingsKey implements Serializable { | ||
|
||
private boolean useProxy; | ||
private String proxyHost = ""; | ||
private int proxyPort = 0; | ||
private String nonProxyHosts = ""; | ||
private String proxyUser = ""; | ||
private String proxyPassword = ""; | ||
private String accountName = ""; | ||
|
||
/** | ||
* Constructor for proxy configuration | ||
*/ | ||
public HttpClientSettingsKey( | ||
String accountName, | ||
String proxyHost, | ||
int proxyPort, | ||
String nonProxyHosts, | ||
String proxyUser, | ||
String proxyPassword) { | ||
this.useProxy = true; | ||
this.accountName = !isNullOrEmpty(accountName) ? accountName.trim() : ""; | ||
this.proxyHost = !isNullOrEmpty(proxyHost) ? proxyHost.trim() : ""; | ||
this.proxyPort = proxyPort; | ||
this.nonProxyHosts = !isNullOrEmpty(nonProxyHosts) ? nonProxyHosts.trim() : ""; | ||
this.proxyUser = !isNullOrEmpty(proxyUser) ? proxyUser.trim() : ""; | ||
this.proxyPassword = !isNullOrEmpty(proxyPassword) ? proxyPassword.trim() : ""; | ||
} | ||
|
||
/** | ||
* Constructor for non-proxy configuration | ||
*/ | ||
public HttpClientSettingsKey(String accountName) { | ||
this.useProxy = false; | ||
this.accountName = !isNullOrEmpty(accountName) ? accountName.trim() : ""; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) return true; | ||
if (obj == null || getClass() != obj.getClass()) return false; | ||
|
||
HttpClientSettingsKey that = (HttpClientSettingsKey) obj; | ||
|
||
return useProxy == that.useProxy && | ||
proxyPort == that.proxyPort && | ||
Objects.equals(accountName, that.accountName) && | ||
Objects.equals(proxyHost, that.proxyHost) && | ||
Objects.equals(nonProxyHosts, that.nonProxyHosts) && | ||
Objects.equals(proxyUser, that.proxyUser) && | ||
Objects.equals(proxyPassword, that.proxyPassword); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(useProxy, accountName, proxyHost, proxyPort, nonProxyHosts, proxyUser, proxyPassword); | ||
} | ||
|
||
public boolean usesProxy() { | ||
return this.useProxy; | ||
} | ||
|
||
public String getAccountName() { | ||
return this.accountName; | ||
} | ||
|
||
public String getProxyHost() { | ||
return this.proxyHost; | ||
} | ||
|
||
public int getProxyPort() { | ||
return this.proxyPort; | ||
} | ||
|
||
public String getProxyUser() { | ||
return this.proxyUser; | ||
} | ||
|
||
public String getProxyPassword() { | ||
return this.proxyPassword; | ||
} | ||
|
||
public String getNonProxyHosts() { | ||
return this.nonProxyHosts; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HttpClientSettingsKey[" + | ||
"accountName='" + accountName + '\'' + | ||
", useProxy=" + useProxy + | ||
", proxyHost='" + proxyHost + '\'' + | ||
", proxyPort=" + proxyPort + | ||
", nonProxyHosts='" + nonProxyHosts + '\'' + | ||
", proxyUser='" + proxyUser + '\'' + | ||
", proxyPassword=" + (proxyPassword.isEmpty() ? "not set" : "set") + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit -> lets no print password There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure. this is all for debugging. will remove. |
||
']'; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, just a suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it as it is from snowflake-jdbc - https://github.com/snowflakedb/snowflake-jdbc/blob/master/src/main/java/net/snowflake/client/core/HttpClientSettingsKey.java#L11