From 9e514cb16120128b4be7e1213817af87052445f9 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 22 May 2019 17:07:19 +0200 Subject: [PATCH] Remove schedule field from EnrichPolicy (#42143) --- .../xpack/core/enrich/EnrichPolicy.java | 28 ++++--------------- .../elasticsearch/xpack/enrich/EnrichIT.java | 2 +- .../rest-api-spec/test/enrich/10_basic.yml | 2 -- .../xpack/enrich/EnrichPolicyRunnerTests.java | 4 +-- .../xpack/enrich/EnrichPolicyTests.java | 4 +-- .../enrich/EnrichProcessorFactoryTests.java | 8 +++--- 6 files changed, 14 insertions(+), 34 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichPolicy.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichPolicy.java index a5b8bf77728..fb3a7a0b338 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichPolicy.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichPolicy.java @@ -39,7 +39,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { private static final ParseField INDICES = new ParseField("indices"); private static final ParseField ENRICH_KEY = new ParseField("enrich_key"); private static final ParseField ENRICH_VALUES = new ParseField("enrich_values"); - private static final ParseField SCHEDULE = new ParseField("schedule"); @SuppressWarnings("unchecked") private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("policy", @@ -48,8 +47,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { (QuerySource) args[1], (List) args[2], (String) args[3], - (List) args[4], - (String) args[5] + (List) args[4] ) ); @@ -67,7 +65,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { parser.declareStringArray(ConstructingObjectParser.constructorArg(), INDICES); parser.declareString(ConstructingObjectParser.constructorArg(), ENRICH_KEY); parser.declareStringArray(ConstructingObjectParser.constructorArg(), ENRICH_VALUES); - parser.declareString(ConstructingObjectParser.constructorArg(), SCHEDULE); } public static EnrichPolicy fromXContent(XContentParser parser) throws IOException { @@ -79,7 +76,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { private final List indices; private final String enrichKey; private final List enrichValues; - private final String schedule; public EnrichPolicy(StreamInput in) throws IOException { this( @@ -87,8 +83,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { in.readOptionalWriteable(QuerySource::new), in.readStringList(), in.readString(), - in.readStringList(), - in.readString() + in.readStringList() ); } @@ -96,11 +91,9 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { QuerySource query, List indices, String enrichKey, - List enrichValues, - String schedule) { + List enrichValues) { this.type = type; this.query= query; - this.schedule = schedule; this.indices = indices; this.enrichKey = enrichKey; this.enrichValues = enrichValues; @@ -126,10 +119,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { return enrichValues; } - public String getSchedule() { - return schedule; - } - public static String getBaseName(String policyName) { return ENRICH_INDEX_NAME_BASE + policyName; } @@ -141,7 +130,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { out.writeStringCollection(indices); out.writeString(enrichKey); out.writeStringCollection(enrichValues); - out.writeString(schedule); } @Override @@ -153,7 +141,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { builder.array(INDICES.getPreferredName(), indices.toArray(new String[0])); builder.field(ENRICH_KEY.getPreferredName(), enrichKey); builder.array(ENRICH_VALUES.getPreferredName(), enrichValues.toArray(new String[0])); - builder.field(SCHEDULE.getPreferredName(), schedule); return builder; } @@ -166,8 +153,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { Objects.equals(query, policy.query) && indices.equals(policy.indices) && enrichKey.equals(policy.enrichKey) && - enrichValues.equals(policy.enrichValues) && - schedule.equals(policy.schedule); + enrichValues.equals(policy.enrichValues); } @Override @@ -177,8 +163,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { query, indices, enrichKey, - enrichValues, - schedule + enrichValues ); } @@ -244,8 +229,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment { (QuerySource) args[2], (List) args[3], (String) args[4], - (List) args[5], - (String) args[6]) + (List) args[5]) ) ); diff --git a/x-pack/plugin/enrich/qa/rest/src/test/java/org/elasticsearch/xpack/enrich/EnrichIT.java b/x-pack/plugin/enrich/qa/rest/src/test/java/org/elasticsearch/xpack/enrich/EnrichIT.java index 5477e5c4f5e..432a3719395 100644 --- a/x-pack/plugin/enrich/qa/rest/src/test/java/org/elasticsearch/xpack/enrich/EnrichIT.java +++ b/x-pack/plugin/enrich/qa/rest/src/test/java/org/elasticsearch/xpack/enrich/EnrichIT.java @@ -43,7 +43,7 @@ public class EnrichIT extends ESRestTestCase { // Create the policy: Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy"); putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-index*\"], \"enrich_key\": \"host\", " + - "\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"], \"schedule\": \"0 5 * * *\"}"); + "\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"]}"); assertOK(client().performRequest(putPolicyRequest)); // create index (remove when execute policy api has been added) diff --git a/x-pack/plugin/enrich/qa/rest/src/test/resources/rest-api-spec/test/enrich/10_basic.yml b/x-pack/plugin/enrich/qa/rest/src/test/resources/rest-api-spec/test/enrich/10_basic.yml index 48036ea05b7..23ce787301b 100644 --- a/x-pack/plugin/enrich/qa/rest/src/test/resources/rest-api-spec/test/enrich/10_basic.yml +++ b/x-pack/plugin/enrich/qa/rest/src/test/resources/rest-api-spec/test/enrich/10_basic.yml @@ -9,7 +9,6 @@ indices: ["bar*"] enrich_key: baz enrich_values: ["a", "b"] - schedule: "*/120" - is_true: acknowledged - do: @@ -20,7 +19,6 @@ - match: { policies.0.indices: ["bar*"] } - match: { policies.0.enrich_key: baz } - match: { policies.0.enrich_values: ["a", "b"] } - - match: { policies.0.schedule: "*/120" } - do: enrich.delete_policy: diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index ca7517efc21..cdeae1b10e1 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -88,7 +88,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { enrichFields.add("field2"); enrichFields.add("field5"); EnrichPolicy policy = - new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndex), "field1", enrichFields, ""); + new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndex), "field1", enrichFields); String policyName = "test1"; ActionListener listener = new ActionListener() { @@ -204,7 +204,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { enrichFields.add("field2"); enrichFields.add("field5"); EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndexPattern), - "field1", enrichFields, ""); + "field1", enrichFields); String policyName = "test1"; ActionListener listener = new ActionListener() { diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyTests.java index 1e48330e849..b4810045065 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyTests.java @@ -61,8 +61,7 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase randomBoolean() ? querySource : null, Arrays.asList(generateRandomStringArray(8, 4, false, false)), randomAlphaOfLength(4), - Arrays.asList(generateRandomStringArray(8, 4, false, false)), - randomAlphaOfLength(4) + Arrays.asList(generateRandomStringArray(8, 4, false, false)) ); } catch (IOException e) { throw new UncheckedIOException(e); @@ -92,6 +91,5 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase assertThat(newInstance.getIndices(), equalTo(expectedInstance.getIndices())); assertThat(newInstance.getEnrichKey(), equalTo(expectedInstance.getEnrichKey())); assertThat(newInstance.getEnrichValues(), equalTo(expectedInstance.getEnrichValues())); - assertThat(newInstance.getSchedule(), equalTo(expectedInstance.getSchedule())); } } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichProcessorFactoryTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichProcessorFactoryTests.java index 1d6228ed602..803a7a8526c 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichProcessorFactoryTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichProcessorFactoryTests.java @@ -31,7 +31,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase { public void testCreateProcessorInstance() throws Exception { List enrichValues = Arrays.asList("globalRank", "tldRank", "tld"); EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key", - enrichValues, "schedule"); + enrichValues); EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null); Map config = new HashMap<>(); @@ -105,7 +105,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase { public void testPolicyNameMissing() { List enrichValues = Arrays.asList("globalRank", "tldRank", "tld"); EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key", - enrichValues, "schedule"); + enrichValues); EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("_name", policy), null); Map config = new HashMap<>(); @@ -137,7 +137,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase { public void testUnsupportedPolicy() { List enrichValues = Arrays.asList("globalRank", "tldRank", "tld"); EnrichPolicy policy = - new EnrichPolicy("unsupported", null, Collections.singletonList("source_index"), "my_key", enrichValues, "schedule"); + new EnrichPolicy("unsupported", null, Collections.singletonList("source_index"), "my_key", enrichValues); EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null); Map config = new HashMap<>(); @@ -170,7 +170,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase { public void testNonExistingDecorateField() throws Exception { List enrichValues = Arrays.asList("globalRank", "tldRank", "tld"); EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key", - enrichValues, "schedule"); + enrichValues); EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null); Map config = new HashMap<>();