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-15745: Move public v2 "core-admin" APIs to annotation framework #565
SOLR-15745: Move public v2 "core-admin" APIs to annotation framework #565
Conversation
Solr's been in the slow process of moving its v2 APIs away from the existing apispec/mapping framework towards one that relies on more explicit annotations to specify API properties. This commit converts the 'reload', 'swap', 'rename', 'unload', 'merge-indexes', and 'split' commands of `/v2/cores/<core>` over to the preferred framework. (NOTE: the spelling 'indexes' in the 'merge-indexes' command was retained here for consistency/compatibility. We should consider changing it going forward.)
Since "v2" is experimental, why not fix "indexes" spelling now? |
Two "soft" reasons:
That said, I'd buy the argument that "indexes" is a clear spelling error, and I'd be willing to make an exception for it if you think I should @epugh ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general LGTM. Couple of nit picks. You are grinding this out!
import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET; | ||
import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST; | ||
import static org.apache.solr.client.solrj.SolrRequest.METHOD.PUT; | ||
import static org.apache.solr.client.solrj.SolrRequest.METHOD.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to figure out how to make our IDE's not do this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, sigh. I play with these IDE settings every now and then when it comes up in review, but I still see it revert from time to time. Not sure what the deal is - I'll try playing with it a bit more.
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PERM; | ||
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_EDIT_PERM; | ||
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_READ_PERM; | ||
import static org.apache.solr.security.PermissionNameProvider.Name.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LIkewise
* | ||
* @see org.apache.solr.client.solrj.request.beans.MergeIndexesPayload | ||
*/ | ||
@EndPoint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked CreateCoreAPI, and this looks consistent with how that is annoated ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! (That's a good thing right? I think they should have the same annotations, except that the path on CreateCore should be /cores
?)
|
||
import java.util.List; | ||
|
||
// TODO rename all of the MergeIndexes* classes to MergeIndices. These are only named this way for consistency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do it now? Seperate PR for naming only changes?
import java.util.List; | ||
|
||
public class SplitCorePayload implements ReflectMapWriter { | ||
// Should be converted as an array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a bug that we need to fix elsewhere, not in the bounds of this PR, or is this more of a wish? Is there a SOLR- that could be referenced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops - no, this isn't a bug. This was just a "note to self" so I could remember some niggling detail while I was working on this one. I forgot to remove it is all. Will remove.
import org.apache.solr.common.util.ReflectMapWriter; | ||
|
||
public class SwapCoresPayload implements ReflectMapWriter { | ||
@JsonProperty(required = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be doing required = true
is other places as part of this conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like having some validation on these would be a big win if it's built in to this style of API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this enforcement is built in to the annotation-style APIs.
Should we be doing required = true is other places as part of this conversion?
For sure - if there's a place where I skipped required = true
that's actually required, absolutely lmk. I thought I set it everywhere I should have, but it's easy to miss.
There are 430 results for "Indexes", and honestly, the more I think on it, I think that while "Indices" may be grammatically correct, "Indexes" is really the word we use! At any rate, only 51 "indices" in the source ;-) |
I thought I was "closing" a comment thread, oops. |
Would it make sense to move the Payload classes into the API classes? I think that's the only place they are used? |
Well, that's another good reason to leave the spelling as-is for now. Yikes though haha 😬
The only reason I haven't done that yet is that I have some far-off aspiration of re-using the payload classes in SolrJ as well. It'd be really nice if each API enumerated the params it accepts in only 1 place that can be used on the server and client side alike. (Bit more detail on this idea here) If you feel strongly about it, I'm open to moving them inside the API classes - I don't want to design too much for a "someday" that may never come. Just lmk. (Either way it should probably be a separate PR since there are a bazillion Payload classes and I'm only touching a few of them here.) |
Put the new ones inside, leave the old ones? |
It wouldn't be my choice in a vacuum: I can live with giving up on my long-term goal of reusing these payload classes, but introducing the inconsistency for different payloads just seems like kicking me while I'm down 😛 But I guess the inconsistency is only a problem if I'm slow getting a PR together to move the other |
I think that's everyone's review comments, except for Eric's (totally justified) finger-wagging about my incorrect import settings, which I'm still wrestling with. I'm going to run |
…565) Solr's been in the slow process of moving its v2 APIs away from the existing apispec/mapping framework towards one that relies on more explicit annotations to specify API properties. This commit converts the 'reload', 'swap', 'rename', 'unload', 'merge-indexes', and 'split' commands of `/v2/cores/<core>` over to the preferred framework. (NOTE: the spelling 'indexes' in the 'merge-indexes' command was retained here for consistency/compatibility. We should consider changing it going forward.)
Based on review feedback from Mike Drob on PR apache#565
This commit converts the 'reload', 'swap', 'rename', 'unload',
'merge-indexes', and 'split' commands of
/v2/cores/<core>
over to thepreferred framework.
(NOTE: the spelling 'indexes' in the 'merge-indexes' command was
retained here for consistency/compatibility. We should consider
changing it going forward.)
Description
Solr's been in the slow process of moving its v2 APIs away from the
existing apispec/mapping framework towards one that relies on more
explicit annotations to specify API properties. Many "core-admin"
APIs remain unconverted.
Solution
This commit converts the 'reload', 'swap', 'rename', 'unload',
'merge-indexes', and 'split' commands of
/v2/cores/<core>
over to thepreferred annotation framework.
Tests
See V2CoreAPIMappingTest
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.