This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new dc31be6b076 SOLR-18104: Remove deprecated constructor in SnapShooter
(#4137)
dc31be6b076 is described below
commit dc31be6b07643c6f5f61f7999b85533887509415
Author: Eric Pugh <[email protected]>
AuthorDate: Thu Feb 26 07:42:17 2026 -0500
SOLR-18104: Remove deprecated constructor in SnapShooter (#4137)
---
.../apache/solr/handler/ReplicationHandler.java | 38 ++++++++++++++++++++--
.../java/org/apache/solr/handler/SnapShooter.java | 20 +-----------
.../pages/user-managed-index-replication.adoc | 5 ++-
3 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index 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 RequestHandlerBase
private 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
RequestHandlerBase
if (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.java
index 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 ExecutorUtil
new 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.adoc
index 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 the
By 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.