-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOLR-17302: Convert remaining filestore APIs to JAX-RS (#2532)
This migrates the remainder of Solr's "filestore" APIs to the JAX-RS framework. No cosmetic changes were made in the process, with the small exception of folding the internal "local delete" functionality into the existing delete API using a new `localDelete` boolean query param.
- Loading branch information
1 parent
e36a6de
commit d0aad69
Showing
17 changed files
with
456 additions
and
285 deletions.
There are no files selected for viewing
This file contains 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
67 changes: 67 additions & 0 deletions
67
solr/api/src/java/org/apache/solr/client/api/endpoint/NodeFileStoreApis.java
This file contains 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,67 @@ | ||
/* | ||
* 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 static org.apache.solr.client.api.util.Constants.OMIT_FROM_CODEGEN_PROPERTY; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.extensions.Extension; | ||
import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.QueryParam; | ||
import org.apache.solr.client.api.model.SolrJerseyResponse; | ||
|
||
/** | ||
* V2 APIs for fetching filestore files, syncing them across nodes, or fetching related metadata. | ||
*/ | ||
@Path("/node") | ||
public interface NodeFileStoreApis { | ||
@GET | ||
@Operation( | ||
summary = "Retrieve file contents or metadata from the filestore.", | ||
tags = {"file-store"}, | ||
// The response of this v2 API is highly variable based on the parameters specified. It can | ||
// return raw (potentially binary) file data, a JSON-ified representation of that file data, | ||
// metadata regarding one or multiple file store entries, etc. This variability can be | ||
// handled on the Jersey server side, but would be prohibitively difficult to accommodate in | ||
// our code-generation templates. Ideally, cosmetic improvements (e.g. splitting it up into | ||
// multiple endpoints) will make this unnecessary in the future. But for now, the extension | ||
// property below ensures that this endpoint is ignored entirely when doing code generation. | ||
extensions = { | ||
@Extension( | ||
properties = {@ExtensionProperty(name = OMIT_FROM_CODEGEN_PROPERTY, value = "true")}) | ||
}) | ||
@Path("/files{path:.+}") | ||
SolrJerseyResponse getFile( | ||
@Parameter(description = "Path to a file or directory within the filestore") | ||
@PathParam("path") | ||
String path, | ||
@Parameter( | ||
description = | ||
"If true, triggers syncing for this file across all nodes in the filestore") | ||
@QueryParam("sync") | ||
Boolean sync, | ||
@Parameter(description = "An optional Solr node name to fetch the file from") | ||
@QueryParam("getFrom") | ||
String getFrom, | ||
@Parameter(description = "Indicates that (only) file metadata should be fetched") | ||
@QueryParam("meta") | ||
Boolean meta); | ||
} |
28 changes: 28 additions & 0 deletions
28
solr/api/src/java/org/apache/solr/client/api/model/FileStoreDirectoryListingResponse.java
This file contains 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,28 @@ | ||
/* | ||
* 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 java.util.Map; | ||
|
||
/** | ||
* One of several possible responses from {@link | ||
* org.apache.solr.client.api.endpoint.NodeFileStoreApis#getFile(String, Boolean, String, Boolean)} | ||
*/ | ||
public class FileStoreDirectoryListingResponse extends SolrJerseyResponse { | ||
@JsonProperty public Map<String, Object> files; | ||
} |
44 changes: 44 additions & 0 deletions
44
solr/api/src/java/org/apache/solr/client/api/model/FileStoreEntryMetadata.java
This file contains 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,44 @@ | ||
/* | ||
* 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.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** Represents the metadata for a single filestore file or directory */ | ||
public class FileStoreEntryMetadata { | ||
@JsonProperty public String name; | ||
@JsonProperty public Boolean dir; | ||
@JsonProperty public Long size; | ||
@JsonProperty public Date timestamp; | ||
|
||
private Map<String, Object> additionalMetadata = new HashMap<>(); | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> unknownProperties() { | ||
return additionalMetadata; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setUnknownProperty(String field, Object value) { | ||
additionalMetadata.put(field, value); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
solr/api/src/java/org/apache/solr/client/api/model/FileStoreJsonFileResponse.java
This file contains 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,30 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* One of several possible responses from {@link | ||
* org.apache.solr.client.api.endpoint.NodeFileStoreApis#getFile(String, Boolean, String, Boolean)} | ||
* | ||
* <p>Typically used when 'wt=json' is specified while retrieving an individual file from the | ||
* filestore | ||
*/ | ||
public class FileStoreJsonFileResponse extends SolrJerseyResponse { | ||
@JsonProperty public String response; | ||
} |
This file contains 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 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 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 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 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.