Remove schedule field from EnrichPolicy (#42143)

This commit is contained in:
Martijn van Groningen 2019-05-22 17:07:19 +02:00
parent 323251c3d1
commit 9e514cb161
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
6 changed files with 14 additions and 34 deletions

View File

@ -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<EnrichPolicy, Void> PARSER = new ConstructingObjectParser<>("policy",
@ -48,8 +47,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
(QuerySource) args[1],
(List<String>) args[2],
(String) args[3],
(List<String>) args[4],
(String) args[5]
(List<String>) 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<String> indices;
private final String enrichKey;
private final List<String> 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<String> indices,
String enrichKey,
List<String> enrichValues,
String schedule) {
List<String> 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<String>) args[3],
(String) args[4],
(List<String>) args[5],
(String) args[6])
(List<String>) args[5])
)
);

View File

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

View File

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

View File

@ -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<PolicyExecutionResult> listener = new ActionListener<PolicyExecutionResult>() {
@ -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<PolicyExecutionResult> listener = new ActionListener<PolicyExecutionResult>() {

View File

@ -61,8 +61,7 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase<EnrichPolicy>
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<EnrichPolicy>
assertThat(newInstance.getIndices(), equalTo(expectedInstance.getIndices()));
assertThat(newInstance.getEnrichKey(), equalTo(expectedInstance.getEnrichKey()));
assertThat(newInstance.getEnrichValues(), equalTo(expectedInstance.getEnrichValues()));
assertThat(newInstance.getSchedule(), equalTo(expectedInstance.getSchedule()));
}
}

View File

@ -31,7 +31,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
public void testCreateProcessorInstance() throws Exception {
List<String> 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<String, Object> config = new HashMap<>();
@ -105,7 +105,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
public void testPolicyNameMissing() {
List<String> 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<String, Object> config = new HashMap<>();
@ -137,7 +137,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
public void testUnsupportedPolicy() {
List<String> 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<String, Object> config = new HashMap<>();
@ -170,7 +170,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
public void testNonExistingDecorateField() throws Exception {
List<String> 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<String, Object> config = new HashMap<>();