diff --git a/x-pack/docs/en/rest-api/info.asciidoc b/x-pack/docs/en/rest-api/info.asciidoc
index ccb979124f2..4faf7e85102 100644
--- a/x-pack/docs/en/rest-api/info.asciidoc
+++ b/x-pack/docs/en/rest-api/info.asciidoc
@@ -67,6 +67,11 @@ Example response:
"available" : true,
"enabled" : true
},
+ "index_lifecycle" : {
+ "description" : "Index lifecycle management for the Elastic Stack",
+ "available" : true,
+ "enabled" : true
+ }
"logstash" : {
"description" : "Logstash management component for X-Pack",
"available" : true,
diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle
index a4db1185e23..d6c99e96eb8 100644
--- a/x-pack/plugin/build.gradle
+++ b/x-pack/plugin/build.gradle
@@ -16,7 +16,7 @@ es_meta_plugin {
name = 'x-pack'
description = 'Elasticsearch Expanded Pack Plugin'
plugins = ['core', 'deprecation', 'graph', 'logstash',
- 'ml', 'monitoring', 'security', 'upgrade', 'watcher', 'sql', 'rollup']
+ 'ml', 'monitoring', 'security', 'upgrade', 'watcher', 'sql', 'rollup', 'index-lifecycle']
}
dependencies {
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
index 2e4caff1a72..33161824b25 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
@@ -535,6 +535,22 @@ public class XPackLicenseState {
return localStatus.active;
}
+ /**
+ * Determine if Index Lifecycle API should be enabled.
+ *
+ * Index Lifecycle API is available in for all license types except
+ * {@link OperationMode#MISSING}
+ *
+ * @return {@code true} as long as the license is valid. Otherwise
+ * {@code false}.
+ */
+ public boolean isIndexLifecycleAllowed() {
+ // status is volatile
+ Status localStatus = status;
+ // Should work on all active licenses
+ return localStatus.active;
+ }
+
/**
* Determine if SQL support should be enabled.
*
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
index 4853588bd3e..0446f5f1f2d 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
@@ -38,6 +38,21 @@ import org.elasticsearch.xpack.core.action.XPackUsageAction;
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
import org.elasticsearch.xpack.core.graph.GraphFeatureSetUsage;
import org.elasticsearch.xpack.core.graph.action.GraphExploreAction;
+import org.elasticsearch.xpack.core.indexlifecycle.AllocateAction;
+import org.elasticsearch.xpack.core.indexlifecycle.DeleteAction;
+import org.elasticsearch.xpack.core.indexlifecycle.ForceMergeAction;
+import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleFeatureSetUsage;
+import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
+import org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction;
+import org.elasticsearch.xpack.core.indexlifecycle.LifecycleType;
+import org.elasticsearch.xpack.core.indexlifecycle.ReadOnlyAction;
+import org.elasticsearch.xpack.core.indexlifecycle.ReplicasAction;
+import org.elasticsearch.xpack.core.indexlifecycle.RolloverAction;
+import org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction;
+import org.elasticsearch.xpack.core.indexlifecycle.TimeseriesLifecycleType;
+import org.elasticsearch.xpack.core.indexlifecycle.action.DeleteLifecycleAction;
+import org.elasticsearch.xpack.core.indexlifecycle.action.GetLifecycleAction;
+import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
import org.elasticsearch.xpack.core.logstash.LogstashFeatureSetUsage;
import org.elasticsearch.xpack.core.ml.MachineLearningFeatureSetUsage;
import org.elasticsearch.xpack.core.ml.MlMetadata;
@@ -308,7 +323,11 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
StopRollupJobAction.INSTANCE,
DeleteRollupJobAction.INSTANCE,
GetRollupJobsAction.INSTANCE,
- GetRollupCapsAction.INSTANCE
+ GetRollupCapsAction.INSTANCE,
+ // ILM
+ DeleteLifecycleAction.INSTANCE,
+ GetLifecycleAction.INSTANCE,
+ PutLifecycleAction.INSTANCE
);
}
@@ -358,7 +377,25 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
// rollup
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.ROLLUP, RollupFeatureSetUsage::new),
new NamedWriteableRegistry.Entry(PersistentTaskParams.class, RollupJob.NAME, RollupJob::new),
- new NamedWriteableRegistry.Entry(Task.Status.class, RollupJobStatus.NAME, RollupJobStatus::new)
+ new NamedWriteableRegistry.Entry(Task.Status.class, RollupJobStatus.NAME, RollupJobStatus::new),
+ // ILM
+ new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.INDEX_LIFECYCLE,
+ IndexLifecycleFeatureSetUsage::new),
+ // ILM - Custom Metadata
+ new NamedWriteableRegistry.Entry(MetaData.Custom.class, IndexLifecycleMetadata.TYPE, IndexLifecycleMetadata::new),
+ new NamedWriteableRegistry.Entry(NamedDiff.class, IndexLifecycleMetadata.TYPE,
+ IndexLifecycleMetadata.IndexLifecycleMetadataDiff::new),
+ // ILM - LifecycleTypes
+ new NamedWriteableRegistry.Entry(LifecycleType.class, TimeseriesLifecycleType.TYPE,
+ (in) -> TimeseriesLifecycleType.INSTANCE),
+ // ILM - Lifecycle Actions
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, AllocateAction.NAME, AllocateAction::new),
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, ForceMergeAction.NAME, ForceMergeAction::new),
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, ReadOnlyAction.NAME, ReadOnlyAction::new),
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, ReplicasAction.NAME, ReplicasAction::new),
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, RolloverAction.NAME, RolloverAction::new),
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, ShrinkAction.NAME, ShrinkAction::new),
+ new NamedWriteableRegistry.Entry(LifecycleAction.class, DeleteAction.NAME, DeleteAction::new)
);
}
@@ -387,7 +424,21 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
//rollup
new NamedXContentRegistry.Entry(PersistentTaskParams.class, new ParseField(RollupField.TASK_NAME),
parser -> RollupJob.fromXContent(parser)),
- new NamedXContentRegistry.Entry(Task.Status.class, new ParseField(RollupJobStatus.NAME), RollupJobStatus::fromXContent)
+ new NamedXContentRegistry.Entry(Task.Status.class, new ParseField(RollupJobStatus.NAME), RollupJobStatus::fromXContent),
+ // ILM - Custom Metadata
+ new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField(IndexLifecycleMetadata.TYPE),
+ parser -> IndexLifecycleMetadata.PARSER.parse(parser, null)),
+ // ILM - Lifecycle Types
+ new NamedXContentRegistry.Entry(LifecycleType.class, new ParseField(TimeseriesLifecycleType.TYPE),
+ (p, c) -> TimeseriesLifecycleType.INSTANCE),
+ // ILM - Lifecycle Actions
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(AllocateAction.NAME), AllocateAction::parse),
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(ForceMergeAction.NAME), ForceMergeAction::parse),
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(ReadOnlyAction.NAME), ReadOnlyAction::parse),
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(ReplicasAction.NAME), ReplicasAction::parse),
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RolloverAction.NAME), RolloverAction::parse),
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(ShrinkAction.NAME), ShrinkAction::parse),
+ new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DeleteAction.NAME), DeleteAction::parse)
);
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java
index dd482c4e22d..c7c48055757 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java
@@ -29,6 +29,8 @@ public final class XPackField {
public static final String SQL = "sql";
/** Name constant for the rollup feature. */
public static final String ROLLUP = "rollup";
+ /** Name constant for the index lifecycle feature. */
+ public static final String INDEX_LIFECYCLE = "index_lifecycle";
private XPackField() {}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java
index a88d423be95..ae3cf732d44 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java
@@ -60,6 +60,12 @@ public class XPackSettings {
public static final Setting LOGSTASH_ENABLED = Setting.boolSetting("xpack.logstash.enabled", true,
Setting.Property.NodeScope);
+ /**
+ * Setting for enabling or disabling the index lifecycle extension. Defaults to true.
+ */
+ public static final Setting INDEX_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.index_lifecycle.enabled", true,
+ Setting.Property.NodeScope);
+
/** Setting for enabling or disabling TLS. Defaults to false. */
public static final Setting TRANSPORT_SSL_ENABLED = Setting.boolSetting("xpack.security.transport.ssl.enabled", false,
Property.NodeScope);
@@ -149,6 +155,7 @@ public class XPackSettings {
settings.add(SQL_ENABLED);
settings.add(USER_SETTING);
settings.add(ROLLUP_ENABLED);
+ settings.add(INDEX_LIFECYCLE_ENABLED);
return Collections.unmodifiableList(settings);
}
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIndexTestHelper.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIndexTestHelper.java
new file mode 100644
index 00000000000..abe069137a3
--- /dev/null
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIndexTestHelper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ *
+ */
+package org.elasticsearch.action.admin.indices.rollover;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public final class RolloverIndexTestHelper {
+
+ // NORELEASE this isn't nice but it's currently the only way to inspect the
+ // settings in an update settings request. Need to see if we can make the
+ // getter public in ES
+ public static void assertRolloverIndexRequest(RolloverRequest request, String alias, Set> expectedConditions) {
+ assertNotNull(request);
+ assertEquals(1, request.indices().length);
+ assertEquals(alias, request.indices()[0]);
+ assertEquals(alias, request.getAlias());
+ assertEquals(expectedConditions.size(), request.getConditions().size());
+ Set