Skip to content

Move the policy class to xpack core module. #41311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2019
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 @@ -3,7 +3,7 @@
* 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.xpack.enrich;
package org.elasticsearch.xpack.core.enrich;

import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
Expand All @@ -15,6 +15,7 @@
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;
Expand All @@ -28,7 +29,7 @@
public final class EnrichPolicy implements Writeable, ToXContentFragment {

static final String EXACT_MATCH_TYPE = "exact_match";
static final String[] SUPPORTED_POLICY_TYPES = new String[]{EXACT_MATCH_TYPE};
public static final String[] SUPPORTED_POLICY_TYPES = new String[]{EXACT_MATCH_TYPE};

static final ParseField TYPE = new ParseField("type");
static final ParseField QUERY = new ParseField("query");
Expand Down Expand Up @@ -64,6 +65,10 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
PARSER.declareString(ConstructingObjectParser.constructorArg(), SCHEDULE);
}

public static EnrichPolicy fromXContent(XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}

private final String type;
private final QuerySource query;
private final String indexPattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -47,7 +48,7 @@ public final class EnrichMetadata extends AbstractNamedDiffable<MetaData.Custom>
if (token == XContentParser.Token.FIELD_NAME) {
fieldName = p.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
patterns.put(fieldName, EnrichPolicy.PARSER.parse(p, c));
patterns.put(fieldName, EnrichPolicy.fromXContent(p));
} else {
throw new ElasticsearchParseException("unexpected token [" + token + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.AbstractSerializingTestCase;
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;

import java.io.IOException;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.test.AbstractSerializingTestCase;
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -29,7 +30,7 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase<EnrichPolicy>

@Override
protected EnrichPolicy doParseInstance(XContentParser parser) throws IOException {
return EnrichPolicy.PARSER.parse(parser, null);
return EnrichPolicy.fromXContent(parser);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
Expand Down