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-17302: Convert /cluster filestore APIs to JAX-RS (reinstating after revert) #2507

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.GENERIC_ENTITY_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 io.swagger.v3.oas.annotations.parameters.RequestBody;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;
import java.io.InputStream;
import java.util.List;
import org.apache.solr.client.api.model.SolrJerseyResponse;
import org.apache.solr.client.api.model.UploadToFileStoreResponse;

@Path("/cluster")
public interface ClusterFileStoreApis {
// TODO Better understand the purpose of the 'sig' parameter and improve docs here.
@PUT
@Operation(
summary = "Upload a file to the filestore.",
tags = {"file-store"})
@Path("/files{filePath:.+}")
UploadToFileStoreResponse uploadFile(
@Parameter(description = "File store path") @PathParam("filePath") String filePath,
@Parameter(description = "Signature(s) for the file being uploaded") @QueryParam("sig")
List<String> sig,
@Parameter(description = "File content to be stored in the filestore")
@RequestBody(
required = true,
extensions = {
@Extension(
properties = {
@ExtensionProperty(name = GENERIC_ENTITY_PROPERTY, value = "true")
})
})
InputStream requestBody);

@DELETE
@Operation(
summary = "Delete a file or directory from the filestore.",
tags = {"file-store"})
@Path("/files{path:.+}")
SolrJerseyResponse deleteFile(
@Parameter(description = "Path to a file or directory within the filestore")
@PathParam("path")
String path);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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;

public class UploadToFileStoreResponse extends SolrJerseyResponse {

@JsonProperty public String file;
@JsonProperty public String message;
}
20 changes: 18 additions & 2 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
import org.apache.solr.core.DirectoryFactory.DirContext;
import org.apache.solr.core.backup.repository.BackupRepository;
import org.apache.solr.core.backup.repository.BackupRepositoryFactory;
import org.apache.solr.filestore.ClusterFileStore;
import org.apache.solr.filestore.DistribFileStore;
import org.apache.solr.filestore.FileStore;
import org.apache.solr.filestore.FileStoreAPI;
import org.apache.solr.handler.ClusterAPI;
import org.apache.solr.handler.RequestHandlerBase;
Expand Down Expand Up @@ -294,7 +297,9 @@ && getZkController().getOverseer() != null
private volatile ClusterEventProducer clusterEventProducer;
private DelegatingPlacementPluginFactory placementPluginFactory;

private DistribFileStore fileStore;
private FileStoreAPI fileStoreAPI;
private ClusterFileStore clusterFileStoreAPI;
private SolrPackageLoader packageLoader;

private final Set<Path> allowPaths;
Expand Down Expand Up @@ -723,8 +728,8 @@ public SolrPackageLoader getPackageLoader() {
return packageLoader;
}

public FileStoreAPI getFileStoreAPI() {
return fileStoreAPI;
public FileStore getFileStore() {
return fileStore;
}

public SolrCache<?, ?> getCache(String name) {
Expand Down Expand Up @@ -856,9 +861,11 @@ private void loadInternal() {
(PublicKeyHandler) containerHandlers.get(PublicKeyHandler.PATH));
pkiAuthenticationSecurityBuilder.initializeMetrics(solrMetricsContext, "/authentication/pki");

fileStore = new DistribFileStore(this);
fileStoreAPI = new FileStoreAPI(this);
registerV2ApiIfEnabled(fileStoreAPI.readAPI);
registerV2ApiIfEnabled(fileStoreAPI.writeAPI);
registerV2ApiIfEnabled(ClusterFileStore.class);

packageLoader = new SolrPackageLoader(this);
registerV2ApiIfEnabled(packageLoader.getPackageAPI().editAPI);
Expand Down Expand Up @@ -1150,6 +1157,15 @@ protected void configure() {
.in(Singleton.class);
}
})
.register(
new AbstractBinder() {
@Override
protected void configure() {
bindFactory(new InjectionFactories.SingletonFactory<>(fileStore))
.to(DistribFileStore.class)
.in(Singleton.class);
}
})
.register(
new AbstractBinder() {
@Override
Expand Down
Loading
Loading