Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void cleanup() {

public void testRolloverLifecycle() throws Exception {
// empty lifecycle contains the default rollover
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;

putComposableIndexTemplate("id1", null, List.of("metrics-foo*"), null, null, lifecycle, false);
String dataStreamName = "metrics-foo";
Expand Down Expand Up @@ -353,7 +353,7 @@ public void testOriginationDate() throws Exception {
}

public void testUpdatingLifecycleAppliesToAllBackingIndices() throws Exception {
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;

putComposableIndexTemplate("id1", null, List.of("metrics-foo*"), null, null, lifecycle, false);

Expand Down Expand Up @@ -384,7 +384,7 @@ public void testAutomaticForceMerge() throws Exception {
* because all necessary merging has already happened automatically. So in order to detect whether forcemerge has been called, we
* use a SendRequestBehavior in the MockTransportService to detect it.
*/
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;
disableDataStreamLifecycle();
String dataStreamName = "metrics-foo";
putComposableIndexTemplate(
Expand Down Expand Up @@ -477,7 +477,7 @@ private static void disableDataStreamLifecycle() {

public void testErrorRecordingOnRollover() throws Exception {
// empty lifecycle contains the default rollover
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;
/*
* We set index.auto_expand_replicas to 0-1 so that if we get a single-node cluster it is not yellow. The cluster being yellow
* could result in data stream lifecycle's automatic forcemerge failing, which would result in an unexpected error in the error
Expand Down Expand Up @@ -613,7 +613,7 @@ public void testErrorRecordingOnRollover() throws Exception {
public void testErrorRecordingOnRetention() throws Exception {
// starting with a lifecycle without retention so we can rollover the data stream and manipulate the second generation index such
// that its retention execution fails
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;

/*
* We set index.auto_expand_replicas to 0-1 so that if we get a single-node cluster it is not yellow. The cluster being yellow
Expand Down Expand Up @@ -750,7 +750,7 @@ public void testErrorRecordingOnRetention() throws Exception {
}

public void testDataLifecycleServiceConfiguresTheMergePolicy() throws Exception {
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;

putComposableIndexTemplate(
"id1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void cleanup() {

public void testExplainLifecycle() throws Exception {
// empty lifecycle contains the default rollover
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;

putComposableIndexTemplate("id1", null, List.of("metrics-foo*"), null, null, lifecycle);
String dataStreamName = "metrics-foo";
Expand Down Expand Up @@ -264,7 +264,7 @@ public void testExplainFailuresLifecycle() throws Exception {
List.of("metrics-foo*"),
null,
null,
DataStreamLifecycle.Template.DEFAULT,
DataStreamLifecycle.Template.DATA_DEFAULT,
new DataStreamOptions.Template(new DataStreamFailureStore.Template(true))
);
String dataStreamName = "metrics-foo";
Expand Down Expand Up @@ -381,7 +381,7 @@ public void testExplainFailuresLifecycle() throws Exception {

public void testExplainLifecycleForIndicesWithErrors() throws Exception {
// empty lifecycle contains the default rollover
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;

putComposableIndexTemplate(
"id1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void testLifecycleComposition() {
// Enabled is always true unless it's explicitly set to false
{
DataStreamLifecycle.Template lifecycle = new DataStreamLifecycle.Template(false, randomPositiveTimeValue(), randomRounds());
List<DataStreamLifecycle.Template> lifecycles = List.of(lifecycle, DataStreamLifecycle.Template.DEFAULT);
List<DataStreamLifecycle.Template> lifecycles = List.of(lifecycle, DataStreamLifecycle.Template.DATA_DEFAULT);
DataStreamLifecycle result = composeDataLifecycles(lifecycles).build();
assertThat(result.enabled(), equalTo(true));
assertThat(result.dataRetention(), equalTo(lifecycle.dataRetention().get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testResponseIlmAndDataStreamLifecycleRepresentation() throws Excepti
.setGeneration(3)
.setAllowCustomRouting(true)
.setIndexMode(IndexMode.STANDARD)
.setLifecycle(new DataStreamLifecycle())
.setLifecycle(DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE)
.setDataStreamOptions(DataStreamOptions.FAILURE_STORE_ENABLED)
.setFailureIndices(DataStream.DataStreamIndices.failureIndicesBuilder(failureStores).build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void testRetentionNotConfigured() {
dataStreamName,
numBackingIndices,
settings(IndexVersion.current()),
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
now
);
builder.put(dataStream);
Expand Down Expand Up @@ -496,7 +496,7 @@ public void testDeletedIndicesAreRemovedFromTheErrorStore() throws IOException {
dataStreamName,
numBackingIndices,
Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()),
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
now
);
builder.put(dataStream);
Expand Down Expand Up @@ -1482,7 +1482,7 @@ public void testTargetIndices() {
numBackingIndices,
numFailureIndices,
settings(IndexVersion.current()),
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
now
).copy().setDataStreamOptions(dataStreamOptions).build(); // failure store is managed even when disabled
builder.put(dataStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public static Template resolveTemplate(
DataStreamLifecycle.Builder lifecycleBuilder = resolveLifecycle(simulatedProject, matchingTemplate);
DataStreamLifecycle.Template lifecycle = lifecycleBuilder == null ? null : lifecycleBuilder.buildTemplate();
if (template.getDataStreamTemplate() != null && lifecycle == null && isDslOnlyMode) {
lifecycle = DataStreamLifecycle.Template.DEFAULT;
lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;
}
DataStreamOptions.Builder optionsBuilder = resolveDataStreamOptions(simulatedProject, matchingTemplate);
return new Template(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static boolean isDataStreamsLifecycleOnlyMode(final Settings settings) {
Setting.Property.NodeScope
);

public static final DataStreamLifecycle DEFAULT = new DataStreamLifecycle();
public static final DataStreamLifecycle DEFAULT_DATA_LIFECYCLE = new DataStreamLifecycle(null, null, null);

public static final String DATA_STREAM_LIFECYCLE_ORIGIN = "data_stream_lifecycle";

Expand Down Expand Up @@ -132,10 +132,6 @@ public static boolean isDataStreamsLifecycleOnlyMode(final Settings settings) {
@Nullable
private final List<DownsamplingRound> downsampling;

public DataStreamLifecycle() {
this(null, null, null);
}

public DataStreamLifecycle(
@Nullable Boolean enabled,
@Nullable TimeValue dataRetention,
Expand Down Expand Up @@ -566,7 +562,7 @@ public Template(boolean enabled, TimeValue dataRetention, List<DataStreamLifecyc
}
}

public static final DataStreamLifecycle.Template DEFAULT = new DataStreamLifecycle.Template(
public static final DataStreamLifecycle.Template DATA_DEFAULT = new DataStreamLifecycle.Template(
true,
ResettableValue.undefined(),
ResettableValue.undefined()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static ClusterState createDataStream(
System::currentTimeMillis,
template.getDataStreamTemplate().isAllowCustomRouting(),
indexMode,
lifecycle == null && isDslOnlyMode ? DataStreamLifecycle.DEFAULT : lifecycle,
lifecycle == null && isDslOnlyMode ? DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE : lifecycle,
dataStreamOptions,
new DataStream.DataStreamIndices(DataStream.BACKING_INDEX_PREFIX, dsBackingIndices, false, null),
// If the failure store shouldn't be initialized on data stream creation, we're marking it for "lazy rollover", which will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testXContentSerializationWithRolloverAndEffectiveRetention() throws
Settings settings = null;
CompressedXContent mappings = null;
Map<String, AliasMetadata> aliases = null;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;
ResettableValue<DataStreamOptions.Template> dataStreamOptions = ResettableValue.undefined();
if (randomBoolean()) {
settings = randomSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() {
@SuppressWarnings("unchecked")
public void testToXContent() throws IOException {
long now = System.currentTimeMillis();
DataStreamLifecycle lifecycle = new DataStreamLifecycle();
DataStreamLifecycle lifecycle = DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE;
ExplainIndexDataStreamLifecycle explainIndex = createRandomIndexDataStreamLifecycleExplanation(now, lifecycle);
explainIndex.setNowSupplier(() -> now);
{
Expand Down Expand Up @@ -241,7 +241,7 @@ public void testToXContent() throws IOException {

public void testChunkCount() {
long now = System.currentTimeMillis();
DataStreamLifecycle lifecycle = new DataStreamLifecycle();
DataStreamLifecycle lifecycle = DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE;
Response response = new Response(
List.of(
createRandomIndexDataStreamLifecycleExplanation(now, lifecycle),
Expand Down Expand Up @@ -298,7 +298,12 @@ protected Response mutateInstance(Response instance) {

private Response randomResponse() {
return new Response(
List.of(createRandomIndexDataStreamLifecycleExplanation(System.nanoTime(), randomBoolean() ? new DataStreamLifecycle() : null)),
List.of(
createRandomIndexDataStreamLifecycleExplanation(
System.nanoTime(),
randomBoolean() ? DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE : null
)
),
randomBoolean()
? new RolloverConfiguration(
new RolloverConditions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testGetGenerationTime() {
now,
randomBoolean() ? now + TimeValue.timeValueDays(1).getMillis() : null,
null,
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
randomBoolean()
? new ErrorEntry(
System.currentTimeMillis(),
Expand All @@ -59,7 +59,7 @@ public void testGetGenerationTime() {
now,
randomBoolean() ? now + TimeValue.timeValueDays(1).getMillis() : null,
TimeValue.timeValueMillis(now + 100),
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
randomBoolean()
? new ErrorEntry(
System.currentTimeMillis(),
Expand Down Expand Up @@ -95,7 +95,7 @@ public void testGetGenerationTime() {
now,
now + 80L, // rolled over in the future (clocks are funny that way)
TimeValue.timeValueMillis(now + 100L),
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
null
);
assertThat(indexDataStreamLifecycle.getGenerationTime(() -> now), is(TimeValue.ZERO));
Expand All @@ -107,7 +107,7 @@ public void testGetTimeSinceIndexCreation() {
{
ExplainIndexDataStreamLifecycle randomIndexDataStreamLifecycleExplanation = createManagedIndexDataStreamLifecycleExplanation(
now,
new DataStreamLifecycle()
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE
);
assertThat(
randomIndexDataStreamLifecycleExplanation.getTimeSinceIndexCreation(() -> now + 75L),
Expand Down Expand Up @@ -138,7 +138,7 @@ public void testGetTimeSinceIndexCreation() {
now + 80L, // created in the future (clocks are funny that way)
null,
null,
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
null
);
assertThat(indexDataStreamLifecycle.getTimeSinceIndexCreation(() -> now), is(TimeValue.ZERO));
Expand All @@ -150,7 +150,7 @@ public void testGetTimeSinceRollover() {
{
ExplainIndexDataStreamLifecycle randomIndexDataStreamLifecycleExplanation = createManagedIndexDataStreamLifecycleExplanation(
now,
new DataStreamLifecycle()
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE
);
if (randomIndexDataStreamLifecycleExplanation.getRolloverDate() == null) {
// age calculated since creation date
Expand Down Expand Up @@ -188,7 +188,7 @@ public void testGetTimeSinceRollover() {
now - 50L,
now + 100L, // rolled over in the future
TimeValue.timeValueMillis(now),
new DataStreamLifecycle(),
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
null
);
assertThat(indexDataStreamLifecycle.getTimeSinceRollover(() -> now), is(TimeValue.ZERO));
Expand Down Expand Up @@ -254,12 +254,18 @@ protected Writeable.Reader<ExplainIndexDataStreamLifecycle> instanceReader() {

@Override
protected ExplainIndexDataStreamLifecycle createTestInstance() {
return createManagedIndexDataStreamLifecycleExplanation(System.nanoTime(), randomBoolean() ? new DataStreamLifecycle() : null);
return createManagedIndexDataStreamLifecycleExplanation(
System.nanoTime(),
randomBoolean() ? DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE : null
);
}

@Override
protected ExplainIndexDataStreamLifecycle mutateInstance(ExplainIndexDataStreamLifecycle instance) throws IOException {
return createManagedIndexDataStreamLifecycleExplanation(System.nanoTime(), randomBoolean() ? new DataStreamLifecycle() : null);
return createManagedIndexDataStreamLifecycleExplanation(
System.nanoTime(),
randomBoolean() ? DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE : null
);
}

private static ExplainIndexDataStreamLifecycle createManagedIndexDataStreamLifecycleExplanation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GetDataStreamLifecycleActionTests extends ESTestCase {
public void testDefaultLifecycleResponseToXContent() throws Exception {
boolean isInternalDataStream = randomBoolean();
GetDataStreamLifecycleAction.Response.DataStreamLifecycle dataStreamLifecycle = createDataStreamLifecycle(
DataStreamLifecycle.DEFAULT,
DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE,
isInternalDataStream
);
GetDataStreamLifecycleAction.Response response = new GetDataStreamLifecycleAction.Response(List.of(dataStreamLifecycle));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public void testXContentSerializationWithRolloverAndEffectiveRetention() throws
if (randomBoolean()) {
dataStreamOptions = randomDataStreamOptionsTemplate();
}
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;
ComponentTemplate template = new ComponentTemplate(
new Template(settings, mappings, aliases, lifecycle, dataStreamOptions),
randomNonNegativeLong(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void testXContentSerializationWithRolloverAndEffectiveRetention() throws
dataStreamOptions = ComponentTemplateTests.randomDataStreamOptionsTemplate();
}
// We use the empty lifecycle so the global retention can be in effect
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DEFAULT;
DataStreamLifecycle.Template lifecycle = DataStreamLifecycle.Template.DATA_DEFAULT;
Template template = new Template(settings, mappings, aliases, lifecycle, dataStreamOptions);
ComposableIndexTemplate.builder()
.indexPatterns(List.of(randomAlphaOfLength(4)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testXContentDeSerializationWithNullValues() throws IOException {
var parsed = DataStreamLifecycle.fromXContent(parser);
assertEquals(XContentParser.Token.END_OBJECT, parser.currentToken());
assertNull(parser.nextToken());
assertThat(parsed, equalTo(DataStreamLifecycle.DEFAULT));
assertThat(parsed, equalTo(DataStreamLifecycle.DEFAULT_DATA_LIFECYCLE));
}
}

Expand Down
Loading