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

SOLR-17516: LBHttpSolrClient: support HttpJdkSolrClient (multiple class verson) #2805

Closed
wants to merge 19 commits into from

Conversation

jdyer1
Copy link
Contributor

@jdyer1 jdyer1 commented Oct 28, 2024

This is a minimal PR to add Load Balancing functionality for the HttpJdkSolrClient. Included is test refactoring, adding the *JdkClient as a random choice for the integration test.

The result is not ideal: We have two layers of abstract classes and 3 implementations. Of the 3 implementations 1 is deprecated and the other two share all code. If we really are getting rid of the deprecated client for 10.0, we could easily consolidate in the future. A generic LB Solr Client is likely best but users may find it an annoying API change that only yields marginal improvement.

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

.withDefaultCollection(solr[0].getDefaultCollection())
.setAliveCheckInterval(500, TimeUnit.MILLISECONDS)
.build()) {
try (var h = client(baseSolrEndpoints)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

h? the type isn't clear enough to use 'var' if the name is merely 'h'.

}
}

private static class LBClientHolder implements AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't closing lbClient close the delegate? If it doesn't, shouldn't it? Then LBClientHolder could go away.

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, looking at LBSolrClient#close (from 2018) -- from which all 3 implementations inherit -- it doesn't seem to. And before I modified this test, it had both the inner and outer clients in the autoclosable try/catch. I agree that this seems wrong and perhaps was an oversight long ago. But then again, because we make the user create their own inner client as a separate step, perhaps it was thought it is the opener's responsibility to explicitly close.

Copy link
Contributor

Choose a reason for hiding this comment

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

we make the user create their own inner client as a separate step, perhaps it was thought it is the opener's responsibility to explicitly close

Ah; okay that makes sense; I didn't look previously.

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of a holder, could client return an anonymous subclass that propagates the close?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The holder is just to avoid copy/paste in these test methods. I'd rather test the actual class and not a subclass.

import org.slf4j.MDC;

/**
* LBHttp2SolrClient or "LoadBalanced LBHttp2SolrClient" is a load balancing wrapper around {@link
Copy link
Contributor

Choose a reason for hiding this comment

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

references to Http2SolrClient here should be replaced; could just refer to an Http based SolrClient.

*
* @since solr 8.0
*/
public abstract class LBHttpSolrClientBase<C extends HttpSolrClientBase> extends LBSolrClient {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need subclassing? In other words, can we have a general (not abstract) LB SolrClient that accepts an HttpSolrClientBase ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we do not need to subclass and I agree a generic LBHttpSolrClient would be better than this. Doing this would be an API change, and although we can change APIs with 10.0 coming, I wonder if it is worth annoying our users for what seems like a very slight improvement?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think yes; if we can't change major things in a major API then.... ? wow.
Also, again, few users use LbSolrClient; it's more of an internal SolrJ component. I say this from experience only; we don't officially communicate such.

}
}

private static class LBClientHolder implements AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of a holder, could client return an anonymous subclass that propagates the close?

@dsmiley
Copy link
Contributor

dsmiley commented Oct 30, 2024

Instead of subclasses of LB....SolrClient, ...Cloud...SolrClient, ...Http...ClusterStateProvider, we can have concrete impls that delegate to a SolrClient that is provided. It's a vision anyway; hopefully achievable?

CC @janhoy @gerlowskija as well

@janhoy
Copy link
Contributor

janhoy commented Oct 30, 2024

Instead of subclasses of LB....SolrClient, ...Cloud...SolrClient, ...Http...ClusterStateProvider, we can have concrete impls that delegate to a SolrClient that is provided. It's a vision anyway; hopefully achievable?

Isn't this a bit much to aim for in 10.0? I'd rather get a CloudJdkSolrClient ready for 10.0 with our current class hierarchy to offer a no-deps soljr, than getting stuck in a large refactoring.

@dsmiley
Copy link
Contributor

dsmiley commented Oct 30, 2024

Users generally don't refer to the LB client nor ClusterStateProvider; we shouldn't constrain ourselves, especially in a major release.

I'll propose a dev list discussion on how users choose between JDK vs Jetty for CloudSolrClient (which doesn't exist yet but if it did....)

@jdyer1
Copy link
Contributor Author

jdyer1 commented Oct 30, 2024

I am torn about what to do about the lengthy doc-comment which was copy/pasted from LBHttpSolrClient to LBHttp2SolrClient. I suppose the right thing to do at this point is to copy/paste it once again for LBHttpJdkSolrClient, and not to have anything elaborate in the abstract class doc-comment. This is yet another argument for having a generic LB Client and not subclasses, but I also feel this is beyond the scope of this PR.

@dsmiley
Copy link
Contributor

dsmiley commented Oct 30, 2024

this is beyond the scope of this PR

I'm not sure I agree; it's how the issue is approached. Maybe there's a sunk-cost issue here

@janhoy
Copy link
Contributor

janhoy commented Oct 31, 2024

Users generally don't refer to the LB client nor ClusterStateProvider; we shouldn't constrain ourselves, especially in a major release.

Agree, wouldn't care too much about breaking these two APIs. Also, if there is will and energy to refactor things for 10.0, it is better for users to take the hit in v10 than doing yet another change for v11.

@jdyer1 jdyer1 changed the title SOLR-17516: LBHttpSolrClient: support HttpJdkSolrClient SOLR-17516: LBHttpSolrClient: support HttpJdkSolrClient (multiple class verson) Oct 31, 2024
@jdyer1
Copy link
Contributor Author

jdyer1 commented Oct 31, 2024

I opened a better PR #2828 with a generic client. Please review/compare.

@jdyer1 jdyer1 closed this Nov 1, 2024
@jdyer1
Copy link
Contributor Author

jdyer1 commented Nov 1, 2024

superseded by #2828.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants