-
Notifications
You must be signed in to change notification settings - Fork 821
SOLR-18212: Migrate PackageAPI endpoints from @EndPoint/@Command to JAX-RS #4178
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
Open
epugh
wants to merge
22
commits into
apache:main
Choose a base branch
from
epugh:copilot/migrate-packageapi-to-jax-rs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a86cf71
Initial plan
Copilot 9422c8c
Update TestPackages.java to use new JAX-RS PackageAPI endpoints
Copilot 744e8ff
Migrate PackageAPI from @EndPoint/@Command to JAX-RS annotations
Copilot cc26412
Fix PackageAPIJaxRsTest to use generated request classes and check re…
Copilot 5040f5b
Extract magic numbers as named constants in PackageAPIJaxRs
Copilot 83c2f5c
Rename PackageAPIJaxRs to PackageAPI and old PackageAPI to PackageStore
Copilot d71f199
Additional migrations from the old "command" style to the new RESTful…
epugh 8994e03
fix test
epugh 199b0f3
doc change
epugh 463f590
Merge remote-tracking branch 'upstream/main' into copilot/migrate-pac…
epugh ae94dd3
Updates from merging in latest code from main.
epugh 62212c3
PackageAPI and PackageApis super confusing.
epugh 30ab7cc
Fix up expectedVersion property that was missing.
epugh 99d90e7
Use our generated solrj code instead of hand crafting.
epugh 7967574
tidy
epugh 7491730
Small cleanups.
epugh deb2142
Now have a JIRA issue
epugh 2578d26
shockingly, we had these unused objects
epugh bf46dc7
Don't need fancy instantiate method!
epugh a0bef90
Use SolrJ methods where possible.
epugh ba61c1b
More conversion to SolrJ methods
epugh 670562d
Rework the tests. I am a bit on the fence about detailed docs.
epugh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
changelog/unreleased/SOLR-18212-migrate-packageapi-to-jax-rs.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| title: The package management API now has OpenAPI and SolrJ support. | ||
| type: changed | ||
| authors: | ||
| - name: Eric Pugh | ||
| links: | ||
| - name: PR#4178 | ||
| url: https://github.com/apache/solr/pull/4178 |
101 changes: 101 additions & 0 deletions
101
solr/api/src/java/org/apache/solr/client/api/endpoint/PackageApis.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.solr.client.api.endpoint; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
| import jakarta.ws.rs.DELETE; | ||
| import jakarta.ws.rs.GET; | ||
| import jakarta.ws.rs.POST; | ||
| import jakarta.ws.rs.Path; | ||
| import jakarta.ws.rs.PathParam; | ||
| import jakarta.ws.rs.QueryParam; | ||
| import org.apache.solr.client.api.model.AddPackageVersionRequestBody; | ||
| import org.apache.solr.client.api.model.PackagesResponse; | ||
| import org.apache.solr.client.api.model.SolrJerseyResponse; | ||
|
|
||
| /** V2 API definitions for managing Solr packages. */ | ||
| @Path("/cluster/package") | ||
| public interface PackageApis { | ||
|
|
||
| @GET | ||
| @Operation( | ||
| summary = "List all packages registered in this Solr cluster.", | ||
| tags = {"package"}) | ||
| PackagesResponse listPackages( | ||
| @Parameter( | ||
| description = | ||
| "Name of a package to refresh on the receiving node only (reloads its listeners from ZooKeeper). Used internally for inter-node fan-out by the refresh endpoint; not normally invoked directly.") | ||
| @QueryParam("refreshPackage") | ||
| String refreshPackage, | ||
| @Parameter( | ||
| description = | ||
| "If provided, the node waits until its package data matches this ZooKeeper version.") | ||
| @QueryParam("expectedVersion") | ||
| Integer expectedVersion); | ||
|
|
||
| @GET | ||
| @Path("/{packageName}") | ||
| @Operation( | ||
| summary = "Get information about a specific package in this Solr cluster.", | ||
| tags = {"package"}) | ||
| PackagesResponse getPackage( | ||
| @Parameter(description = "The name of the package.", required = true) | ||
| @PathParam("packageName") | ||
| String packageName, | ||
| @Parameter( | ||
| description = | ||
| "If provided, the node waits until its package data matches this ZooKeeper version before responding.") | ||
| @QueryParam("expectedVersion") | ||
| Integer expectedVersion); | ||
|
|
||
| @POST | ||
| @Path("/{packageName}/versions") | ||
| @Operation( | ||
| summary = "Add a version of a package to this Solr cluster.", | ||
| tags = {"package"}) | ||
| SolrJerseyResponse addPackageVersion( | ||
| @Parameter(description = "The name of the package.", required = true) | ||
| @PathParam("packageName") | ||
| String packageName, | ||
| @RequestBody(description = "Details of the package version to add.", required = true) | ||
| AddPackageVersionRequestBody requestBody); | ||
|
|
||
| @DELETE | ||
| @Path("/{packageName}/versions/{version}") | ||
| @Operation( | ||
| summary = "Delete a specific version of a package from this Solr cluster.", | ||
| tags = {"package"}) | ||
| SolrJerseyResponse deletePackageVersion( | ||
| @Parameter(description = "The name of the package.", required = true) | ||
| @PathParam("packageName") | ||
| String packageName, | ||
| @Parameter(description = "The version of the package to delete.", required = true) | ||
| @PathParam("version") | ||
| String version); | ||
|
|
||
| @POST | ||
| @Path("/{packageName}/refresh") | ||
| @Operation( | ||
| summary = "Refresh a package on all nodes in this Solr cluster.", | ||
| tags = {"package"}) | ||
| SolrJerseyResponse refreshPackage( | ||
| @Parameter(description = "The name of the package to refresh.", required = true) | ||
| @PathParam("packageName") | ||
| String packageName); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
solr/api/src/java/org/apache/solr/client/api/model/PackagesResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.solr.client.api.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** Response for the package listing API. */ | ||
| public class PackagesResponse extends SolrJerseyResponse { | ||
|
|
||
| @JsonProperty("result") | ||
| @Schema(description = "The package data including znode version and package definitions.") | ||
| public PackageData result; | ||
|
|
||
| /** Package data returned by the package API. */ | ||
| public static class PackageData { | ||
| @JsonProperty("znodeVersion") | ||
| @Schema(description = "The ZooKeeper version of the packages.json node.") | ||
| public int znodeVersion; | ||
|
|
||
| @JsonProperty("packages") | ||
| @Schema(description = "Map from package name to list of package versions.") | ||
| public Map<String, List<PackageVersion>> packages; | ||
| } | ||
|
|
||
| /** Describes a single version of a package. */ | ||
| public static class PackageVersion { | ||
| @JsonProperty("package") | ||
| @Schema(description = "The package name.") | ||
| public String pkg; | ||
|
|
||
| @JsonProperty("version") | ||
| @Schema(description = "The version string.") | ||
| public String version; | ||
|
|
||
| @JsonProperty("files") | ||
| @Schema(description = "List of file paths from the file store included in this version.") | ||
| public List<String> files; | ||
|
|
||
| @JsonProperty("manifest") | ||
| @Schema(description = "Optional manifest reference.") | ||
| public String manifest; | ||
|
|
||
| @JsonProperty("manifestSHA512") | ||
| @Schema(description = "Optional SHA-512 hash of the manifest.") | ||
| public String manifestSHA512; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[Q] Should 'expectedVersion' be supported here, in addition to the "list" method above?
In the current code on main it looks like the query param is supported for both the "list-all" and "get-single-package" usecases.
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! It's kind of internal tooling, but yeah.