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-16372: Migrate collection listing, deletion to JAX-RS #1412

Merged

Conversation

gerlowskija
Copy link
Contributor

@gerlowskija gerlowskija commented Mar 1, 2023

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

Description

Solr is in the process of migrating its v2 APIs over to a JAX-RS framework. This gives us a more feature-rich framework for expressing APIs, makes it easier for the APIs themselves to be more REST-ful and standardized, and also makes it easier for Solr to integrate with tooling such as OpenAPI, which can be used to autogenerate client bindings for a variety of different languages.

But many non-JAX-RS APIs remain.

Solution

This PR introduces a baby-step in the right direction by migrating two additional APIs to JAX-RS: the "list collections" and "delete collection" APIs.

Tests

See DeleteCollectionAPITest. Existing v2 tests continue to pass.

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)
  • 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

In edition to migrating this one API, this PR establishes a pattern for
other overseer-based APIs whose responses aggregate the responses from
any and all sub-requests made by the overseer.
@gerlowskija gerlowskija marked this pull request as draft March 1, 2023 14:11
@gerlowskija gerlowskija marked this pull request as ready for review March 6, 2023 19:05
@gerlowskija
Copy link
Contributor Author

Alright, this should be ready to go. I'll plan on merging midweek and then backporting later on pending any feedback from folks.


/** Customizes the ObjectMapper settings used for serialization/deserialization in Jersey */
@SuppressWarnings("rawtypes")
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you try to fix this or too tricky? These are annoying

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I looked into it a bit but couldn't quite figure out the right syntax unfortunately ☹️

@Override
public void serialize(NamedList value, JsonGenerator gen, SerializerProvider provider)
throws IOException {
gen.writeObject(value.asShallowMap());
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect if benchmarks are done, this is going to be revisited to be more efficient. That NamedList.shallowMap looks trivial but the implementations of several of its methods call NamedList.asMap which is not. Fine for now I guess.
CC @noblepaul

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NamedList.shallowMap looks trivial but the implementations of several of its methods call NamedList.asMap which is not

Yeah, I'd picked the shallow-map approach because it looked reasonably trivial, but point well taken about the asMap usage. I suspect there's something that could be done with the MapWriter interface, but I couldn't get it working and eventually settled for what you see here.

public class SubResponseAccumulatingJerseyResponse extends SolrJerseyResponse {

@JsonProperty("requestid")
public String requestId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the requestId here the same as "rid" which is only used in logging? But maybe not because it's a response JSON property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not 'rid' related at all, though the overlap in terminology is definitely confusing and makes it seem that way.

This is about the async parameter that some collection-admin APIs take to run commands asynchronously.
Today, if you make a collection-admin request with an async param, Solr will return a mostly blank response with only this 'requestid' field set (echoing back the async value you passed in).

Copy link
Contributor

Choose a reason for hiding this comment

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

I found "requestid" somewhat overloaded as a term as well.... operation_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that Solr spits out 'requestid' here because that's the name of the parameter that v1 REQUESTSTATUS has taken, historically.

Definitely something worth cleaning up at some point. (Personally my preference would be for something more explicit, like asynchronous-request-id, but admittedly that's probably too verbose for most people's tastes.) I'd be onboard with any option that helped requestid be less overloaded.

That said - definitely beyond the scope of this ticket to make any field naming changes, unfortunately. Changing the response format would impact v1 APIs as well, have backcompat implications, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

For these types of feedback, what's the best way foreward? Should we create a JIRA for each one of these and make it be related to the current migration related JIRA, (in this case SOLR-16372)? If so, do you want to do them as the person moving the current issue forward, or me to do it as "the kibitzing person coming up with ideas" person? I don't want to lose these ideas improvements ;-)

// Only required properties provided
{
final ZkNodeProps message =
DeleteCollectionAPI.createRemoteMessage("someCollName", null, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Sigh... one day if we ever want to remove the Overseer fully, I see here an ever increasing number of tests that assume its existence. Yeah we've spoken about this, just reading this test with a heavy sigh.

@gerlowskija gerlowskija merged commit a750fcb into apache:main Mar 9, 2023
2 of 3 checks passed
@gerlowskija gerlowskija deleted the SOLR-16372-collection-crud-apis branch March 9, 2023 15:22
gerlowskija added a commit to gerlowskija/solr that referenced this pull request Mar 13, 2023
The endpoints themselves remain the same, other than moving to the
JAX-RS framework.
gerlowskija added a commit that referenced this pull request Mar 15, 2023
The endpoints themselves remain the same, other than moving to the
JAX-RS framework.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants