Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ public static NodeConfig fromConfig(
configBuilder.setBackupRepositoryPlugins(
getBackupRepositoryPluginInfos(root.get("backup").getAll("repository")));
configBuilder.setClusterPlugins(getClusterPlugins(loader, root));
// <metrics><hiddenSysProps></metrics> will be removed in Solr 10, but until then, use it if a
// <hiddenSysProps> is not provided under <solr>.
// Remove this line in 10.0
configBuilder.setHiddenSysProps(getHiddenSysProps(root.get("metrics")));
configBuilder.setMetricsConfig(getMetricsConfig(root.get("metrics")));
configBuilder.setCachesConfig(getCachesConfig(loader, root.get("caches")));
configBuilder.setDefaultZkHost(defaultZkHost);
Expand Down Expand Up @@ -747,26 +743,6 @@ private static Object decodeNullValue(Object o) {
return o;
}

/**
* Deprecated as of 9.3, will be removed in 10.0
*
* @param metrics configNode for the metrics
* @return a comma-separated list of hidden Sys Props
*/
@Deprecated(forRemoval = true, since = "9.3")
private static String getHiddenSysProps(ConfigNode metrics) {
ConfigNode p = metrics.get("hiddenSysProps");
if (!p.exists()) return null;
Set<String> props = new HashSet<>();
p.forEachChild(
it -> {
if (it.name().equals("str") && StrUtils.isNotNullOrEmpty(it.txt()))
props.add(Pattern.quote(it.txt()));
return Boolean.TRUE;
});
return String.join(",", props);
}

private static PluginInfo getPluginInfo(ConfigNode cfg) {
if (cfg == null || !cfg.exists()) return null;
final var pluginInfo = new PluginInfo(cfg, cfg.name(), false, true);
Expand Down
38 changes: 35 additions & 3 deletions solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,37 @@ public boolean abortFetch() {
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);
Expand Down Expand Up @@ -1505,7 +1533,11 @@ public void postCommit() {
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) {
Expand Down
20 changes: 1 addition & 19 deletions solr/core/src/java/org/apache/solr/handler/SnapShooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
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;
Expand All @@ -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,
Expand Down Expand Up @@ -245,8 +228,7 @@ public static IndexCommit getAndSaveNamedIndexCommit(SolrCore solrCore, String c
+ 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(
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.


Expand Down
Loading