You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ge...@apache.org on 2023/09/27 17:40:17 UTC
[solr] 05/06: Migrade install-core-data to 'api' module
This is an automated email from the ASF dual-hosted git repository.
gerlowskija pushed a commit to branch SOLR-16825-migrate-definitions-to-api-module-pt4
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 1896fdde26b74e61292475629bf09274521e97e1
Author: Jason Gerlowski <ge...@apache.org>
AuthorDate: Wed Sep 27 10:33:46 2023 -0400
Migrade install-core-data to 'api' module
---
.../client/api/endpoint/InstallCoreDataApi.java | 42 ++++++++++++++++++++++
.../api/model/InstallCoreDataRequestBody.java | 30 ++++++++++++++++
.../solr/handler/admin/CoreAdminHandler.java | 4 +--
.../solr/handler/admin/InstallCoreDataOp.java | 12 +++----
...nstallCoreDataAPI.java => InstallCoreData.java} | 40 ++++-----------------
5 files changed, 86 insertions(+), 42 deletions(-)
diff --git a/solr/api/src/java/org/apache/solr/client/api/endpoint/InstallCoreDataApi.java b/solr/api/src/java/org/apache/solr/client/api/endpoint/InstallCoreDataApi.java
new file mode 100644
index 00000000000..4ee95539571
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/endpoint/InstallCoreDataApi.java
@@ -0,0 +1,42 @@
+/*
+ * 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 javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import org.apache.solr.client.api.model.InstallCoreDataRequestBody;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+
+/**
+ * V2 API definition for installing an offline index to a single core of a shard.
+ *
+ * <p>This is an internal API intended for use only by the Collection Admin "Install Shard Data"
+ * API.
+ */
+@Path("/cores/{coreName}/install")
+public interface InstallCoreDataApi {
+
+ @POST
+ @Operation(
+ summary = "Install an offline index to a specified core",
+ tags = {"cores"})
+ SolrJerseyResponse installCoreData(
+ @PathParam("coreName") String coreName, InstallCoreDataRequestBody requestBody)
+ throws Exception;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/InstallCoreDataRequestBody.java b/solr/api/src/java/org/apache/solr/client/api/model/InstallCoreDataRequestBody.java
new file mode 100644
index 00000000000..2ba9d09c1f6
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/InstallCoreDataRequestBody.java
@@ -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;
+
+public class InstallCoreDataRequestBody {
+ // Expected to point to an index directory (e.g. data/techproducts_shard1_replica_n1/data/index)
+ // for a single core that has previously been uploaded to the backup repository previously
+ // uploaded to the backup repository.
+ @JsonProperty public String location;
+
+ @JsonProperty public String repository;
+
+ @JsonProperty public String asyncId;
+}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
index d928282df5c..d9ece272f75 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
@@ -58,7 +58,7 @@ import org.apache.solr.handler.admin.api.AllCoresStatusAPI;
import org.apache.solr.handler.admin.api.BackupCoreAPI;
import org.apache.solr.handler.admin.api.CoreSnapshotAPI;
import org.apache.solr.handler.admin.api.CreateCoreAPI;
-import org.apache.solr.handler.admin.api.InstallCoreDataAPI;
+import org.apache.solr.handler.admin.api.InstallCoreData;
import org.apache.solr.handler.admin.api.MergeIndexesAPI;
import org.apache.solr.handler.admin.api.OverseerOperationAPI;
import org.apache.solr.handler.admin.api.PrepareCoreRecoveryAPI;
@@ -403,7 +403,7 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
public Collection<Class<? extends JerseyResource>> getJerseyResources() {
return List.of(
CoreSnapshotAPI.class,
- InstallCoreDataAPI.class,
+ InstallCoreData.class,
BackupCoreAPI.class,
RestoreCoreAPI.class,
ReloadCoreAPI.class);
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/InstallCoreDataOp.java b/solr/core/src/java/org/apache/solr/handler/admin/InstallCoreDataOp.java
index c115739f6a8..7d7ada266a3 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/InstallCoreDataOp.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/InstallCoreDataOp.java
@@ -21,9 +21,10 @@ import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
import static org.apache.solr.common.params.CoreAdminParams.BACKUP_LOCATION;
import static org.apache.solr.common.params.CoreAdminParams.BACKUP_REPOSITORY;
+import org.apache.solr.client.api.model.InstallCoreDataRequestBody;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.handler.admin.api.InstallCoreDataAPI;
+import org.apache.solr.handler.admin.api.InstallCoreData;
import org.apache.solr.handler.api.V2ApiUtils;
/**
@@ -31,7 +32,7 @@ import org.apache.solr.handler.api.V2ApiUtils;
* "Install Shard Data" Collection-Admin functionality
*
* <p>Converts v1-style query parameters into a v2-style request body and delegating to {@link
- * InstallCoreDataAPI}.
+ * InstallCoreData}.
*/
public class InstallCoreDataOp implements CoreAdminHandler.CoreAdminOp {
@Override
@@ -39,11 +40,10 @@ public class InstallCoreDataOp implements CoreAdminHandler.CoreAdminOp {
final SolrParams params = it.req.getParams();
final String coreName = params.required().get(CoreAdminParams.CORE);
- final InstallCoreDataAPI api =
- new InstallCoreDataAPI(
+ final InstallCoreData api =
+ new InstallCoreData(
it.handler.getCoreContainer(), it.handler.getCoreAdminAsyncTracker(), it.req, it.rsp);
- final InstallCoreDataAPI.InstallCoreDataRequestBody requestBody =
- new InstallCoreDataAPI.InstallCoreDataRequestBody();
+ final InstallCoreDataRequestBody requestBody = new InstallCoreDataRequestBody();
requestBody.repository = params.get(BACKUP_REPOSITORY);
requestBody.location = params.get(BACKUP_LOCATION);
requestBody.asyncId = params.get(ASYNC);
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/InstallCoreDataAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/InstallCoreData.java
similarity index 73%
rename from solr/core/src/java/org/apache/solr/handler/admin/api/InstallCoreDataAPI.java
rename to solr/core/src/java/org/apache/solr/handler/admin/api/InstallCoreData.java
index c0cd11b3451..a64fff77905 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/InstallCoreDataAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/InstallCoreData.java
@@ -17,16 +17,11 @@
package org.apache.solr.handler.admin.api;
-import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.lang.invoke.MethodHandles;
import java.net.URI;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
+import org.apache.solr.client.api.endpoint.InstallCoreDataApi;
+import org.apache.solr.client.api.model.InstallCoreDataRequestBody;
import org.apache.solr.client.api.model.SolrJerseyResponse;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.ZkController;
@@ -36,25 +31,19 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.core.backup.repository.BackupRepository;
import org.apache.solr.handler.RestoreCore;
import org.apache.solr.handler.admin.CoreAdminHandler;
-import org.apache.solr.jersey.JacksonReflectMapWriter;
import org.apache.solr.jersey.PermissionName;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
- * v2 implementation of the "Install Core Data" Core-Admin API
+ * V2 API implementation of the "Install Core Data" Core-Admin API
*
* <p>This is an internal API intended for use only by the Collection Admin "Install Shard Data"
* API.
*/
-@Path("/cores/{coreName}/install")
-public class InstallCoreDataAPI extends CoreAdminAPIBase {
+public class InstallCoreData extends CoreAdminAPIBase implements InstallCoreDataApi {
- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- public InstallCoreDataAPI(
+ public InstallCoreData(
CoreContainer coreContainer,
CoreAdminHandler.CoreAdminAsyncTracker coreAdminAsyncTracker,
SolrQueryRequest req,
@@ -62,11 +51,8 @@ public class InstallCoreDataAPI extends CoreAdminAPIBase {
super(coreContainer, coreAdminAsyncTracker, req, rsp);
}
- @POST
- @Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
@PermissionName(CORE_EDIT_PERM)
- public SolrJerseyResponse installCoreData(
- @PathParam("coreName") String coreName, InstallCoreDataRequestBody requestBody)
+ public SolrJerseyResponse installCoreData(String coreName, InstallCoreDataRequestBody requestBody)
throws Exception {
final SolrJerseyResponse response = instantiateJerseyResponse(SolrJerseyResponse.class);
@@ -118,18 +104,4 @@ public class InstallCoreDataAPI extends CoreAdminAPIBase {
return response;
}
-
- public static class InstallCoreDataRequestBody implements JacksonReflectMapWriter {
- // Expected to point to an index directory (e.g. data/techproducts_shard1_replica_n1/data/index)
- // for a single core that has previously been uploaded to the backup repository previously
- // uploaded to the backup repository.
- @JsonProperty("location")
- public String location;
-
- @JsonProperty("repository")
- public String repository;
-
- @JsonProperty("async")
- public String asyncId;
- }
}