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-16391: Convert create-core, core-status, /luke to JAX-RS #3054

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

gerlowskija
Copy link
Contributor

https://issues.apache.org/jira/browse/SOLR-16391

Description

Many v2 APIs remain on the legacy v2 API framework, including a number of APIs dealing with core CRUD and status-checking.

Solution

This commit migrates four APIs: create-core, single-core-status, all-core-status, and the "luke" request handler over to the JAX-RS framework. This adds the APIs to our growing OpenAPI spec, and ensures that SolrRequest/SolrResponse implementations are generated for each.

Since the v1 and v2 response formats are the same for each API converted in this PR, the response POJOs are also useful in existing tests for our v1 APIs, and this PR rolls out some of that usage to clear up needless casting and NamedList inspection.

Lastly, this PR modifies some 'public'-visibility SolrJ methods that will need properly deprecated in an eventual 9x backport. I've tried to flag those with a PR comment where I'm aware of the change. Please point out any others I've missed.

Tests

TBD

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

Still need to run tests and do a final once-over of the code, but this
appears to be pretty close.
This is not working, or even compiling, but I wanted to checkpoint my
work to share it between machines.  When resuming, look for the TODO
comment in StatusOp.java.
Builds on the previous commit's broken state and brings things to a
point where they should at least compile so that I can run tests and
start catching bugs.

TODO/NOCOMMITs throughout the changes still, and there are a few tests I
know fail from the earlier create-core change, but we can start to catch
things.
@gerlowskija
Copy link
Contributor Author

Still TODO: expand response POJOs usage in tests where appropriate, ref-guide updates for APIs, flag methods-needing-deprecation with PR comments.

@epugh
Copy link
Contributor

epugh commented Jan 22, 2025

As my 13 year old would say, you are cookin!

Out of curiosity, at this point, do you think we need to keep up the emphasis on back porting to 9x.. If we smell 10 on the horizon, maybe we don't worry about backporting......

Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

12/32 so far, looking good.

final var coreStatusReq = new CoresApi.GetCoreStatus(coreName);
final var coreStatusRsp = coreStatusReq.process(solrClient).getParsed();
final var coreStatusByName = coreStatusRsp.status;
final var coreStatus = coreStatusByName.get(coreName);
Copy link
Contributor

Choose a reason for hiding this comment

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

these var are a lot more readable...

final var initFailureForCore = failureStatus.get(coreName);
final boolean hasName = coreStatus != null && coreStatus.name != null;
exists = hasName || initFailureForCore != null;
wait = hasName && initFailureForCore == null && "true".equals(coreStatus.isLoading);
Copy link
Contributor

Choose a reason for hiding this comment

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

boo that we are string comparing versus using a boolean...

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like I see boolean true used elsewhere for isLoading?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -92,32 +82,12 @@ public enum CoreAdminOperation implements CoreAdminOp {
CREATE_OP(
CREATE,
it -> {
assert TestInjection.injectRandomDelayInCoreCreation();
Copy link
Contributor

Choose a reason for hiding this comment

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

take it we don't need this in the future? Or a pattern we don't want to continue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eric found this later on his own, but for anyone else, this line was moved but not removed. See here

info.add("schema", core.getSchemaResource());
info.add("startTime", core.getStartTimeStamp());
info.add("uptime", core.getUptimeMs());
info.name = core.getName();
Copy link
Contributor

Choose a reason for hiding this comment

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

so much nicer

}

private CreateCoreResponse doCreate(CreateCoreParams requestBody, CreateCoreResponse response) {
assert TestInjection.injectRandomDelayInCoreCreation();
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh.. Okay, maybe thsi line explains why the other had it removed!

Thought this code was already on the branch prior to creating the PR,
but neglected to commit/push I guess.

Tests should be passing with this commit.
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.

2 participants