You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/10/24 19:12:40 UTC

[GitHub] [solr] iamsanjay opened a new pull request, #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

iamsanjay opened a new pull request, #1119:
URL: https://github.com/apache/solr/pull/1119

   https://issues.apache.org/jira/browse/SOLR-16461
   
   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Solr:
   
   * https://issues.apache.org/jira/projects/SOLR
   
   For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA. 
   To create a Jira issue, you will need to create an account there first.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * SOLR-16461: Create v2 equivalent of v1 ReplicationHandler 'BACKUP'
   
   SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   A backup API for user manager cluster or single node installation has no v2 equivalent. This ticket is used to track changes that will be made to add the v2 API for the 'backup'.
   
   v1 Existing Form
   
   ```
   /solr/{coreName}/replication?command=backup`
   ```
   
   to:
   ```
   /api//cores/{coreName}/replication/backups
   ```
   
   # Solution
   
   This PR adds v2 endpoints for Backup (via ReplicationHandler) using new JAS-RX framework. In JAS-RX api we inject core container and then through `CoreContainer`, an object of `ReplicationHandler` is injected inside API. After getting access to the ReplicationHandler, a method named `handleRequestBody` is called to handle the backup.
   
   Note:- Currently this PR is in draft mode as the injection is failing while creating API object. We are working on this. 
   
   # Tests
   
   It's still work in progress. Currently test is failing because of injection issues. But there is one test case added which calls the v2 endpoints and assert following in the returned response.
   - Status Code on successful backup
   - Content type 
   - Response JSON
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on PR #1119:
URL: https://github.com/apache/solr/pull/1119#issuecomment-1663251308

   I agree this is a good place to start. there is a bit of gymnastics, but I will try to push some changes to this branch to continue on the existing proposal (I don't mind it at all, I fear messing something up unknowingly). or if you have a better idea on how to collaborate @gerlowskija I am all ears.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1322029293


##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {
+
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private final SolrCore solrCore;
+  private final ReplicationHandlerConfig replicationHandlerConfig;
+
+  @Inject
+  public SnapshotBackupAPI(SolrCore solrCore, ReplicationHandlerConfig replicationHandlerConfig) {
+    this.solrCore = solrCore;
+    this.replicationHandlerConfig = replicationHandlerConfig;
+  }
+
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+  @Operation(summary = "Backup command using ReplicationHandler")
+  @PermissionName(CORE_EDIT_PERM)
+  public BackupReplicationResponse createBackup(
+      @RequestBody BackupReplicationRequestBody backupReplicationPayload) throws Exception {
+    if (backupReplicationPayload == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Required request-body is missing");
+    }
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler) solrCore.getRequestHandler(ReplicationHandler.PATH);
+    return doBackup(replicationHandler, backupReplicationPayload);
+  }
+
+  private BackupReplicationResponse doBackup(
+      ReplicationHandler replicationHandler,
+      BackupReplicationRequestBody backupReplicationPayload) {
+    BackupReplicationResponse response = instantiateJerseyResponse(BackupReplicationResponse.class);
+    int numberToKeep = backupReplicationPayload.numberToKeep;
+    int numberBackupsToKeep = replicationHandlerConfig.getNumberBackupsToKeep();
+    String location = backupReplicationPayload.location;
+    String repoName = backupReplicationPayload.repository;
+    String commitName = backupReplicationPayload.commitName;
+    String name = backupReplicationPayload.name;
+    Consumer<NamedList<?>> resultConsumer = result -> response.result = result;
+    try {
+      ReplicationHandler.doSnapShoot(

Review Comment:
   updated the test, introduced a test class with a dummy impl so it simplifies the verification a bit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
iamsanjay commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1006235472


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   I will look into this and then maybe open a ticket as well. Thank you so much for all the help @gerlowskija. I really appreciate it!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1319865106


##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {

Review Comment:
   [+1] Thanks for updating the path here to match what we lined up in the spreadsheet!
   
   [-0] There are a LOT of different backup or snapshot adjacent APIs: `/admin/collections?action=BACKUP`, `/admin/cores?action=BACKUP`, `/admin/collections?action=CREATESNAPSHOT`, `/admin/cores?action=CREATESNAPSHOT`, `/replication?cmd=backup`, etc.  With so many similar APIs, it's really hard to find names to differentiate them all.  (Tbh I'm not even sure what the differences are between the ReplicationHandle backup functionality and what's exposed via `/admin/collections` and `/admin/cores`.)
   
   But if you've got any sparks of inspiration there and can come up with a name that helps distinguish this API from its close cousins, we should definitely use that here.
   
   (As a larger question, I think we should re-evaluate which of these functionalities is worth keeping around in 10.0.  So maybe this disambiguation question is only a short-term concern.  But still 🤷 )



##########
solr/core/src/test/org/apache/solr/handler/admin/api/SnapshotBackupAPITest.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.InjectionFactories;
+import org.apache.solr.jersey.SolrJacksonMapper;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.process.internal.RequestScoped;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Unit tests for {@link SnapshotBackupAPI}. */
+public class SnapshotBackupAPITest extends JerseyTest {
+
+  private SolrCore solrCore;
+  private ReplicationHandlerConfig replicationHandlerConfig;
+
+  @BeforeClass
+  public static void ensureWorkingMockito() {
+    assumeWorkingMockito();
+  }
+
+  @Override
+  protected Application configure() {
+    resetMocks();
+    final ResourceConfig config = new ResourceConfig();
+    config.register(SnapshotBackupAPI.class);
+    config.register(SolrJacksonMapper.class);
+    config.register(SolrExceptionTestMapper.class);
+    config.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            bindFactory(new InjectionFactories.SingletonFactory<>(solrCore))
+                .to(SolrCore.class)
+                .in(RequestScoped.class);
+          }
+        });
+    config.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            bindFactory(new InjectionFactories.SingletonFactory<>(replicationHandlerConfig))
+                .to(ReplicationHandlerConfig.class)
+                .in(RequestScoped.class);
+          }
+        });
+    return config;
+  }
+
+  @Test
+  public void testSuccessfulBackupCommand() throws Exception {

Review Comment:
   [-0] Does this test name make sense, if the backup (intentionally and correctly) comes back with a 400?
   
   [0] I think I agree with something you said elsewhere, that it'd be worth adding some input-validation unit tests somewhere.  But nbd if you disagree on that at this point.



##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {
+
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private final SolrCore solrCore;
+  private final ReplicationHandlerConfig replicationHandlerConfig;
+
+  @Inject
+  public SnapshotBackupAPI(SolrCore solrCore, ReplicationHandlerConfig replicationHandlerConfig) {
+    this.solrCore = solrCore;
+    this.replicationHandlerConfig = replicationHandlerConfig;
+  }
+
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+  @Operation(summary = "Backup command using ReplicationHandler")
+  @PermissionName(CORE_EDIT_PERM)
+  public BackupReplicationResponse createBackup(
+      @RequestBody BackupReplicationRequestBody backupReplicationPayload) throws Exception {
+    if (backupReplicationPayload == null) {

Review Comment:
   [0] It comes up often enough that maybe it's worth moving this check-null-and-throw to be a protected method on `JerseyResource` similar to the existing `ensureRequiredParameterProvided`.



##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {
+
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private final SolrCore solrCore;
+  private final ReplicationHandlerConfig replicationHandlerConfig;
+
+  @Inject
+  public SnapshotBackupAPI(SolrCore solrCore, ReplicationHandlerConfig replicationHandlerConfig) {
+    this.solrCore = solrCore;
+    this.replicationHandlerConfig = replicationHandlerConfig;
+  }
+
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+  @Operation(summary = "Backup command using ReplicationHandler")
+  @PermissionName(CORE_EDIT_PERM)
+  public BackupReplicationResponse createBackup(
+      @RequestBody BackupReplicationRequestBody backupReplicationPayload) throws Exception {
+    if (backupReplicationPayload == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Required request-body is missing");
+    }
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler) solrCore.getRequestHandler(ReplicationHandler.PATH);
+    return doBackup(replicationHandler, backupReplicationPayload);
+  }
+
+  private BackupReplicationResponse doBackup(
+      ReplicationHandler replicationHandler,
+      BackupReplicationRequestBody backupReplicationPayload) {
+    BackupReplicationResponse response = instantiateJerseyResponse(BackupReplicationResponse.class);
+    int numberToKeep = backupReplicationPayload.numberToKeep;
+    int numberBackupsToKeep = replicationHandlerConfig.getNumberBackupsToKeep();
+    String location = backupReplicationPayload.location;
+    String repoName = backupReplicationPayload.repository;
+    String commitName = backupReplicationPayload.commitName;
+    String name = backupReplicationPayload.name;
+    Consumer<NamedList<?>> resultConsumer = result -> response.result = result;
+    try {
+      ReplicationHandler.doSnapShoot(

Review Comment:
   [0] It'd prob be easier to test this API in `SnapshotBackupAPITest` if the underling functionality lived in some helper class (that I guess was injected into the ctor).  Not sure it's worth the hassle and noise of refactoring that all, but figured I'd mention it here in case you liked the idea 🤷  



##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {

Review Comment:
   [+1] Thanks for updating the path here to match what we lined up in the spreadsheet!
   
   [-0] There are a LOT of different backup or snapshot adjacent APIs: `/admin/collections?action=BACKUP`, `/admin/cores?action=BACKUP`, `/admin/collections?action=CREATESNAPSHOT`, `/admin/cores?action=CREATESNAPSHOT`, `/replication?cmd=backup`, etc.  With so many similar APIs, it's really hard to find names to differentiate them all.  (Tbh I'm not even sure what the differences are between the ReplicationHandle backup functionality and what's exposed via `/admin/collections` and `/admin/cores`.)
   
   But if you've got any sparks of inspiration there and can come up with a name that helps distinguish this API from its close cousins, we should definitely use that here.
   
   (As a larger question, I think we should re-evaluate which of these functionalities is worth keeping around in 10.0.  So maybe this disambiguation question is only a short-term concern.  But still 🤷 )



##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {
+
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private final SolrCore solrCore;
+  private final ReplicationHandlerConfig replicationHandlerConfig;
+
+  @Inject
+  public SnapshotBackupAPI(SolrCore solrCore, ReplicationHandlerConfig replicationHandlerConfig) {
+    this.solrCore = solrCore;
+    this.replicationHandlerConfig = replicationHandlerConfig;
+  }
+
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+  @Operation(summary = "Backup command using ReplicationHandler")
+  @PermissionName(CORE_EDIT_PERM)
+  public BackupReplicationResponse createBackup(
+      @RequestBody BackupReplicationRequestBody backupReplicationPayload) throws Exception {
+    if (backupReplicationPayload == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Required request-body is missing");
+    }
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler) solrCore.getRequestHandler(ReplicationHandler.PATH);
+    return doBackup(replicationHandler, backupReplicationPayload);
+  }
+
+  private BackupReplicationResponse doBackup(
+      ReplicationHandler replicationHandler,
+      BackupReplicationRequestBody backupReplicationPayload) {
+    BackupReplicationResponse response = instantiateJerseyResponse(BackupReplicationResponse.class);
+    int numberToKeep = backupReplicationPayload.numberToKeep;
+    int numberBackupsToKeep = replicationHandlerConfig.getNumberBackupsToKeep();
+    String location = backupReplicationPayload.location;
+    String repoName = backupReplicationPayload.repository;
+    String commitName = backupReplicationPayload.commitName;
+    String name = backupReplicationPayload.name;
+    Consumer<NamedList<?>> resultConsumer = result -> response.result = result;
+    try {
+      ReplicationHandler.doSnapShoot(

Review Comment:
   [0] It'd prob be easier to test this API in `SnapshotBackupAPITest` if the underling functionality lived in some helper class (that I guess was injected into the ctor).  Not sure it's worth the hassle and noise of refactoring that all, but figured I'd mention it here in case you liked the idea 🤷  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
gerlowskija commented on PR #1119:
URL: https://github.com/apache/solr/pull/1119#issuecomment-1344407206

   Hi @iamsanjay 
   
   Just wanted to give you a short update on my lack of progress on this.  It is definitely still on my radar, but there are a few things that are holding it up at this point:
   
   1. As you pointed out elsewhere, the JAX-RS integration in Solr doesn't yet have a mechanism to read config values out of solrconfig.xml, which is kindof a serious blocker for this ticket.  That's on my short list to get to, and once it's resolved I plan to circle back to merging this.
   2. Additionally, there's been some discussion in the community recently about how the recent addition of the JAX-RS framework has affected (or, more pointedly, slowed down) Solr startup in some cases.  That's turned into a big blocker, and there's even talk of deferring the release of our JAX-RS v2 APIs until that perf regression can be mitigated.  Most of my focus has shifted to that - after all, it's not much good focusing on individual JAX-RS APIs if shipping the whole framework gets delayed 😛 (see SOLR-16531 for more details)
   
   Anyway, that's all to say that I haven't gotten to this PR, but that I haven't forgotten it or let it fall off my radar.  I'm just focusing on a few blockers that need wrapped up, and plan to return to this when that's finished.  Thanks for your patience!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1006098487


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   > Yes it's backup API from the ReplicationHandler but I assumed from the new proposed v2 format that it goes into CoreAdminHandler as it starts with /cores
   
   Ah, I see!
   
   The short answer here is that there's no 1:1 mapping between the v2 path and the RequestHandler that the functionality originally came from.  Or vice versa.  There are v1 RequestHandlers (e.g. CollectionsHandler) whose functionality is going to be split across a handful of different paths.  And there are v2 paths whose functionality originally came from a number of different RequestHandlers.
   
   So in terms of registering each v2 API, the convention I've been following has been to register them on whatever RequestHandler the functionality originally came from, regardless of the v2 path.
   
   Great observation though - I'll try to clarify this in the "step-by-step" writeup I put in JIRA.
   
   > I will not have access to the SolrParams that we configure in solrconfig.xml for ReplicationHandler
   
   You've got a really keen eye for all the stuff that doesn't work yet! 😛   You're right - we don't currently have a way to get those requestHandler-level settings forwarded to the corresponding v2 API.  Definitely something I hope to fix sooner rather than later.  I spiked out a solution awhile back but it was pretty hacky.  If you're interested in digging into that some, definitely lmk and we can get a JIRA filed and work on it together.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1004311073


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   [Q] There are lots of backup APIs - maybe I just got confused about which one you were working on - but I would've expected this new method to appear in ReplicationHandler since that's the backup functionality you're intending to address.  What am I missing?



##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;

Review Comment:
   [0] Don't forget your copyright header setup; it's nearly impossible IMO to remember to put the header in yourself on every file you create!



##########
solr/core/src/test/org/apache/solr/handler/replication/BackupAPITest.java:
##########
@@ -0,0 +1,102 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.inject.Singleton;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.InjectionFactories;
+import org.apache.solr.jersey.SolrJacksonMapper;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.process.internal.RequestScoped;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Unit test of v2 endpoints for Replication Handler backup command */

Review Comment:
   [+1] This is a cool test; I've only experimented with using `JerseyTest` up to this point, but I like what I see so far!
   
   [0] You could probably do a javadoc "link", rather than trying to describe the API being tested in words.
   
   e.g.
   
   ```
   /**
    * Unit tests for {@link BackupAPI}
    */
   ```



##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {

Review Comment:
   [-1] Because Solr has a bunch of different "backup"-related features and APIs, I think we should come up with a more descriptive name here.  Maybe "ReplicationBackupAPI", since that's where the functionality initially existed?  Maybe "SnapshotBackupAPI", since this triggers the "snapshot" functionality and not a "true" backup?  Idk.  Any ideas?



##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")

Review Comment:
   [0] Personally, I'd make the path-variable singular instead of plural (i.e. "core"), since it's referring to a single specific core.



##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON})
+  @Operation(
+      summary = "Backup command using ReplicationHandler",
+      tags = {"cores"})
+  @PermissionName(CORE_EDIT_PERM)
+  public SolrJerseyResponse createBackup(
+      @RequestBody BackupReplicationPayload backupReplicationPayload) throws Exception {
+    final SolrJerseyResponse response = instantiateJerseyResponse(SolrJerseyResponse.class);
+    final Map<String, Object> v1Params = backupReplicationPayload.toMap(new HashMap<>());
+    v1Params.put(ReplicationHandler.COMMAND, ReplicationHandler.CMD_BACKUP);
+    replicationHandler.handleRequestBody(wrapParams(solrQueryRequest, v1Params), solrQueryResponse);
+    return response;
+  }
+
+  /* POJO for v2 endpoints request body.*/
+  public static class BackupReplicationPayload implements JacksonReflectMapWriter {

Review Comment:
   [0] The traditional v2 framework set up the convention of naming these classes "Payloads", so this definitely isn't "wrong".  But my personal preference would be to go with "RequestBody" for our JAX-RS APIs (e.g. BackupReplicationRequestBody).
   
   If you don't have a strong preference for 'Payload', consider renaming to use 'RequestBody' instead.



##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   [0] I wasn't able to reproduce the injection issue you mentioned - in fact I was having trouble triggering the API at all, but this code here strikes me as a likely culprit for the issue you described.
   
   We're using 'coreName' here to look up the SolrCore object, but what value does 'coreName' have at this point?  Idk whether it would be set or not when the constructor gets called.  I'd guess not: I'm not sure the "instance variable" even exists for the `@PathParam` annotation to give it a value until after the constructor is called.  Reflection stuff is weird, so I wouldn't bet on it for sure, but that'd be my guess.
   
   Anyway, if 'coreName' is null here, I bet we'd get a null SolrCore and trigger a NPE at this line.
   
   ----
   
   Assuming this is the issue (which is a big 'IF', admittedly) - I'd suggest we take the bit of functionality we need from ReplicationHandler and move it to a public method here, instead of trying to reuse ReplicationHandler directly.
   
   There are "strategic" reasons that Solr wants to move in this sort of direction, see my comment in JIRA [here](https://issues.apache.org/jira/browse/SOLR-16461?focusedCommentId=17619003&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17619003) for a bit more context.
   
   Happy to help with that if need be, lmk.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302183689


##########
solr/core/src/test/org/apache/solr/handler/replication/BackupAPITest.java:
##########
@@ -0,0 +1,102 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.inject.Singleton;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.InjectionFactories;
+import org.apache.solr.jersey.SolrJacksonMapper;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.process.internal.RequestScoped;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Unit test of v2 endpoints for Replication Handler backup command */

Review Comment:
   javadoc updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
iamsanjay commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1004818754


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   Now moving on to the other thing which is to move the replicationHandler code to API's. I am just curious If we move code to API's. How we are going to access this below configuration? I will try to run the backup command via JAS-RX API and see if I still have access to them.
   
   ```
   <requestHandler name="/replication" class="solr.ReplicationHandler">
     <lst name="leader">
       <str name="replicateAfter">optimize</str>
       <str name="backupAfter">optimize</str>
       <str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
     </lst>
     <int name="maxNumberOfBackups">2</int>
     <str name="commitReserveDuration">00:00:10</str>
     <lst name="invariants">
       <str name="maxWriteMBPerSec">16</str>
     </lst>
   </requestHandler>
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
iamsanjay commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1004814541


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   [Q] Does that mean the v2 API format will also change for '/replication'? i.e. instead of starting with '/cores' Will it starts with '/replication'?
   something like that.
   ```
   /replication/{coreName}/backups
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302178487


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   moved api to `ReplicationHandler` which also now injects a config object for the new api



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
iamsanjay commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1004816133


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   Yes  the issue is that I was accessing `@PathParam`  value in Constructor and It was not available. That's why It was giving the Injection error. I removed it. And, now it's able to create API's object. Thank you so much.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302177490


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON})
+  @Operation(
+      summary = "Backup command using ReplicationHandler",
+      tags = {"cores"})
+  @PermissionName(CORE_EDIT_PERM)
+  public SolrJerseyResponse createBackup(
+      @RequestBody BackupReplicationPayload backupReplicationPayload) throws Exception {
+    final SolrJerseyResponse response = instantiateJerseyResponse(SolrJerseyResponse.class);
+    final Map<String, Object> v1Params = backupReplicationPayload.toMap(new HashMap<>());
+    v1Params.put(ReplicationHandler.COMMAND, ReplicationHandler.CMD_BACKUP);
+    replicationHandler.handleRequestBody(wrapParams(solrQueryRequest, v1Params), solrQueryResponse);
+    return response;
+  }
+
+  /* POJO for v2 endpoints request body.*/
+  public static class BackupReplicationPayload implements JacksonReflectMapWriter {

Review Comment:
   rename done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302173918


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;

Review Comment:
   header added



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #1119:
URL: https://github.com/apache/solr/pull/1119#issuecomment-1609414830

   > the JAX-RS integration in Solr doesn't yet have a mechanism to read config values out of solrconfig.xml, which is kindof a serious blocker for this ticket
   
   There's a JIRA to track this effort now - [SOLR-16847](https://issues.apache.org/jira/browse/SOLR-16847), so hopefully the blocker can be resolved soon and we can get this in!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on PR #1119:
URL: https://github.com/apache/solr/pull/1119#issuecomment-1688919453

   @gerlowskija updated the PR, please take a look and let me know what you think. the test will fail on purpose to show that the correct class was called, but because it's a static util method it's a bit more tricky to mock.
   I did not do any manual testing yet and I think some param validation might still be needed.
   
   crave build is failing because it's not able to apply patch -  I think the branch is too old? we could do a quick rebase to bring this up to a fresher revision. let me know what you think.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1322029693


##########
solr/core/src/test/org/apache/solr/handler/admin/api/SnapshotBackupAPITest.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.InjectionFactories;
+import org.apache.solr.jersey.SolrJacksonMapper;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.process.internal.RequestScoped;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Unit tests for {@link SnapshotBackupAPI}. */
+public class SnapshotBackupAPITest extends JerseyTest {
+
+  private SolrCore solrCore;
+  private ReplicationHandlerConfig replicationHandlerConfig;
+
+  @BeforeClass
+  public static void ensureWorkingMockito() {
+    assumeWorkingMockito();
+  }
+
+  @Override
+  protected Application configure() {
+    resetMocks();
+    final ResourceConfig config = new ResourceConfig();
+    config.register(SnapshotBackupAPI.class);
+    config.register(SolrJacksonMapper.class);
+    config.register(SolrExceptionTestMapper.class);
+    config.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            bindFactory(new InjectionFactories.SingletonFactory<>(solrCore))
+                .to(SolrCore.class)
+                .in(RequestScoped.class);
+          }
+        });
+    config.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            bindFactory(new InjectionFactories.SingletonFactory<>(replicationHandlerConfig))
+                .to(ReplicationHandlerConfig.class)
+                .in(RequestScoped.class);
+          }
+        });
+    return config;
+  }
+
+  @Test
+  public void testSuccessfulBackupCommand() throws Exception {

Review Comment:
   agreed. added a validation test with 400 error, and a success test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
iamsanjay commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1004820977


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {

Review Comment:
   I have created new package for it and named it 'replication' under 'handler' package. And I was thinking of moving all the replication related commands under this package.
   But if we do not want new package then Yes I can change it's name to suggested name and move it to /handler/admin/api



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay commented on PR #1119:
URL: https://github.com/apache/solr/pull/1119#issuecomment-1673749396

   > @iamsanjay are you ok with me pushing some changes to this PR's branch to get things goin again?
   
   Yes @stillalex go ahead. Let me know if you have any questions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1322028887


##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {
+
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private final SolrCore solrCore;
+  private final ReplicationHandlerConfig replicationHandlerConfig;
+
+  @Inject
+  public SnapshotBackupAPI(SolrCore solrCore, ReplicationHandlerConfig replicationHandlerConfig) {
+    this.solrCore = solrCore;
+    this.replicationHandlerConfig = replicationHandlerConfig;
+  }
+
+  /**
+   * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1
+   * /solr/coreName/replication?command=backup
+   */
+  @POST
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+  @Operation(summary = "Backup command using ReplicationHandler")
+  @PermissionName(CORE_EDIT_PERM)
+  public BackupReplicationResponse createBackup(
+      @RequestBody BackupReplicationRequestBody backupReplicationPayload) throws Exception {
+    if (backupReplicationPayload == null) {

Review Comment:
   makes sense, method added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1006099737


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   Short answer: you're right that this doesn't work currently.
   
   See my slightly longer explanation [here](https://github.com/apache/solr/pull/1119#discussion_r1006098487).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] iamsanjay commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
iamsanjay commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1004814313


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   Yes it's backup API from the `ReplicationHandler` but I assumed from the new proposed v2 format that it goes into CoreAdminHandler as it starts with `/cores`
   ```
   /cores/{coreName}/replication/backups
   ```
   But yes you are right, this should goes inside ReplicationHandler. Also I have not tried it yet, but going via CoreAdminHandler I will not have access to the SolrParams that we configure in solrconfig.xml for ReplicationHandler.
   ```
   <requestHandler name="/replication" class="solr.ReplicationHandler">
     <lst name="leader">
       <str name="replicateAfter">optimize</str>
       <str name="backupAfter">optimize</str>
       <str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
     </lst>
     <int name="maxNumberOfBackups">2</int>
     <str name="commitReserveDuration">00:00:10</str>
     <lst name="invariants">
       <str name="maxWriteMBPerSec">16</str>
     </lst>
   </requestHandler>
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302180114


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {
+  private final SolrQueryRequest solrQueryRequest;
+  private final SolrQueryResponse solrQueryResponse;
+  private final ReplicationHandler replicationHandler;
+
+  @PathParam("cores")
+  private String coreName;
+
+  @Inject
+  public BackupAPI(
+      CoreContainer cc, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) {
+    this.replicationHandler =
+        (ReplicationHandler) cc.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   nothing to followup on, resolving.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302179642


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")

Review Comment:
   renamed to `/cores/{coreName}/replication/backups`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1006101772


##########
solr/core/src/java/org/apache/solr/handler/replication/BackupAPI.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.solr.handler.replication;
+
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{cores}/replication/backups")
+public class BackupAPI extends JerseyResource {

Review Comment:
   I didn't notice the package change.  I don't introduce new packages too often, mostly because Solr is very disorganized and inconsistent in its use of them.  Though my attitude there is probably part of the problem. 
   
   Makes sense to me; forget I said anything.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on PR #1119:
URL: https://github.com/apache/solr/pull/1119#issuecomment-1670316275

   @iamsanjay are you ok with me pushing some changes to this PR's branch to get things goin again?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1302178487


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -452,6 +454,11 @@ void call() throws Exception {
     }
   }
 
+  @Override

Review Comment:
   moved api to `ReplicationHandler`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex commented on a diff in pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex commented on code in PR #1119:
URL: https://github.com/apache/solr/pull/1119#discussion_r1322003104


##########
solr/core/src/java/org/apache/solr/handler/admin/api/SnapshotBackupAPI.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.handler.ReplicationHandler.ERR_STATUS;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import java.lang.invoke.MethodHandles;
+import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.annotation.JsonProperty;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.handler.ReplicationHandler.ReplicationHandlerConfig;
+import org.apache.solr.jersey.JacksonReflectMapWriter;
+import org.apache.solr.jersey.PermissionName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** V2 endpoint for Backup API used for User-Managed clusters and Single-Node Installation. */
+@Path("/cores/{coreName}/replication/backups")
+public class SnapshotBackupAPI extends JerseyResource {

Review Comment:
   hmm. I see `snapshot` as a term used on the replication handler. maybe this would work to not overload the `backup` term?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] stillalex merged pull request #1119: [SOLR-16461] Create v2 equivalent of v1 ReplicationHandler 'BACKUP'

Posted by "stillalex (via GitHub)" <gi...@apache.org>.
stillalex merged PR #1119:
URL: https://github.com/apache/solr/pull/1119


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org