Skip to content

Conversation

@enqueue
Copy link
Contributor

@enqueue enqueue commented Jan 24, 2021

Fix for #522

@zhicwu
Copy link
Contributor

zhicwu commented Jan 25, 2021

Thank you @enqueue! Will it work when httpAuthorization is set?

@enqueue
Copy link
Contributor Author

enqueue commented Jan 25, 2021

Thank you @enqueue! Will it work when httpAuthorization is set?

Good point! I will check it.

}

private static boolean isConfigurationValidForAuth(ClickHouseProperties props) {
return props.getHost() != null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we need to check host here - it's always null in BalancedClickhouseDataSource. Will this cause authentication issue when connecting to a cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I had not thought about this. Will try to find out how the BalancedClickhouseDataSource works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some tests for common scenarios to BalancedClickhouseDataSourceTest, do you have any others you can think of? The host is set in 'ClickhouseJdbcUrlParser.parseClickhouseUrlfrom the URL, so we hopefully do not have to change the implementation ofBalancedClickhouseDataSource`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks for the detailed explanation. I don't have anything to add then.

String password, String expectedAuthHeader) throws Exception
{
ClickHouseProperties props = new ClickHouseProperties();
props.setHost("localhost");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add one more test when host is null?

Copy link
Contributor Author

@enqueue enqueue Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

How would this happen? The properties being passed here already contain the host as parsed by ClickhouseJdbcUrlParser...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought host is null when using BalancedDataSource but I'll double check :p


private final CloseableHttpClient client;

private final HttpClientContext httpContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make it protected and create the context in constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is analogous to the client. This class does not know how to construct these, but gets ready to use "connection stuff".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I would say that the statement should simply get everything it needs to do its work. It does not need to know how to create connection context, but this is my subjective judgement. I can understand that we want to try and keep the number of ties with Apache HTTP Client under control. I am going to follow your suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. Perhaps it's too early to consider refactoring. I'm fine to keep HttpContext argument now, but I think we may use a new interface like ClickHouseClient to replace both CloseableHtppClient and HttpContext, in order to hide protocol implementation details.

@zhicwu
Copy link
Contributor

zhicwu commented Feb 2, 2021

Thank you @enqueue for making this pull request. I think we're close to get it merged. Mean time, can we remove HttpContext parameter from Statement and PreparedStatement constructors? Instead, we can create http context inside the constructor. This is because HttpContext is tied to http, so when we add support for more protocols, we'll have to remove it anyway because we only need to pass a client(e.g. HttpClient, NativeClient or GrpcClient) for execution.

Let me know if you have different opinion and we can discuss.

@enqueue
Copy link
Contributor Author

enqueue commented Feb 6, 2021

Hi @zhicwu I updated the PR to take into account your suggestions. I need your help getting the build to green though. The maven output says something about ClickHouseResponseSummary missing, but there isn't any code referring to this class. Running mvn verify locally works. What am I doing wrong? Thank you very much in advance.

@zhicwu
Copy link
Contributor

zhicwu commented Feb 6, 2021

Thank you @enqueue. ResponseSummary was merged from PR #498. Have you merged all changes from upstream/develop? I'm out for launch but I'll look into this when I get back to home.

@zhicwu zhicwu merged commit 8e68aa4 into ClickHouse:develop Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants