Skip to content

SOLR-16490 Create a v2 equivalent for RESTORECORE#1449

Merged
gerlowskija merged 5 commits intoapache:mainfrom
sayandigital:opensource-new
Aug 3, 2023
Merged

SOLR-16490 Create a v2 equivalent for RESTORECORE#1449
gerlowskija merged 5 commits intoapache:mainfrom
sayandigital:opensource-new

Conversation

@sayandigital
Copy link
Contributor

@sayandigital sayandigital commented Mar 11, 2023

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

Description

Create a v2 equivalent for /admin/cores for RESTORECORE

Solution

Adding a new class called RestoreCoreAPI and RestoreCorePayload as per the V2 API documentation provided in the document( Solr v2 API proposed changes https://docs.google.com/spreadsheets/d/1HAoBBFPpSiT8mJmgNZKkZAPwfCfPvlc08m5jz3fQBpA/edit#gid=1549066254)

Tests

Added test cases in solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java

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

@sayandigital
Copy link
Contributor Author

sayandigital commented Mar 11, 2023

@gerlowskija @chatman Request you to advise on the next steps

@sayandigital sayandigital marked this pull request as draft April 3, 2023 09:09
@gerlowskija
Copy link
Contributor

Hi @sayandigital - sorry for the delay, this got buried in my Inbox for awhile. But thanks for picking this up; will aim to review shortly!

@sayandigital
Copy link
Contributor Author

Hi @sayandigital - sorry for the delay, this got buried in my Inbox for awhile. But thanks for picking this up; will aim to review shortly!

Thank you @gerlowskija

Copy link
Contributor

@gerlowskija gerlowskija 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 the PR @sayandigital! Overall the PR looks good; just need to tweak the appearance of the v2 API a bit and make sure we're supporting all the parameters that the v1 RESTORECORE API supports.

Let me know if my inline comments are unclear or there's anything else I can help with!

* @see RestoreCorePayload
*/
@EndPoint(
path = {"/cores/{core}"},
Copy link
Contributor

Choose a reason for hiding this comment

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

[-1] IMO the endpoint specifics (particularly the path/url) should look a little different here.

It might've gotten buried in all the text on SOLR-16490, but we've been building up a spreadsheet of Solr's APIs and what their v2 equivalents will ideally look like. RESTORECORE is a bit hard to find there, but on the "'Command' APIs" Tab there's an entry for it. The path there is listed as /cores/{core}/restore- could we use that value here?

this.coreAdminHandler = coreAdminHandler;
}

@Command(name = V2_CORE_RESTORE_CMD)
Copy link
Contributor

Choose a reason for hiding this comment

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

[-1] Similar my comment above about the API path, I think the overall shape of this code looks great. Just need to tweak a few specifics so that the v2 RESTORECORE API lines up better with the direction we're trying to move our v2 APIs in.

Particularly, we're trying to move away from the v2 "command-based" APIs (i.e. APIs with a request body whose only top-level key is the name of some command or other). Instead we're generally moving the command itself into the path (see my comment above about changing the path to /cores/coreName/restore) and then moving most of the actual restore parameters to the top level of the "Payload"/request-body.

This is definitely do-able using the Solr-custom annotation framework you've used in this PR (see RenameCollectionAPI for an example). But you might find it more natural to do if you switch this API over to use the JAX-RS framework we've been moving towards. If you want to try that out there's a step-by-step writeup on this here and a handful of examples that you can crib from (example1, example2)


import org.apache.solr.common.util.ReflectMapWriter;

public class RestoreCorePayload implements ReflectMapWriter {}
Copy link
Contributor

Choose a reason for hiding this comment

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

[0] RestoreCore operations supports a bunch of params that we'll need to include in the payload/request-body here. For a sense of what all 'restore' supports, see the req.getParams() calls in RestoreCoreOp

@gerlowskija
Copy link
Contributor

Hi @sayandigital - thanks again for your work on this. Let me know if I can help out with any questions or issues that crop up when you get a chance to circle back to this!

Also addresses a number of review comments and adds some small bits of
test coverage.
@gerlowskija
Copy link
Contributor

Alright - I've made some changes on top of the base you provided @sayandigital. Both to address some of the review comments, and to use the more-preferred JAX-RS framework that Solr supports now. Tests and 'check' pass; gonna merge this afternoon and then let things bake for a few days before backporting.

@gerlowskija gerlowskija marked this pull request as ready for review August 3, 2023 15:50
@gerlowskija gerlowskija merged commit 2b34888 into apache:main Aug 3, 2023
gerlowskija added a commit that referenced this pull request Aug 8, 2023
No v2 equivalent existed prior to this commit.  The new V2 API is
`POST /api/cores/cName/restore {...}`.

---------

Co-authored-by: Jason Gerlowski <gerlowskija@apache.org>
@sayandigital
Copy link
Contributor Author

Thanks @gerlowskija to help take this to completion

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