Apache Solr open-source search software
SOLR-18104: Remove deprecated constructor in SnapShooter (#4137)
Eric Pughdc31be6b0764
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.javaindex e803bdd1d6b..8b367cf8c30 100644--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java@@ -379,9 +379,37 @@ public class ReplicationHandler extends RequestHandlerBaseprivate void deleteSnapshot(ModifiableSolrParams params, SolrQueryResponse rsp) {params.required().get(NAME);+ String repoName = params.get(CoreAdminParams.BACKUP_REPOSITORY);String location = params.get(CoreAdminParams.BACKUP_LOCATION);- core.getCoreContainer().assertPathAllowed(location == null ? null : Path.of(location));- SnapShooter snapShooter = new SnapShooter(core, location, params.get(NAME));++ // commitName is not documented in ref guide for the backup option.+ // copying to here, an dit may be that both are just null?+ String commitName = params.get(CoreAdminParams.COMMIT_NAME);++ CoreContainer cc = core.getCoreContainer();+ BackupRepository repo = null;+ if (repoName != null) {+ repo = cc.newBackupRepository(repoName);+ location = repo.getBackupLocation(location);+ if (location == null) {+ throw new IllegalArgumentException("location is required");+ }+ } else {+ repo = new LocalFileSystemRepository();+ if (location == null) {+ location = core.getDataDir();+ } else {+ location =+ core.getCoreDescriptor().getInstanceDir().resolve(location).normalize().toString();+ }+ }+ if ("file".equals(repo.createURI("x").getScheme())) {+ core.getCoreContainer().assertPathAllowed(Path.of(location));+ }++ URI locationUri = repo.createDirectoryURI(location);+ SnapShooter snapShooter =+ new SnapShooter(repo, core, locationUri, params.get(NAME), commitName);snapShooter.validateDeleteSnapshot();snapShooter.deleteSnapAsync(this);rsp.add(STATUS, OK_STATUS);@@ -1505,7 +1533,11 @@ public class ReplicationHandler extends RequestHandlerBaseif (numberToKeep < 1) {numberToKeep = Integer.MAX_VALUE;}- SnapShooter snapShooter = new SnapShooter(core, null, null);++ URI locationUri = Path.of(core.getDataDir()).toUri();++ SnapShooter snapShooter =+ new SnapShooter(new LocalFileSystemRepository(), core, locationUri, null, null);snapShooter.validateCreateSnapshot();snapShooter.createSnapAsync(numberToKeep, (nl) -> snapShootDetails = nl);} catch (Exception e) {diff --git a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java b/solr/core/src/java/org/apache/solr/handler/SnapShooter.javaindex 4fe1f0c7427..b971543a70a 100644--- a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java+++ b/solr/core/src/java/org/apache/solr/handler/SnapShooter.java@@ -45,7 +45,6 @@ import org.apache.solr.core.IndexDeletionPolicyWrapper;import org.apache.solr.core.SolrCore;import org.apache.solr.core.backup.repository.BackupRepository;import org.apache.solr.core.backup.repository.BackupRepository.PathType;-import org.apache.solr.core.backup.repository.LocalFileSystemRepository;import org.apache.solr.core.snapshots.SolrSnapshotMetaDataManager;import org.apache.solr.handler.api.V2ApiUtils;import org.slf4j.Logger;@@ -67,22 +66,6 @@ public class SnapShooter {private BackupRepository backupRepo = null;private String commitName; // can be null- @Deprecated- public SnapShooter(SolrCore core, String location, String snapshotName) {- String snapDirStr = null;- // Note - This logic is only applicable to the usecase where a shared file-system is exposed via- // local file-system interface (primarily for backwards compatibility). For other use-cases,- // users will be required to specify "location" where the backup should be stored.- if (location == null) {- snapDirStr = core.getDataDir();- } else {- snapDirStr =- core.getCoreDescriptor().getInstanceDir().resolve(location).normalize().toString();- }- initialize(- new LocalFileSystemRepository(), core, Path.of(snapDirStr).toUri(), snapshotName, null);- }-public SnapShooter(BackupRepository backupRepo,SolrCore core,@@ -245,8 +228,7 @@ public class SnapShooter {+ solrCore.getName());}- public void createSnapAsync(final int numberToKeep, Consumer<NamedList<?>> result)- throws IOException {+ public void createSnapAsync(final int numberToKeep, Consumer<NamedList<?>> result) {// TODO should use Solr's ExecutorUtilnew Thread(() -> {diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/user-managed-index-replication.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/user-managed-index-replication.adocindex 353fdcf598a..ea3f0f37674 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/user-managed-index-replication.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/user-managed-index-replication.adoc@@ -518,7 +518,7 @@ The snapshot will be created in a directory called `snapshot.<name>` within theBy default the name is generated using date in `yyyyMMddHHmmssSSS` format.If the `location` parameter is passed, that would be used instead of the data directory.-`repository`::: The name of the backup repository to use+`repository`::: The name of the backup repository to use.When not specified, it defaults to local file system.`location`::: Backup location.@@ -569,6 +569,9 @@ There are two supported parameters:`name`::: The name of the snapshot.A snapshot with the name `snapshot._name_` must exist or an error will be returned.+`repository`::: The name of the backup repository to use.+ When not specified, it defaults to local file system.+`location`::: The location where the snapshot is created.