[ https://issues.apache.org/jira/browse/SOLR-16461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17618184#comment-17618184 ]
Sanjay commented on SOLR-16461: ------------------------------- BackupAPI Class Code. Also I am not sure yet whether we can inject ReplicationHandler directly into the constructor not(I guess we cannot). I have seen AddReplicaPropertyAPI injecting CoreContainer which has access to CollectionHandler and CoreAdminHandler but not to ReplicationHandler. Though I have tried only with SolrQueryRequest and SolrQueryResponse but it's still throwing error. {code:java} 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.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.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; 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/{core}/replication/") public class BackupAPI extends JerseyResource { private final ReplicationHandler replicationHandler; private final SolrQueryRequest solrQueryRequest; private final SolrQueryResponse solrQueryResponse; @Inject public BackupAPI( ReplicationHandler replicationHandler, SolrQueryRequest solrQueryRequest, SolrQueryResponse solrQueryResponse) { this.replicationHandler = replicationHandler; this.solrQueryRequest = solrQueryRequest; this.solrQueryResponse = solrQueryResponse; } @GET public SolrJerseyResponse demo() { final SolrJerseyResponse response = instantiateJerseyResponse(SolrJerseyResponse.class); System.out.println("I am not sure If this gets printed!!"); return response; } /** * This API (POST /api/cores/coreName/replication/backups {...}) is analogous to the v1 * /solr/coreName/replication?command=backup */ @Path("backups") @POST @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; } /** */ public static class BackupReplicationPayload implements JacksonReflectMapWriter { @Schema(description = "The path where the backup will be created") @JsonProperty public String location; @Schema(description = "The backup will be created in a directory called snapshot.<name>") @JsonProperty public String name; @Schema(description = "The number of backups to keep.") @JsonProperty public String numberToKeep; @Schema(description = "The name of the repository to be used for e backup.") @JsonProperty public String repository; @Schema( description = "The name of the commit which was used while taking a snapshot using the CREATESNAPSHOT command.") @JsonProperty public String commitName; } } {code} > Create v2 equivalent of v1 'BACKUP' (A backup API for user managed cluster or > single node installation) > ------------------------------------------------------------------------------------------------------- > > Key: SOLR-16461 > URL: https://issues.apache.org/jira/browse/SOLR-16461 > Project: Solr > Issue Type: Sub-task > Components: v2 API > Affects Versions: 9.1 > Reporter: Sanjay > Priority: Major > Labels: V2 > > 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'. > > > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org