Applying changes required for ILM after merge

This commit is contained in:
Tal Levy 2018-04-25 12:23:21 -07:00
parent d74fb9eb45
commit 1df6b6c65d
25 changed files with 184 additions and 20 deletions

View File

@ -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,

View File

@ -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 {

View File

@ -535,6 +535,22 @@ public class XPackLicenseState {
return localStatus.active;
}
/**
* Determine if Index Lifecycle API should be enabled.
* <p>
* 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.
* <p>

View File

@ -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)
);
}

View File

@ -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() {}

View File

@ -60,6 +60,12 @@ public class XPackSettings {
public static final Setting<Boolean> 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<Boolean> 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<Boolean> 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);
}

View File

@ -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<Condition<?>> expectedConditions) {
assertNotNull(request);
assertEquals(1, request.indices().length);
assertEquals(alias, request.indices()[0]);
assertEquals(alias, request.getAlias());
assertEquals(expectedConditions.size(), request.getConditions().size());
Set<Object> expectedConditionValues = expectedConditions.stream().map(condition -> condition.value).collect(Collectors.toSet());
Set<Object> actualConditionValues = request.getConditions().values().stream()
.map(condition -> condition.value).collect(Collectors.toSet());
assertEquals(expectedConditionValues, actualConditionValues);
}
// NORELEASE this isn't nice but it's currently the only way to create an
// UpdateSettingsResponse. Need to see if we can make the constructor public
// in ES
public static RolloverResponse createMockResponse(RolloverRequest request, boolean rolledOver) {
return new RolloverResponse(null, null, Collections.emptyMap(), request.isDryRun(), rolledOver, true, true);
}
}

View File

@ -0,0 +1,32 @@
/*
* 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.settings.put;
import org.elasticsearch.common.settings.Settings;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public final class UpdateSettingsTestHelper {
// 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 assertSettingsRequest(UpdateSettingsRequest request, Settings expectedSettings, String... expectedIndices) {
assertNotNull(request);
assertArrayEquals(expectedIndices, request.indices());
assertEquals(expectedSettings, request.settings());
}
// NORELEASE this isn't nice but it's currently the only way to create an
// UpdateSettingsResponse. Need to see if we can make the constructor public
// in ES
public static UpdateSettingsResponse createMockResponse(boolean acknowledged) {
return new UpdateSettingsResponse(acknowledged);
}
}

View File

@ -1,13 +1,13 @@
evaluationDependsOn(xpackModule('core'))
apply plugin: 'elasticsearch.esplugin'
esplugin {
name 'x-pack-index-lifecycle'
description 'Elasticsearch Expanded Pack Plugin - Index Lifecycle'
classname 'org.elasticsearch.xpack.indexlifecycle.IndexLifecycle'
extendedPlugins = ['x-pack-core']
hasNativeController false
requiresKeystore true
extendedPlugins = ['x-pack-core']
licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt')
noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt')
}
archivesBaseName = 'x-pack-index-lifecycle'
@ -21,10 +21,6 @@ dependencies {
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
}
dependencyLicenses {
ignoreSha 'x-pack-core'
}
run {
plugin ':x-pack-elasticsearch:plugin:core'
plugin xpackModule('core')
}

View File

@ -13,11 +13,12 @@
- match: { nodes.$master.modules.13.name: x-pack-core }
- match: { nodes.$master.modules.14.name: x-pack-deprecation }
- match: { nodes.$master.modules.15.name: x-pack-graph }
- match: { nodes.$master.modules.16.name: x-pack-logstash }
- match: { nodes.$master.modules.17.name: x-pack-ml }
- match: { nodes.$master.modules.18.name: x-pack-monitoring }
- match: { nodes.$master.modules.19.name: x-pack-rollup }
- match: { nodes.$master.modules.20.name: x-pack-security }
- match: { nodes.$master.modules.21.name: x-pack-sql }
- match: { nodes.$master.modules.22.name: x-pack-upgrade }
- match: { nodes.$master.modules.23.name: x-pack-watcher }
- match: { nodes.$master.plugins.16.name: x-pack-index-lifecycle }
- match: { nodes.$master.modules.17.name: x-pack-logstash }
- match: { nodes.$master.modules.18.name: x-pack-ml }
- match: { nodes.$master.modules.19.name: x-pack-monitoring }
- match: { nodes.$master.modules.20.name: x-pack-rollup }
- match: { nodes.$master.modules.21.name: x-pack-security }
- match: { nodes.$master.modules.22.name: x-pack-sql }
- match: { nodes.$master.modules.23.name: x-pack-upgrade }
- match: { nodes.$master.modules.24.name: x-pack-watcher }

View File

@ -17,6 +17,7 @@ project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps)
integTestCluster {
distribution 'zip'
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.security.enabled', 'true'

View File

@ -22,6 +22,7 @@ integTestRunner {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'

View File

@ -7,6 +7,7 @@ dependencies {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'

View File

@ -7,6 +7,7 @@ dependencies {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
numNodes = 1

View File

@ -51,6 +51,7 @@ processTestResources.dependsOn(createNodeKeyStore)
integTestCluster {
dependsOn createNodeKeyStore
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.ml.enabled', 'true'
setting 'logger.org.elasticsearch.xpack.ml.datafeed', 'TRACE'

View File

@ -7,6 +7,7 @@ dependencies {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
}

View File

@ -15,6 +15,7 @@ remoteClusterTestCluster {
numNodes = 2
clusterName = 'remote-cluster'
setting 'search.remote.connect', false
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'

View File

@ -8,6 +8,7 @@ dependencies {
integTestCluster {
numNodes = 2
clusterName = 'multi-node'
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'

View File

@ -11,6 +11,7 @@ dependencies {
integTestCluster {
// Whitelist reindexing from the local node so we can test it.
setting 'reindex.remote.whitelist', '127.0.0.1:*'
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'

View File

@ -19,6 +19,7 @@ integTestRunner {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'

View File

@ -27,6 +27,7 @@ integTestCluster {
setting 'xpack.security.authc.realms.native.type', 'native'
setting 'xpack.security.authc.realms.native.order', '2'
setting 'xpack.security.enabled', 'true'
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'

View File

@ -8,6 +8,7 @@ dependencies {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.monitoring.enabled', 'true'
setting 'xpack.watcher.enabled', 'true'
setting 'xpack.security.enabled', 'false'

View File

@ -176,6 +176,7 @@ integTestCluster {
setting 'xpack.monitoring.exporters._http.auth.password', 'x-pack-test-password'
setting 'xpack.monitoring.exporters._http.ssl.verification_mode', 'full'
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.security.http.ssl.enabled', 'true'
setting 'xpack.security.http.ssl.keystore.path', nodeKeystore.name

View File

@ -14,6 +14,7 @@ task copyWatcherRestTests(type: Copy) {
integTestCluster {
dependsOn copyWatcherRestTests
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.security.enabled', 'true'

View File

@ -12,6 +12,7 @@ dependencies {
}
integTestCluster {
setting 'xpack.index_lifecycle.enabled', 'false'
setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false'