Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions modules/data-streams/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
exports org.elasticsearch.datastreams.lifecycle;
exports org.elasticsearch.datastreams.lifecycle.transitions.steps to org.elasticsearch.server;
exports org.elasticsearch.datastreams.options.action to org.elasticsearch.server;
exports org.elasticsearch.datastreams;

provides org.elasticsearch.features.FeatureSpecification with org.elasticsearch.datastreams.DataStreamFeatures;
}
2 changes: 2 additions & 0 deletions x-pack/plugin/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ esplugin {
classname ='org.elasticsearch.xpack.core.XPackPlugin'
hasNativeController =false
requiresKeystore =false
extendedPlugins = ['data-streams']
}

tasks.withType(AbstractDependenciesTask).configureEach {
Expand Down Expand Up @@ -80,6 +81,7 @@ dependencies {
api "com.unboundid:unboundid-ldapsdk:${versions.ldapsdk}"

implementation project(":x-pack:plugin:core:template-resources")
compileOnly project(':modules:data-streams')

testImplementation "org.elasticsearch:mocksocket:${versions.mocksocket}"
testImplementation project(path: ':modules:reindex')
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
requires org.slf4j;
requires com.ibm.icu;
requires org.elasticsearch.exponentialhistogram;
requires org.elasticsearch.datastreams;

exports org.elasticsearch.index.engine.frozen;
exports org.elasticsearch.license;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import org.elasticsearch.cluster.metadata.ProjectMetadata;
import org.elasticsearch.cluster.metadata.RepositoriesMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.datastreams.DataStreamsPlugin;
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleService;
import org.elasticsearch.license.LicenseUtils;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.repositories.RepositoriesService;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -141,7 +143,7 @@ boolean isEligibleForConvertToFrozen() {
return false;
}

String repositoryName = resolveRepositoryName(projectState);
final String repositoryName = getRepositoryForFrozen(projectMetadata, indexName);
if (Strings.hasText(repositoryName) == false) {
logger.debug("Default repository not configured, skipping convert-to-frozen steps for index [{}]", indexName);
throw new ElasticsearchException(
Expand Down Expand Up @@ -169,10 +171,14 @@ boolean isEligibleForConvertToFrozen() {
}

/**
* Resolves the repository name to use for the snapshot and searchable snapshot steps.
* Return the repository name to use for converting this index to a searchable snapshot, or else null if it is not set.
*/
private static String resolveRepositoryName(ProjectState projectState) {
return RepositoriesService.DEFAULT_REPOSITORY_SETTING.get(projectState.cluster().metadata().settings());
@Nullable
private static String getRepositoryForFrozen(ProjectMetadata projectMetadata, String indexName) {
return Optional.ofNullable(projectMetadata.index(indexName))
.map(im -> im.getCustomData(DataStreamsPlugin.LIFECYCLE_CUSTOM_INDEX_METADATA_KEY))
.map(custom -> custom.get(DataStreamLifecycleService.FROZEN_CANDIDATE_REPOSITORY_METADATA_KEY))
.orElse(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.elasticsearch.cluster.metadata.RepositoryMetadata;
import org.elasticsearch.cluster.project.TestProjectResolvers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.datastreams.DataStreamsPlugin;
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleService;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.license.License;
Expand All @@ -42,6 +44,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.cluster.metadata.IndexMetadata.APIBlock.WRITE;
Expand Down Expand Up @@ -405,6 +408,10 @@ private ProjectState createProjectStateWithRepo(String repoName, boolean registe
.settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build())
.numberOfShards(1)
.numberOfReplicas(0)
.putCustom(
DataStreamsPlugin.LIFECYCLE_CUSTOM_INDEX_METADATA_KEY,
Map.of(DataStreamLifecycleService.FROZEN_CANDIDATE_REPOSITORY_METADATA_KEY, repoName)
)
.build(),
false
);
Expand Down
Loading