diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
index 9470d44216343..c945b37ba561c 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
@@ -112,6 +112,7 @@
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
import org.elasticsearch.protocol.xpack.ml.PutJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
import org.elasticsearch.rest.action.search.RestSearchAction;
@@ -1213,6 +1214,18 @@ static Request getMigrationAssistance(IndexUpgradeInfoRequest indexUpgradeInfoRe
return request;
}
+ static Request putRollupJob(PutRollupJobRequest putRollupJobRequest) throws IOException {
+ String endpoint = new EndpointBuilder()
+ .addPathPartAsIs("_xpack")
+ .addPathPartAsIs("rollup")
+ .addPathPartAsIs("job")
+ .addPathPart(putRollupJobRequest.getConfig().getId())
+ .build();
+ Request request = new Request(HttpPut.METHOD_NAME, endpoint);
+ request.setEntity(createEntity(putRollupJobRequest, REQUEST_BODY_CONTENT_TYPE));
+ return request;
+ }
+
private static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException {
BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef();
return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType));
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
index 50d7465ae334a..1fac1f10ccedd 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
@@ -212,6 +212,7 @@ public class RestHighLevelClient implements Closeable {
private final LicenseClient licenseClient = new LicenseClient(this);
private final MigrationClient migrationClient = new MigrationClient(this);
private final MachineLearningClient machineLearningClient = new MachineLearningClient(this);
+ private final RollupClient rollupClient = new RollupClient(this);
/**
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
@@ -361,6 +362,16 @@ public MachineLearningClient machineLearning() {
return machineLearningClient;
}
+ /**
+ * Provides methods for accessing the Elastic Licensed Rollup APIs that
+ * are shipped with the default distribution of Elasticsearch. All of
+ * these APIs will 404 if run against the OSS distribution of Elasticsearch.
+ *
+ * See the
+ * Watcher APIs on elastic.co for more information.
+ */
+ public RollupClient rollup() { return rollupClient; }
+
/**
* Executes a bulk request using the Bulk API.
* See Bulk API on elastic.co
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java
new file mode 100644
index 0000000000000..992a52811d98b
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.elasticsearch.client;
+
+import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
+
+import java.io.IOException;
+
+import static java.util.Collections.emptySet;
+
+/**
+ * A wrapper for the {@link RestHighLevelClient} that provides methods for
+ * accessing the Elastic Rollup-related methods
+ *
+ * See the
+ * X-Pack Rollup APIs on elastic.co for more information.
+ */
+public class RollupClient {
+
+ private final RestHighLevelClient restHighLevelClient;
+
+ RollupClient(RestHighLevelClient restHighLevelClient) {
+ this.restHighLevelClient = restHighLevelClient;
+ }
+
+ /**
+ * Put a rollup job into the cluster
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return the response
+ * @throws IOException in case there is a problem sending the request or parsing back the response
+ */
+ public PutRollupJobResponse putRollupJob(PutRollupJobRequest request, RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::putRollupJob, options,
+ PutRollupJobResponse::fromXContent, emptySet());
+ }
+
+ /**
+ * Asynchronously put a rollup job into the cluster
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @param listener the listener to be notified upon request completion
+ */
+ public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions options, ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::putRollupJob, options,
+ PutRollupJobResponse::fromXContent, listener, emptySet());
+ }
+}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java
index b5d8dbb628eb9..9213a13a6d4b5 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java
@@ -757,6 +757,7 @@ public void testApiNamingConventions() throws Exception {
if (apiName.startsWith("xpack.") == false &&
apiName.startsWith("license.") == false &&
apiName.startsWith("machine_learning.") == false &&
+ apiName.startsWith("rollup.") == false &&
apiName.startsWith("watcher.") == false &&
apiName.startsWith("migration.") == false) {
apiNotFound.add(apiName);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java
new file mode 100644
index 0000000000000..17995eba2ce49
--- /dev/null
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.elasticsearch.client;
+
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
+import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.action.support.WriteRequest;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
+import org.elasticsearch.rest.RestStatus;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.protocol.xpack.rollup.RollupField.SUPPORTED_METRICS;
+
+public class RollupIT extends ESRestHighLevelClientTestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testPutRollupJob() throws Exception {
+ final Set values = new HashSet<>();
+ double sum = 0.0d;
+ int max = Integer.MIN_VALUE;
+ int min = Integer.MAX_VALUE;
+
+ final BulkRequest bulkRequest = new BulkRequest();
+ bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
+ for (int minute = 0; minute < 60; minute++) {
+ for (int second = 0; second < 60; second = second + 10) {
+ final int value = randomIntBetween(0, 100);
+
+ final IndexRequest indexRequest = new IndexRequest("docs", "doc");
+ indexRequest.source(jsonBuilder()
+ .startObject()
+ .field("value", value)
+ .field("date", String.format(Locale.ROOT, "2018-01-01T00:%02d:%02dZ", minute, second))
+ .endObject());
+ bulkRequest.add(indexRequest);
+
+ values.add(value);
+ sum += value;
+ if (value > max) {
+ max = value;
+ }
+ if (value < min) {
+ min = value;
+ }
+ }
+ }
+
+ final int numDocs = bulkRequest.numberOfActions();
+
+ BulkResponse bulkResponse = highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT);
+ assertEquals(RestStatus.OK, bulkResponse.status());
+ if (bulkResponse.hasFailures()) {
+ for (BulkItemResponse itemResponse : bulkResponse.getItems()) {
+ if (itemResponse.isFailed()) {
+ logger.fatal(itemResponse.getFailureMessage());
+ }
+ }
+ }
+ assertFalse(bulkResponse.hasFailures());
+
+ RefreshResponse refreshResponse = highLevelClient().indices().refresh(new RefreshRequest("docs"), RequestOptions.DEFAULT);
+ assertEquals(0, refreshResponse.getFailedShards());
+
+ final String id = randomAlphaOfLength(10);
+ final String indexPattern = randomFrom("docs", "d*", "doc*");
+ final String rollupIndex = randomFrom("rollup", "test");
+ final String cron = "*/1 * * * * ?";
+ final int pageSize = randomIntBetween(numDocs, numDocs * 10);
+ // TODO expand this to also test with histogram and terms?
+ final GroupConfig groups = new GroupConfig(new DateHistogramGroupConfig("date", DateHistogramInterval.DAY));
+ final List metrics = Collections.singletonList(new MetricConfig("value", SUPPORTED_METRICS));
+ final TimeValue timeout = TimeValue.timeValueSeconds(randomIntBetween(30, 600));
+
+ PutRollupJobRequest putRollupJobRequest =
+ new PutRollupJobRequest(new RollupJobConfig(id, indexPattern, rollupIndex, cron, pageSize, groups, metrics, timeout));
+
+ final RollupClient rollupClient = highLevelClient().rollup();
+ PutRollupJobResponse response = execute(putRollupJobRequest, rollupClient::putRollupJob, rollupClient::putRollupJobAsync);
+ assertTrue(response.isAcknowledged());
+
+ // TODO Replace this with the Rollup Start Job API
+ Response startResponse = client().performRequest(new Request("POST", "/_xpack/rollup/job/" + id + "/_start"));
+ assertEquals(RestStatus.OK.getStatus(), startResponse.getHttpResponse().getStatusLine().getStatusCode());
+
+ int finalMin = min;
+ int finalMax = max;
+ double finalSum = sum;
+ assertBusy(() -> {
+ SearchResponse searchResponse = highLevelClient().search(new SearchRequest(rollupIndex), RequestOptions.DEFAULT);
+ assertEquals(0, searchResponse.getFailedShards());
+ assertEquals(1L, searchResponse.getHits().getTotalHits());
+
+ SearchHit searchHit = searchResponse.getHits().getAt(0);
+ Map source = searchHit.getSourceAsMap();
+ assertNotNull(source);
+
+ assertEquals(numDocs, source.get("date.date_histogram._count"));
+ assertEquals(groups.getDateHistogram().getInterval().toString(), source.get("date.date_histogram.interval"));
+ assertEquals(groups.getDateHistogram().getTimeZone(), source.get("date.date_histogram.time_zone"));
+
+ for (MetricConfig metric : metrics) {
+ for (String name : metric.getMetrics()) {
+ Number value = (Number) source.get(metric.getField() + "." + name + ".value");
+ if ("min".equals(name)) {
+ assertEquals(finalMin, value.intValue());
+ } else if ("max".equals(name)) {
+ assertEquals(finalMax, value.intValue());
+ } else if ("sum".equals(name)) {
+ assertEquals(finalSum, value.doubleValue(), 0.0d);
+ } else if ("avg".equals(name)) {
+ assertEquals(finalSum, value.doubleValue(), 0.0d);
+ Number avgCount = (Number) source.get(metric.getField() + "." + name + "._count");
+ assertEquals(numDocs, avgCount.intValue());
+ } else if ("value_count".equals(name)) {
+ assertEquals(numDocs, value.intValue());
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/RollupDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/RollupDocumentationIT.java
new file mode 100644
index 0000000000000..080a52810a260
--- /dev/null
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/RollupDocumentationIT.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.elasticsearch.client.documentation;
+
+import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.LatchedActionListener;
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
+import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.support.WriteRequest;
+import org.elasticsearch.client.ESRestHighLevelClientTestCase;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.HistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
+import org.elasticsearch.rest.RestStatus;
+import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
+import org.junit.Before;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+
+public class RollupDocumentationIT extends ESRestHighLevelClientTestCase {
+
+ @Before
+ public void setUpDocs() throws IOException {
+ final BulkRequest bulkRequest = new BulkRequest();
+ bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
+ for (int i = 0; i < 50; i++) {
+ final IndexRequest indexRequest = new IndexRequest("docs", "doc");
+ indexRequest.source(jsonBuilder()
+ .startObject()
+ .field("timestamp", String.format(Locale.ROOT, "2018-01-01T00:%02d:00Z", i))
+ .field("hostname", 0)
+ .field("datacenter", 0)
+ .field("temperature", 0)
+ .field("voltage", 0)
+ .field("load", 0)
+ .field("net_in", 0)
+ .field("net_out", 0)
+ .endObject());
+ bulkRequest.add(indexRequest);
+ }
+ BulkResponse bulkResponse = highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT);
+ assertEquals(RestStatus.OK, bulkResponse.status());
+ assertFalse(bulkResponse.hasFailures());
+
+ RefreshResponse refreshResponse = highLevelClient().indices().refresh(new RefreshRequest("docs"), RequestOptions.DEFAULT);
+ assertEquals(0, refreshResponse.getFailedShards());
+ }
+
+ public void testCreateRollupJob() throws Exception {
+ RestHighLevelClient client = highLevelClient();
+
+ final String indexPattern = "docs";
+ final String rollupIndex = "rollup";
+ final String cron = "*/1 * * * * ?";
+ final int pageSize = 100;
+ final TimeValue timeout = null;
+
+ //tag::x-pack-rollup-put-rollup-job-group-config
+ DateHistogramGroupConfig dateHistogram =
+ new DateHistogramGroupConfig("timestamp", DateHistogramInterval.HOUR, new DateHistogramInterval("7d"), "UTC"); // <1>
+ TermsGroupConfig terms = new TermsGroupConfig("hostname", "datacenter"); // <2>
+ HistogramGroupConfig histogram = new HistogramGroupConfig(5L, "load", "net_in", "net_out"); // <3>
+
+ GroupConfig groups = new GroupConfig(dateHistogram, histogram, terms); // <4>
+ //end::x-pack-rollup-put-rollup-job-group-config
+
+ //tag::x-pack-rollup-put-rollup-job-metrics-config
+ List metrics = new ArrayList<>(); // <1>
+ metrics.add(new MetricConfig("temperature", Arrays.asList("min", "max", "sum"))); // <2>
+ metrics.add(new MetricConfig("voltage", Arrays.asList("avg", "value_count"))); // <3>
+ //end::x-pack-rollup-put-rollup-job-metrics-config
+ {
+ String id = "job_1";
+
+ //tag::x-pack-rollup-put-rollup-job-config
+ RollupJobConfig config = new RollupJobConfig(id, // <1>
+ indexPattern, // <2>
+ rollupIndex, // <3>
+ cron, // <4>
+ pageSize, // <5>
+ groups, // <6>
+ metrics, // <7>
+ timeout); // <8>
+ //end::x-pack-rollup-put-rollup-job-config
+
+ //tag::x-pack-rollup-put-rollup-job-request
+ PutRollupJobRequest request = new PutRollupJobRequest(config); // <1>
+ //end::x-pack-rollup-put-rollup-job-request
+
+ //tag::x-pack-rollup-put-rollup-job-execute
+ PutRollupJobResponse response = client.rollup().putRollupJob(request, RequestOptions.DEFAULT);
+ //end::x-pack-rollup-put-rollup-job-execute
+
+ //tag::x-pack-rollup-put-rollup-job-response
+ boolean acknowledged = response.isAcknowledged(); // <1>
+ //end::x-pack-rollup-put-rollup-job-response
+ assertTrue(acknowledged);
+ }
+ {
+ String id = "job_2";
+ RollupJobConfig config = new RollupJobConfig(id, indexPattern, rollupIndex, cron, pageSize, groups, metrics, timeout);
+ PutRollupJobRequest request = new PutRollupJobRequest(config);
+ // tag::x-pack-rollup-put-rollup-job-execute-listener
+ ActionListener listener = new ActionListener() {
+ @Override
+ public void onResponse(PutRollupJobResponse response) {
+ // <1>
+ }
+
+ @Override
+ public void onFailure(Exception e) {
+ // <2>
+ }
+ };
+ // end::x-pack-rollup-put-rollup-job-execute-listener
+
+ // Replace the empty listener by a blocking listener in test
+ final CountDownLatch latch = new CountDownLatch(1);
+ listener = new LatchedActionListener<>(listener, latch);
+
+ // tag::x-pack-rollup-put-rollup-job-execute-async
+ client.rollup().putRollupJobAsync(request, RequestOptions.DEFAULT, listener); // <1>
+ // end::x-pack-rollup-put-rollup-job-execute-async
+
+ assertTrue(latch.await(30L, TimeUnit.SECONDS));
+ }
+ }
+}
diff --git a/docs/java-rest/high-level/supported-apis.asciidoc b/docs/java-rest/high-level/supported-apis.asciidoc
index 1ddee70f1e09b..3249077fae20a 100644
--- a/docs/java-rest/high-level/supported-apis.asciidoc
+++ b/docs/java-rest/high-level/supported-apis.asciidoc
@@ -215,3 +215,12 @@ The Java High Level REST Client supports the following Watcher APIs:
include::watcher/put-watch.asciidoc[]
include::watcher/delete-watch.asciidoc[]
+
+
+== Rollup APIs
+
+The Java High Level REST Client supports the following Rollup APIs:
+
+* <>
+
+include::x-pack/rollup/put_job.asciidoc[]
diff --git a/docs/java-rest/high-level/x-pack/rollup/put_job.asciidoc b/docs/java-rest/high-level/x-pack/rollup/put_job.asciidoc
new file mode 100644
index 0000000000000..6d8f0352ef2b7
--- /dev/null
+++ b/docs/java-rest/high-level/x-pack/rollup/put_job.asciidoc
@@ -0,0 +1,172 @@
+[[java-rest-high-x-pack-rollup-put-job]]
+=== Put Rollup Job API
+
+The Put Rollup Job API can be used to create a new Rollup job
+in the cluster. The API accepts a `PutRollupJobRequest` object
+as a request and returns a `PutRollupJobResponse`.
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-request]]
+==== Put Rollup Job Request
+
+A `PutRollupJobRequest` requires the following argument:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-request]
+--------------------------------------------------
+<1> The configuration of the Rollup job to create as a `RollupJobConfig`
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-config]]
+==== Rollup Job Configuration
+
+The `RollupJobConfig` object contains all the details about the rollup job
+configuration. See <> to learn more
+about the various configuration settings.
+
+A `RollupJobConfig` requires the following arguments:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-config]
+--------------------------------------------------
+<1> The name of the Rollup job
+<2> The index (or index pattern) to rollup
+<3> The index to store rollup results into
+<4> A cron expression which defines when the Rollup job should be executed
+<5> The page size to use for the Rollup job
+<6> The grouping configuration of the Rollup job as a `GroupConfig`
+<7> The metrics configuration of the Rollup job as a list of `MetricConfig`
+<8> The timeout value to use for the Rollup job as a `TimeValue`
+
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-group-config]]
+==== Grouping Configuration
+
+The grouping configuration of the Rollup job is defined in the `RollupJobConfig`
+using a `GroupConfig` instance. `GroupConfig` reflects all the configuration
+settings that can be defined using the REST API. See <>
+to learn more about these settings.
+
+Using the REST API, we could define this grouping configuration:
+
+[source,js]
+--------------------------------------------------
+"groups" : {
+ "date_histogram": {
+ "field": "timestamp",
+ "interval": "1h",
+ "delay": "7d",
+ "time_zone": "UTC"
+ },
+ "terms": {
+ "fields": ["hostname", "datacenter"]
+ },
+ "histogram": {
+ "fields": ["load", "net_in", "net_out"],
+ "interval": 5
+ }
+}
+--------------------------------------------------
+// NOTCONSOLE
+
+Using the `GroupConfig` object and the high level REST client, the same
+configuration would be:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-group-config]
+--------------------------------------------------
+<1> The date histogram aggregation to use to rollup up documents, as a `DateHistogramGroupConfig`
+<2> The terms aggregation to use to rollup up documents, as a `TermsGroupConfig`
+<3> The histogram aggregation to use to rollup up documents, as a `HistogramGroupConfig`
+<4> The grouping configuration as a `GroupConfig`
+
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-metrics-config]]
+==== Metrics Configuration
+
+After defining which groups should be generated for the data, you next configure
+which metrics should be collected. The list of metrics is defined in the `RollupJobConfig`
+using a `List` instance. `MetricConfig` reflects all the configuration
+settings that can be defined using the REST API. See <>
+to learn more about these settings.
+
+Using the REST API, we could define this metrics configuration:
+
+[source,js]
+--------------------------------------------------
+"metrics": [
+ {
+ "field": "temperature",
+ "metrics": ["min", "max", "sum"]
+ },
+ {
+ "field": "voltage",
+ "metrics": ["avg", "value_count"]
+ }
+]
+--------------------------------------------------
+// NOTCONSOLE
+
+Using the `MetricConfig` object and the high level REST client, the same
+configuration would be:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-metrics-config]
+--------------------------------------------------
+<1> The list of `MetricConfig` to configure in the `RollupJobConfig`
+<2> Adds the metrics to compute on the `temperature` field
+<3> Adds the metrics to compute on the `voltage` field
+
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-execution]]
+==== Execution
+
+The Put Rollup Job API can be executed through a `RollupClient`
+instance. Such instance can be retrieved from a `RestHighLevelClient`
+using the `rollup()` method:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-execute]
+--------------------------------------------------
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-response]]
+==== Response
+
+The returned `PutRollupJobResponse` indicates if the new Rollup job
+has been successfully created:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-response]
+--------------------------------------------------
+<1> `acknowledged` is a boolean indicating whether the job was successfully created
+
+[[java-rest-high-x-pack-rollup-put-rollup-job-async]]
+==== Asynchronous Execution
+
+This request can be executed asynchronously:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-execute-async]
+--------------------------------------------------
+<1> The `PutRollupJobRequest` to execute and the `ActionListener` to use when
+the execution completes
+
+The asynchronous method does not block and returns immediately. Once it is
+completed the `ActionListener` is called back using the `onResponse` method
+if the execution successfully completed or using the `onFailure` method if
+it failed.
+
+A typical listener for `PutRollupJobResponse` looks like:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-put-rollup-job-execute-listener]
+--------------------------------------------------
+<1> Called when the execution is successfully completed. The response is
+provided as an argument
+<2> Called in case of failure. The raised exception is provided as an argument
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 0389ceffbc3d6..aa8b5f88d3f58 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
@@ -33,16 +33,17 @@
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.xpack.core.action.XPackInfoAction;
import org.elasticsearch.xpack.core.action.XPackUsageAction;
+import org.elasticsearch.xpack.core.beats.BeatsFeatureSetUsage;
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.logstash.LogstashFeatureSetUsage;
-import org.elasticsearch.xpack.core.beats.BeatsFeatureSetUsage;
import org.elasticsearch.xpack.core.ml.MachineLearningFeatureSetUsage;
import org.elasticsearch.xpack.core.ml.MlMetadata;
import org.elasticsearch.xpack.core.ml.action.CloseJobAction;
@@ -96,7 +97,6 @@
import org.elasticsearch.xpack.core.ml.job.config.JobTaskState;
import org.elasticsearch.xpack.core.monitoring.MonitoringFeatureSetUsage;
import org.elasticsearch.xpack.core.rollup.RollupFeatureSetUsage;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.DeleteRollupJobAction;
import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
import org.elasticsearch.xpack.core.rollup.action.GetRollupJobsAction;
@@ -133,8 +133,8 @@
import org.elasticsearch.xpack.core.security.authc.support.mapper.expressiondsl.ExceptExpression;
import org.elasticsearch.xpack.core.security.authc.support.mapper.expressiondsl.FieldExpression;
import org.elasticsearch.xpack.core.security.authc.support.mapper.expressiondsl.RoleMapperExpression;
-import org.elasticsearch.xpack.core.security.authz.privilege.ConditionalClusterPrivileges;
import org.elasticsearch.xpack.core.security.authz.privilege.ConditionalClusterPrivilege;
+import org.elasticsearch.xpack.core.security.authz.privilege.ConditionalClusterPrivileges;
import org.elasticsearch.xpack.core.security.transport.netty4.SecurityNetty4Transport;
import org.elasticsearch.xpack.core.ssl.SSLService;
import org.elasticsearch.xpack.core.ssl.action.GetCertificateInfoAction;
@@ -379,7 +379,7 @@ public List getNamedXContent() {
StartDatafeedAction.DatafeedParams::fromXContent),
new NamedXContentRegistry.Entry(PersistentTaskParams.class, new ParseField(OpenJobAction.TASK_NAME),
OpenJobAction.JobParams::fromXContent),
- // ML - Task states
+ // ML - Task states
new NamedXContentRegistry.Entry(PersistentTaskState.class, new ParseField(DatafeedState.NAME), DatafeedState::fromXContent),
new NamedXContentRegistry.Entry(PersistentTaskState.class, new ParseField(JobTaskState.NAME), JobTaskState::fromXContent),
// watcher
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/DeleteRollupJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/DeleteRollupJobAction.java
index e59c6738d86b1..dec250a748f8e 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/DeleteRollupJobAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/DeleteRollupJobAction.java
@@ -16,8 +16,8 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import java.io.IOException;
import java.util.Objects;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java
index 128874a6c8c87..73cade8150d3b 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java
@@ -21,7 +21,7 @@
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import java.io.IOException;
import java.util.Collections;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupIndexCapsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupIndexCapsAction.java
index 4f95919c4986b..d3f856ac0d55d 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupIndexCapsAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupIndexCapsAction.java
@@ -22,7 +22,7 @@
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import java.io.IOException;
import java.util.Arrays;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java
index 50f7931508585..d990818225ec2 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java
@@ -24,9 +24,9 @@
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.tasks.Task;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStats;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStatus;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java
index 962f4cceb6af5..4acf269a771e7 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java
@@ -6,26 +6,12 @@
package org.elasticsearch.xpack.core.rollup.action;
import org.elasticsearch.action.Action;
-import org.elasticsearch.action.ActionRequestValidationException;
-import org.elasticsearch.action.IndicesRequest;
-import org.elasticsearch.action.fieldcaps.FieldCapabilities;
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.action.support.master.AcknowledgedRequest;
-import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.xcontent.ToXContentObject;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Objects;
-
-public class PutRollupJobAction extends Action {
+public class PutRollupJobAction extends Action {
public static final PutRollupJobAction INSTANCE = new PutRollupJobAction();
public static final String NAME = "cluster:admin/xpack/rollup/put";
@@ -35,113 +21,15 @@ private PutRollupJobAction() {
}
@Override
- public Response newResponse() {
- return new Response();
+ public PutRollupJobResponse newResponse() {
+ return new PutRollupJobResponse();
}
- public static class Request extends AcknowledgedRequest implements IndicesRequest, ToXContentObject {
-
- private RollupJobConfig config;
- private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false);
-
- public Request(RollupJobConfig config) {
- this.config = config;
- }
-
- public Request() {
-
- }
-
- public static Request fromXContent(final XContentParser parser, final String id) throws IOException {
- return new Request(RollupJobConfig.fromXContent(parser, id));
- }
-
- public RollupJobConfig getConfig() {
- return config;
- }
-
- public void setConfig(RollupJobConfig config) {
- this.config = config;
- }
-
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- this.config = new RollupJobConfig(in);
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- this.config.writeTo(out);
- }
-
- @Override
- public ActionRequestValidationException validate() {
- return null;
- }
-
- public RollupActionRequestValidationException validateMappings(Map> fieldCapsResponse) {
- RollupActionRequestValidationException validationException = new RollupActionRequestValidationException();
- if (fieldCapsResponse.size() == 0) {
- validationException.addValidationError("Could not find any fields in the index/index-pattern that were configured in job");
- return validationException;
- }
- config.validateMappings(fieldCapsResponse, validationException);
- if (validationException.validationErrors().size() > 0) {
- return validationException;
- }
- return null;
- }
-
- @Override
- public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
- return this.config.toXContent(builder, params);
- }
-
- @Override
- public String[] indices() {
- return new String[]{this.config.getIndexPattern()};
- }
-
- @Override
- public IndicesOptions indicesOptions() {
- return indicesOptions;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(config);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Request other = (Request) obj;
- return Objects.equals(config, other.config);
- }
- }
-
- public static class RequestBuilder extends MasterNodeOperationRequestBuilder {
+ public static class RequestBuilder
+ extends MasterNodeOperationRequestBuilder {
protected RequestBuilder(ElasticsearchClient client, PutRollupJobAction action) {
- super(client, action, new Request());
- }
- }
-
- public static class Response extends AcknowledgedResponse {
-
- public Response() {
- super();
- }
-
- public Response(boolean acknowledged) {
- super(acknowledged);
+ super(client, action, new PutRollupJobRequest());
}
}
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupJobCaps.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupJobCaps.java
index 1b8eb736084a8..dcc34684c46fa 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupJobCaps.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupJobCaps.java
@@ -11,7 +11,7 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import java.io.IOException;
import java.util.ArrayList;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StartRollupJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StartRollupJobAction.java
index e3dcb1a882f9f..b0b15aa4dd428 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StartRollupJobAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StartRollupJobAction.java
@@ -19,7 +19,7 @@
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import java.io.IOException;
import java.util.Collections;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StopRollupJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StopRollupJobAction.java
index eb48d640f21eb..8378dfa4cb244 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StopRollupJobAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/StopRollupJobAction.java
@@ -18,7 +18,7 @@
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import java.io.IOException;
import java.util.Collections;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJob.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJob.java
index 94306966a34da..8e5bb34f160fc 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJob.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJob.java
@@ -14,6 +14,7 @@
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.xpack.core.XPackPlugin;
import java.io.IOException;
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/ConfigTestHelpers.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/ConfigTestHelpers.java
index d892eb550a17a..e43c78d5352ad 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/ConfigTestHelpers.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/ConfigTestHelpers.java
@@ -7,14 +7,14 @@
import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.HistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.HistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
-import org.elasticsearch.xpack.core.rollup.job.TermsGroupConfig;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfigSerializingTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfigSerializingTests.java
index 6b8846def7284..fe08598eb05f3 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfigSerializingTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfigSerializingTests.java
@@ -11,6 +11,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.test.AbstractSerializingTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
@@ -21,6 +22,7 @@
import java.util.HashMap;
import java.util.Map;
+import static org.apache.lucene.util.LuceneTestCase.random;
import static org.elasticsearch.xpack.core.rollup.ConfigTestHelpers.randomDateHistogramGroupConfig;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/GroupConfigSerializingTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/GroupConfigSerializingTests.java
index 49ea206ded767..bff5f3ddd7f6d 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/GroupConfigSerializingTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/GroupConfigSerializingTests.java
@@ -7,6 +7,7 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
import org.elasticsearch.test.AbstractSerializingTestCase;
import java.io.IOException;
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfigSerializingTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfigSerializingTests.java
index ef81b235b1fba..8f886a7431d06 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfigSerializingTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfigSerializingTests.java
@@ -9,8 +9,9 @@
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.HistogramGroupConfig;
import org.elasticsearch.test.AbstractSerializingTestCase;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import java.io.IOException;
import java.util.Collections;
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/MetricConfigSerializingTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/MetricConfigSerializingTests.java
index a5b8d9afead2e..8146a64530d94 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/MetricConfigSerializingTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/MetricConfigSerializingTests.java
@@ -9,6 +9,7 @@
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
import org.elasticsearch.test.AbstractSerializingTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfigTests.java
index a5a82bc2bb090..6086132fd03c0 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfigTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfigTests.java
@@ -7,6 +7,7 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.test.AbstractSerializingTestCase;
import org.junit.Before;
@@ -87,15 +88,6 @@ public void testEmptyID() {
assertThat(e.getMessage(), equalTo("Id must be a non-null, non-empty string"));
}
- public void testBadCron() {
- final RollupJobConfig sample = randomRollupJobConfig(random());
-
- Exception e = expectThrows(IllegalArgumentException.class, () ->
- new RollupJobConfig(sample.getId(), sample.getIndexPattern(), sample.getRollupIndex(), "0 * * *", sample.getPageSize(),
- sample.getGroupConfig(), sample.getMetricsConfig(), sample.getTimeout()));
- assertThat(e.getMessage(), equalTo("invalid cron expression [0 * * *]"));
- }
-
public void testMatchAllIndexPattern() {
final RollupJobConfig sample = randomRollupJobConfig(random());
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfigSerializingTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfigSerializingTests.java
index ccdd616df7b51..70d61363bd3e0 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfigSerializingTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfigSerializingTests.java
@@ -9,6 +9,7 @@
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
import org.elasticsearch.test.AbstractSerializingTestCase;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java
index 0fc4d838f7ce8..52a4f8219ae9f 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java
@@ -35,7 +35,7 @@
import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.core.XPackSettings;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.DeleteRollupJobAction;
import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtils.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtils.java
index d1706fd708e93..3ae8adf2ecfdb 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtils.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtils.java
@@ -11,9 +11,9 @@
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
import org.joda.time.DateTimeZone;
import java.util.ArrayList;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupRequestTranslator.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupRequestTranslator.java
index 0668e7c43ad3c..076aec4ed51bc 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupRequestTranslator.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupRequestTranslator.java
@@ -12,6 +12,8 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
@@ -19,8 +21,6 @@
import org.elasticsearch.search.aggregations.metrics.avg.AvgAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.sum.SumAggregationBuilder;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
import org.joda.time.DateTimeZone;
import java.util.ArrayList;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupResponseTranslator.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupResponseTranslator.java
index 4042e98ef93fb..c27de5164cf1d 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupResponseTranslator.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupResponseTranslator.java
@@ -34,7 +34,7 @@
import org.elasticsearch.search.aggregations.metrics.sum.InternalSum;
import org.elasticsearch.search.aggregations.metrics.sum.SumAggregationBuilder;
import org.elasticsearch.search.internal.InternalSearchResponse;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java
index 88c2986574792..576180e06b996 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java
@@ -19,10 +19,10 @@
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import java.io.IOException;
import java.util.ArrayList;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java
index 6d565e43b8644..4acd98057e7c9 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java
@@ -19,7 +19,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
import org.elasticsearch.xpack.core.rollup.action.RollableIndexCaps;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupJobAction.java
index a72dbfbe6b94f..2ca103f061dcb 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupJobAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupJobAction.java
@@ -23,7 +23,7 @@
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.GetRollupJobsAction;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStatus;
import org.elasticsearch.xpack.rollup.job.RollupJobTask;
@@ -124,4 +124,4 @@ protected GetRollupJobsAction.Response newResponse(GetRollupJobsAction.Request r
protected GetRollupJobsAction.Response readTaskResponse(StreamInput in) throws IOException {
return new GetRollupJobsAction.Response(in);
}
-}
\ No newline at end of file
+}
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java
index 889dfa3ac8efc..1592f9b538adf 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java
@@ -38,22 +38,25 @@
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.persistent.PersistentTasksService;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.core.XPackPlugin;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.PutRollupJobAction;
import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.xpack.core.scheduler.Cron;
import org.elasticsearch.xpack.rollup.Rollup;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
-public class TransportPutRollupJobAction extends TransportMasterNodeAction {
+public class TransportPutRollupJobAction extends TransportMasterNodeAction {
private final XPackLicenseState licenseState;
private final PersistentTasksService persistentTasksService;
private final Client client;
@@ -64,7 +67,7 @@ public TransportPutRollupJobAction(Settings settings, TransportService transport
ClusterService clusterService, XPackLicenseState licenseState,
PersistentTasksService persistentTasksService, Client client) {
super(settings, PutRollupJobAction.NAME, transportService, clusterService, threadPool, actionFilters,
- indexNameExpressionResolver, PutRollupJobAction.Request::new);
+ indexNameExpressionResolver, PutRollupJobRequest::new);
this.licenseState = licenseState;
this.persistentTasksService = persistentTasksService;
this.client = client;
@@ -76,19 +79,20 @@ protected String executor() {
}
@Override
- protected PutRollupJobAction.Response newResponse() {
- return new PutRollupJobAction.Response();
+ protected PutRollupJobResponse newResponse() {
+ return new PutRollupJobResponse();
}
@Override
- protected void masterOperation(PutRollupJobAction.Request request, ClusterState clusterState,
- ActionListener listener) {
+ protected void masterOperation(PutRollupJobRequest request, ClusterState clusterState,
+ ActionListener listener) {
if (!licenseState.isRollupAllowed()) {
listener.onFailure(LicenseUtils.newComplianceException(XPackField.ROLLUP));
return;
}
+ validate(request);
XPackPlugin.checkReadyForXPackCustomMetadata(clusterState);
FieldCapabilitiesRequest fieldCapsRequest = new FieldCapabilitiesRequest()
@@ -115,6 +119,13 @@ public void onFailure(Exception e) {
});
}
+ static void validate(final PutRollupJobRequest request) {
+ final RollupJobConfig rollupJobConfig = request.getConfig();
+ if (rollupJobConfig != null) {
+ Cron.validate(rollupJobConfig.getCron());
+ }
+ }
+
private static RollupJob createRollupJob(RollupJobConfig config, ThreadPool threadPool) {
// ensure we only filter for the allowed headers
Map filteredHeaders = threadPool.getThreadContext().getHeaders().entrySet().stream()
@@ -123,7 +134,7 @@ private static RollupJob createRollupJob(RollupJobConfig config, ThreadPool thre
return new RollupJob(config, filteredHeaders);
}
- static void createIndex(RollupJob job, ActionListener listener,
+ static void createIndex(RollupJob job, ActionListener listener,
PersistentTasksService persistentTasksService, Client client, Logger logger) {
String jobMetadata = "\"" + job.getConfig().getId() + "\":" + job.getConfig().toJSONString();
@@ -148,7 +159,7 @@ static void createIndex(RollupJob job, ActionListener listener,
+ static void updateMapping(RollupJob job, ActionListener listener,
PersistentTasksService persistentTasksService, Client client, Logger logger) {
final String indexName = job.getConfig().getRollupIndex();
@@ -210,7 +221,7 @@ static void updateMapping(RollupJob job, ActionListener listener,
+ static void startPersistentTask(RollupJob job, ActionListener listener,
PersistentTasksService persistentTasksService) {
persistentTasksService.sendStartRequest(job.getConfig().getId(), RollupField.TASK_NAME, job,
@@ -226,13 +237,13 @@ static void startPersistentTask(RollupJob job, ActionListener listener,
+ private static void waitForRollupStarted(RollupJob job, ActionListener listener,
PersistentTasksService persistentTasksService) {
persistentTasksService.waitForPersistentTaskCondition(job.getConfig().getId(), Objects::nonNull, job.getConfig().getTimeout(),
new PersistentTasksService.WaitForPersistentTaskListener() {
@Override
public void onResponse(PersistentTasksCustomMetaData.PersistentTask task) {
- listener.onResponse(new PutRollupJobAction.Response(true));
+ listener.onResponse(new PutRollupJobResponse(true));
}
@Override
@@ -249,7 +260,7 @@ public void onTimeout(TimeValue timeout) {
}
@Override
- protected ClusterBlockException checkBlock(PutRollupJobAction.Request request, ClusterState state) {
+ protected ClusterBlockException checkBlock(PutRollupJobRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
}
}
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java
index c63ab96fa2595..6e1b410cee90e 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java
@@ -53,10 +53,10 @@
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportRequestHandler;
import org.elasticsearch.transport.TransportService;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
import org.elasticsearch.xpack.core.rollup.action.RollupSearchAction;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
import org.elasticsearch.xpack.rollup.Rollup;
import org.elasticsearch.xpack.rollup.RollupJobIdentifierUtils;
import org.elasticsearch.xpack.rollup.RollupRequestTranslator;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java
index 9119a5445d42e..17c1f37153878 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java
@@ -14,9 +14,9 @@
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStats;
import org.elasticsearch.xpack.rollup.Rollup;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupIndexer.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupIndexer.java
index 87294706b3b7d..10a05477c1f69 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupIndexer.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupIndexer.java
@@ -20,12 +20,12 @@
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
import org.elasticsearch.xpack.core.rollup.job.IndexerState;
import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStats;
import java.util.ArrayList;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupJobTask.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupJobTask.java
index 65362f9ad9dd3..c982901ae61d3 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupJobTask.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/RollupJobTask.java
@@ -25,12 +25,12 @@
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.ClientHelper;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.StartRollupJobAction;
import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction;
import org.elasticsearch.xpack.core.rollup.job.IndexerState;
import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStats;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStatus;
import org.elasticsearch.xpack.core.scheduler.SchedulerEngine;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java
index 231e382827e8a..16febafb1f483 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestPutRollupJobAction.java
@@ -7,9 +7,8 @@
import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
@@ -20,7 +19,6 @@
import java.io.IOException;
public class RestPutRollupJobAction extends BaseRestHandler {
- public static final ParseField ID = new ParseField("id");
public RestPutRollupJobAction(Settings settings, RestController controller) {
super(settings);
@@ -28,13 +26,9 @@ public RestPutRollupJobAction(Settings settings, RestController controller) {
}
@Override
- protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
- String id = restRequest.param(ID.getPreferredName());
- XContentParser parser = restRequest.contentParser();
-
- PutRollupJobAction.Request request = PutRollupJobAction.Request.fromXContent(parser, id);
-
- return channel -> client.execute(PutRollupJobAction.INSTANCE, request, new RestToXContentListener<>(channel));
+ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
+ final PutRollupJobRequest putRollupJobRequest = PutRollupJobRequest.fromXContent(request.contentParser(), request.param("id"));
+ return channel -> client.execute(PutRollupJobAction.INSTANCE, putRollupJobRequest, new RestToXContentListener<>(channel));
}
@Override
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java
index dfa5c977f2a5f..1127bdaea5348 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStartRollupJobAction.java
@@ -11,7 +11,7 @@
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.rollup.Rollup;
import org.elasticsearch.xpack.core.rollup.action.StartRollupJobAction;
diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java
index f51952b7f6143..8ced1db8a6a1e 100644
--- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java
+++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestStopRollupJobAction.java
@@ -11,7 +11,7 @@
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.rollup.Rollup;
import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtilTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtilTests.java
index 3235d0c39e256..115db849b7549 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtilTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupJobIdentifierUtilTests.java
@@ -16,12 +16,12 @@
import org.elasticsearch.search.aggregations.support.ValueType;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.HistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
-import org.elasticsearch.xpack.core.rollup.job.TermsGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.HistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
import org.joda.time.DateTimeZone;
import java.util.Arrays;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java
index 35d9f0d133a3d..bdfc4d908fefc 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java
@@ -66,7 +66,7 @@
import org.elasticsearch.search.aggregations.metrics.sum.SumAggregationBuilder;
import org.elasticsearch.search.aggregations.support.ValueType;
import org.elasticsearch.search.internal.InternalSearchResponse;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import java.io.IOException;
import java.util.ArrayList;
@@ -76,7 +76,7 @@
import java.util.Map;
import static java.util.Collections.singleton;
-import static org.elasticsearch.xpack.core.rollup.RollupField.COUNT_FIELD;
+import static org.elasticsearch.protocol.xpack.rollup.RollupField.COUNT_FIELD;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.IsEqual.equalTo;
@@ -156,7 +156,7 @@ public void testMissingLiveIndex() {
InternalSum count = mock(InternalSum.class);
when(count.getValue()).thenReturn(2.0);
when(count.value()).thenReturn(2.0);
- when(count.getName()).thenReturn("foo." + RollupField.COUNT_FIELD);
+ when(count.getName()).thenReturn("foo." + COUNT_FIELD);
when(count.getMetaData()).thenReturn(null);
when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count);
@@ -254,7 +254,7 @@ public void testTranslateRollup() {
InternalSum count = mock(InternalSum.class);
when(count.getValue()).thenReturn(2.0);
when(count.value()).thenReturn(2.0);
- when(count.getName()).thenReturn("foo." + RollupField.COUNT_FIELD);
+ when(count.getName()).thenReturn("foo." + COUNT_FIELD);
when(count.getMetaData()).thenReturn(null);
when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count);
@@ -379,7 +379,7 @@ public void testSimpleReduction() {
InternalSum count = mock(InternalSum.class);
when(count.getValue()).thenReturn(2.0);
when(count.value()).thenReturn(2.0);
- when(count.getName()).thenReturn("foo." + RollupField.COUNT_FIELD);
+ when(count.getName()).thenReturn("foo." + COUNT_FIELD);
when(count.getMetaData()).thenReturn(null);
when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count);
@@ -523,8 +523,8 @@ public void testDateHisto() throws IOException {
DateHistogramAggregationBuilder rollupHisto = new DateHistogramAggregationBuilder("histo")
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -536,11 +536,11 @@ public void testDateHisto() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -569,8 +569,8 @@ public void testDateHistoWithGap() throws IOException {
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
.minDocCount(0)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -582,11 +582,11 @@ public void testDateHistoWithGap() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -626,8 +626,8 @@ public void testNonMatchingPartition() throws IOException {
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
.minDocCount(0)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -639,11 +639,11 @@ public void testNonMatchingPartition() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
KeywordFieldMapper.Builder nrKeywordBuilder = new KeywordFieldMapper.Builder("partition");
KeywordFieldMapper.KeywordFieldType nrKeywordFT = nrKeywordBuilder.fieldType();
@@ -690,33 +690,33 @@ public void testNonMatchingPartition() throws IOException {
// Time 100: Two "a" documents, one "b" doc
Document doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 100));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 2));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 2));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
doc.add(new TextField("partition.terms." + RollupField.VALUE, "a", Field.Store.NO));
- doc.add(new SortedNumericDocValuesField("partition.terms." + RollupField.COUNT_FIELD, 2));
+ doc.add(new SortedNumericDocValuesField("partition.terms." + COUNT_FIELD, 2));
iw.addDocument(doc);
doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 100));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 1));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
doc.add(new TextField("partition.terms." + RollupField.VALUE, "b", Field.Store.NO));
- doc.add(new SortedNumericDocValuesField("partition.terms." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("partition.terms." + COUNT_FIELD, 1));
iw.addDocument(doc);
// Time 200: one "a" document, one "b" doc
doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 200));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 1));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
doc.add(new TextField("partition.terms." + RollupField.VALUE, "a", Field.Store.NO));
- doc.add(new SortedNumericDocValuesField("partition.terms." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("partition.terms." + COUNT_FIELD, 1));
iw.addDocument(doc);
doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 200));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 1));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
doc.add(new TextField("partition.terms." + RollupField.VALUE, "b", Field.Store.NO));
- doc.add(new SortedNumericDocValuesField("partition.terms." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("partition.terms." + COUNT_FIELD, 1));
iw.addDocument(doc);
}, rollupHisto, new MappedFieldType[]{rFTtimestamp, rFTvalue, rKeywordFT}));
@@ -737,8 +737,8 @@ public void testDateHistoOverlappingAggTrees() throws IOException {
DateHistogramAggregationBuilder rollupHisto = new DateHistogramAggregationBuilder("histo")
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -750,11 +750,11 @@ public void testDateHistoOverlappingAggTrees() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -798,8 +798,8 @@ public void testDateHistoOverlappingMergeRealIntoZero() throws IOException {
DateHistogramAggregationBuilder rollupHisto = new DateHistogramAggregationBuilder("histo")
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -811,11 +811,11 @@ public void testDateHistoOverlappingMergeRealIntoZero() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -834,13 +834,13 @@ public void testDateHistoOverlappingMergeRealIntoZero() throws IOException {
iw -> {
Document doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 100));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 0));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 0));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
iw.addDocument(doc);
Document doc2 = new Document();
doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 200));
- doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 0));
+ doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 0));
doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
iw.addDocument(doc2);
@@ -866,8 +866,8 @@ public void testDateHistoOverlappingMergeZeroIntoReal() throws IOException {
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
.minDocCount(0)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -879,11 +879,11 @@ public void testDateHistoOverlappingMergeZeroIntoReal() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
InternalAggregation currentTree = doQuery(new MatchAllDocsQuery(),
iw -> {
@@ -896,13 +896,13 @@ public void testDateHistoOverlappingMergeZeroIntoReal() throws IOException {
iw -> {
Document doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 100));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 0));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 0));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
iw.addDocument(doc);
Document doc2 = new Document();
doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, 200));
- doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 0));
+ doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 0));
doc2.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
iw.addDocument(doc2);
@@ -1050,7 +1050,7 @@ public void testStringTerms() throws IOException {
TermsAggregationBuilder rollupTerms = new TermsAggregationBuilder("terms", ValueType.STRING)
.field("stringfield.terms." + RollupField.VALUE)
.subAggregation(new SumAggregationBuilder("terms." + COUNT_FIELD)
- .field("stringfield.terms." + RollupField.COUNT_FIELD));
+ .field("stringfield.terms." + COUNT_FIELD));
KeywordFieldMapper.Builder nrBuilder = new KeywordFieldMapper.Builder("terms");
KeywordFieldMapper.KeywordFieldType nrFTterm = nrBuilder.fieldType();
@@ -1062,11 +1062,11 @@ public void testStringTerms() throws IOException {
rFTterm.setHasDocValues(true);
rFTterm.setName(rollupTerms.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("terms." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("terms." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("stringfield.terms." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("stringfield.terms." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -1091,7 +1091,7 @@ public void testStringTermsNullValue() throws IOException {
TermsAggregationBuilder rollupTerms = new TermsAggregationBuilder("terms", ValueType.STRING)
.field("stringfield.terms." + RollupField.VALUE)
.subAggregation(new SumAggregationBuilder("terms." + COUNT_FIELD)
- .field("stringfield.terms." + RollupField.COUNT_FIELD));
+ .field("stringfield.terms." + COUNT_FIELD));
KeywordFieldMapper.Builder nrBuilder = new KeywordFieldMapper.Builder("terms");
KeywordFieldMapper.KeywordFieldType nrFTterm = nrBuilder.fieldType();
@@ -1103,11 +1103,11 @@ public void testStringTermsNullValue() throws IOException {
rFTterm.setHasDocValues(true);
rFTterm.setName(rollupTerms.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("terms." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("terms." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("stringfield.terms." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("stringfield.terms." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -1139,7 +1139,7 @@ public void testLongTerms() throws IOException {
TermsAggregationBuilder rollupTerms = new TermsAggregationBuilder("terms", ValueType.LONG)
.field("longfield.terms." + RollupField.VALUE)
.subAggregation(new SumAggregationBuilder("terms." + COUNT_FIELD)
- .field("longfield.terms." + RollupField.COUNT_FIELD));
+ .field("longfield.terms." + COUNT_FIELD));
NumberFieldMapper.Builder nrBuilder = new NumberFieldMapper.Builder("terms", NumberFieldMapper.NumberType.LONG);
MappedFieldType nrFTterm = nrBuilder.fieldType();
@@ -1151,11 +1151,11 @@ public void testLongTerms() throws IOException {
rFTterm.setHasDocValues(true);
rFTterm.setName(rollupTerms.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("terms." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("terms." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("longfield.terms." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("longfield.terms." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -1180,8 +1180,8 @@ public void testHisto() throws IOException {
HistogramAggregationBuilder rollupHisto = new HistogramAggregationBuilder("histo")
.field("bar.histogram." + RollupField.VALUE)
.interval(100)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("bar.histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("bar.histogram." + COUNT_FIELD));
NumberFieldMapper.Builder nrBuilder = new NumberFieldMapper.Builder("histo", NumberFieldMapper.NumberType.LONG);
MappedFieldType nrFTbar = nrBuilder.fieldType();
@@ -1193,11 +1193,11 @@ public void testHisto() throws IOException {
rFTbar.setHasDocValues(true);
rFTbar.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("bar.histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("bar.histogram." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -1224,8 +1224,8 @@ public void testOverlappingBuckets() throws IOException {
DateHistogramAggregationBuilder rollupHisto = new DateHistogramAggregationBuilder("histo")
.field("timestamp.date_histogram." + RollupField.TIMESTAMP)
.interval(100)
- .subAggregation(new SumAggregationBuilder("histo." + RollupField.COUNT_FIELD)
- .field("timestamp.date_histogram." + RollupField.COUNT_FIELD));
+ .subAggregation(new SumAggregationBuilder("histo." + COUNT_FIELD)
+ .field("timestamp.date_histogram." + COUNT_FIELD));
DateFieldMapper.Builder nrBuilder = new DateFieldMapper.Builder("histo");
DateFieldMapper.DateFieldType nrFTtimestamp = nrBuilder.fieldType();
@@ -1237,11 +1237,11 @@ public void testOverlappingBuckets() throws IOException {
rFTtimestamp.setHasDocValues(true);
rFTtimestamp.setName(rollupHisto.field());
- NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + RollupField.COUNT_FIELD,
+ NumberFieldMapper.Builder valueBuilder = new NumberFieldMapper.Builder("histo." + COUNT_FIELD,
NumberFieldMapper.NumberType.LONG);
MappedFieldType rFTvalue = valueBuilder.fieldType();
rFTvalue.setHasDocValues(true);
- rFTvalue.setName("timestamp.date_histogram." + RollupField.COUNT_FIELD);
+ rFTvalue.setName("timestamp.date_histogram." + COUNT_FIELD);
List responses = doQueries(new MatchAllDocsQuery(),
iw -> {
@@ -1277,15 +1277,15 @@ private Document timestampedValueDoc(long timestamp, long value) {
private Document timestampedValueRollupDoc(long timestamp, long value) {
Document doc = new Document();
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.TIMESTAMP, timestamp));
- doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + COUNT_FIELD, 1));
doc.add(new SortedNumericDocValuesField("timestamp.date_histogram." + RollupField.INTERVAL, 1));
doc.add(new SortedNumericDocValuesField("foo.avg." + RollupField.VALUE, value));
- doc.add(new SortedNumericDocValuesField("foo.avg." + RollupField.COUNT_FIELD, 3));
+ doc.add(new SortedNumericDocValuesField("foo.avg." + COUNT_FIELD, 3));
doc.add(new SortedNumericDocValuesField("foo.min." + RollupField.VALUE, value));
doc.add(new SortedNumericDocValuesField("foo.max." + RollupField.VALUE, value));
doc.add(new SortedNumericDocValuesField("foo.sum." + RollupField.VALUE, value));
doc.add(new SortedNumericDocValuesField("bar.histogram." + RollupField.VALUE, value));
- doc.add(new SortedNumericDocValuesField("bar.histogram." + RollupField.COUNT_FIELD, 1));
+ doc.add(new SortedNumericDocValuesField("bar.histogram." + COUNT_FIELD, 1));
doc.add(new SortedNumericDocValuesField("bar.histogram." + RollupField.INTERVAL, 1));
return doc;
}
@@ -1299,7 +1299,7 @@ private Document stringValueDoc(String stringValue) {
private Document stringValueRollupDoc(String stringValue, long docCount) {
Document doc = new Document();
doc.add(new SortedSetDocValuesField("stringfield.terms." + RollupField.VALUE, new BytesRef(stringValue)));
- doc.add(new SortedNumericDocValuesField("stringfield.terms." + RollupField.COUNT_FIELD, docCount));
+ doc.add(new SortedNumericDocValuesField("stringfield.terms." + COUNT_FIELD, docCount));
return doc;
}
@@ -1312,7 +1312,7 @@ private Document longValueDoc(Long longValue) {
private Document longValueRollupDoc(Long longValue, long docCount) {
Document doc = new Document();
doc.add(new SortedNumericDocValuesField("longfield.terms." + RollupField.VALUE, longValue));
- doc.add(new SortedNumericDocValuesField("longfield.terms." + RollupField.COUNT_FIELD, docCount));
+ doc.add(new SortedNumericDocValuesField("longfield.terms." + COUNT_FIELD, docCount));
return doc;
}
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java
index 9068bcfce36a4..f7c5b303edc91 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java
@@ -12,10 +12,10 @@
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.test.AbstractStreamableTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
import org.elasticsearch.xpack.core.rollup.action.RollableIndexCaps;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.mockito.Mockito;
import java.io.IOException;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java
index e9d5d6153b18c..c2cc770ab7e9b 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java
@@ -12,7 +12,7 @@
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.test.AbstractStreamableTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction;
import org.elasticsearch.xpack.core.rollup.action.RollableIndexCaps;
import org.mockito.Mockito;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobActionRequestTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobActionRequestTests.java
deleted file mode 100644
index 848bd5f13dd9e..0000000000000
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobActionRequestTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.xpack.rollup.action;
-
-
-import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.test.AbstractStreamableXContentTestCase;
-import org.elasticsearch.xpack.core.rollup.action.PutRollupJobAction.Request;
-import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.junit.Before;
-
-import java.io.IOException;
-
-public class PutJobActionRequestTests extends AbstractStreamableXContentTestCase {
-
- private String jobId;
-
- @Before
- public void setupJobID() {
- jobId = randomAlphaOfLengthBetween(1,10);
- }
-
- @Override
- protected Request createTestInstance() {
- return new Request(ConfigTestHelpers.randomRollupJobConfig(random(), jobId));
- }
-
- @Override
- protected boolean supportsUnknownFields() {
- return false;
- }
-
- @Override
- protected Request createBlankInstance() {
- return new Request();
- }
-
- @Override
- protected Request doParseInstance(final XContentParser parser) throws IOException {
- return Request.fromXContent(parser, jobId);
- }
-
-}
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java
index d9caad5147d41..ff9b5ce867ec2 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java
@@ -22,12 +22,12 @@
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.persistent.PersistentTasksService;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.action.PutRollupJobAction;
-import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
+import org.elasticsearch.xpack.core.rollup.job.RollupJob;
import org.elasticsearch.xpack.rollup.Rollup;
import org.mockito.ArgumentCaptor;
@@ -52,7 +52,7 @@ public class PutJobStateMachineTests extends ESTestCase {
public void testCreateIndexException() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Could not create index for rollup job [foo]"));
@@ -78,7 +78,7 @@ public void testCreateIndexException() {
public void testIndexAlreadyExists() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getCause().getMessage(), equalTo("Ending"));
@@ -110,7 +110,7 @@ public void testIndexAlreadyExists() {
public void testIndexMetaData() throws InterruptedException {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getCause().getMessage(), equalTo("Ending"));
@@ -153,7 +153,7 @@ public void testIndexMetaData() throws InterruptedException {
public void testGetMappingFails() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Could not update mappings for rollup job [foo]"));
@@ -177,7 +177,7 @@ public void testGetMappingFails() {
public void testNoMetadataInMapping() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Expected to find _meta key in mapping of rollup index ["
@@ -210,7 +210,7 @@ public void testNoMetadataInMapping() {
public void testNoMappingVersion() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Could not determine version of existing rollup metadata for index ["
@@ -247,7 +247,7 @@ public void testNoMappingVersion() {
public void testJobAlreadyInMapping() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Cannot create rollup job [foo] because job was previously created (existing metadata)."));
@@ -288,7 +288,7 @@ public void testAddJobToMapping() {
final RollupJobConfig config =
ConfigTestHelpers.randomRollupJobConfig(random(), ESTestCase.randomAlphaOfLength(10), "foo", "rollup_index_foo");
RollupJob job = new RollupJob(config, Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Ending"));
@@ -333,7 +333,7 @@ public void testAddJobToMapping() {
public void testTaskAlreadyExists() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Cannot create job [foo] because it has already been created (task exists)"));
@@ -356,7 +356,7 @@ public void testTaskAlreadyExists() {
public void testStartTask() {
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
- ActionListener testListener = ActionListener.wrap(response -> {
+ ActionListener testListener = ActionListener.wrap(response -> {
fail("Listener success should not have been triggered.");
}, e -> {
assertThat(e.getMessage(), equalTo("Ending"));
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutRollupJobRequestTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutRollupJobRequestTests.java
new file mode 100644
index 0000000000000..fc3d387b935e1
--- /dev/null
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutRollupJobRequestTests.java
@@ -0,0 +1,64 @@
+/*
+ * 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.xpack.rollup.action;
+
+
+import org.elasticsearch.action.ActionRequestValidationException;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.test.AbstractStreamableXContentTestCase;
+import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
+import org.junit.Before;
+
+import java.io.IOException;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+public class PutRollupJobRequestTests extends AbstractStreamableXContentTestCase {
+
+ private String jobId;
+
+ @Before
+ public void setupJobID() {
+ jobId = randomAlphaOfLengthBetween(1,10);
+ }
+
+ @Override
+ protected PutRollupJobRequest createTestInstance() {
+ return new PutRollupJobRequest(ConfigTestHelpers.randomRollupJobConfig(random(), jobId));
+ }
+
+ @Override
+ protected boolean supportsUnknownFields() {
+ return false;
+ }
+
+ @Override
+ protected PutRollupJobRequest createBlankInstance() {
+ return new PutRollupJobRequest();
+ }
+
+ @Override
+ protected PutRollupJobRequest doParseInstance(final XContentParser parser) throws IOException {
+ return PutRollupJobRequest.fromXContent(parser, jobId);
+ }
+
+ public void testValidate() {
+ PutRollupJobRequest request = new PutRollupJobRequest(null);
+ ActionRequestValidationException validation = request.validate();
+ assertThat(validation, is(notNullValue()));
+ assertThat(validation.validationErrors(), contains(is("configuration of the rollup job is missing")));
+ assertThat(validation.validationErrors().size(), is(1));
+
+ request = new PutRollupJobRequest();
+ validation = request.validate();
+ assertThat(validation, is(notNullValue()));
+ assertThat(validation.validationErrors(), contains(is("configuration of the rollup job is missing")));
+ assertThat(validation.validationErrors().size(), is(1));
+ }
+}
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutRollupJobResponseTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutRollupJobResponseTests.java
new file mode 100644
index 0000000000000..77666fd057c7c
--- /dev/null
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutRollupJobResponseTests.java
@@ -0,0 +1,43 @@
+/*
+ * 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.xpack.rollup.action;
+
+
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobResponse;
+import org.elasticsearch.test.AbstractStreamableXContentTestCase;
+import org.junit.Before;
+
+public class PutRollupJobResponseTests extends AbstractStreamableXContentTestCase {
+
+ private boolean acknowledged;
+
+ @Before
+ public void setupJobID() {
+ acknowledged = randomBoolean();
+ }
+
+ @Override
+ protected PutRollupJobResponse createTestInstance() {
+ return new PutRollupJobResponse(acknowledged);
+ }
+
+ @Override
+ protected boolean supportsUnknownFields() {
+ return false;
+ }
+
+ @Override
+ protected PutRollupJobResponse createBlankInstance() {
+ return new PutRollupJobResponse();
+ }
+
+ @Override
+ protected PutRollupJobResponse doParseInstance(final XContentParser parser) {
+ return PutRollupJobResponse.fromXContent(parser);
+ }
+
+}
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/RollupIndexCapsTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/RollupIndexCapsTests.java
index 78b1e1e0d2d0c..ef8480bae3bdc 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/RollupIndexCapsTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/RollupIndexCapsTests.java
@@ -9,7 +9,7 @@
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java
index 069e23e4093de..26142f9c83bdf 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java
@@ -27,6 +27,8 @@
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.indices.IndicesModule;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.aggregations.Aggregations;
@@ -45,13 +47,11 @@
import org.elasticsearch.search.suggest.SuggestBuilder;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.RollupJobCaps;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
-import org.elasticsearch.xpack.core.rollup.job.TermsGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.xpack.rollup.Rollup;
import org.hamcrest.core.IsEqual;
import org.joda.time.DateTimeZone;
@@ -70,8 +70,8 @@
import static java.util.Collections.emptyList;
import static java.util.Collections.singleton;
+import static org.elasticsearch.protocol.xpack.rollup.RollupField.COUNT_FIELD;
import static org.elasticsearch.xpack.core.rollup.ConfigTestHelpers.randomHistogramGroupConfig;
-import static org.elasticsearch.xpack.core.rollup.RollupField.COUNT_FIELD;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.mockito.Mockito.mock;
@@ -641,7 +641,7 @@ public void testRollupOnly() throws IOException {
InternalSum count = mock(InternalSum.class);
when(count.getValue()).thenReturn(2.0);
when(count.value()).thenReturn(2.0);
- when(count.getName()).thenReturn("foo." + RollupField.COUNT_FIELD);
+ when(count.getName()).thenReturn("foo." + COUNT_FIELD);
when(count.getMetaData()).thenReturn(null);
when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count);
@@ -758,7 +758,7 @@ public void testBoth() throws IOException {
InternalSum count = mock(InternalSum.class);
when(count.getValue()).thenReturn(2.0);
when(count.value()).thenReturn(2.0);
- when(count.getName()).thenReturn("foo." + RollupField.COUNT_FIELD);
+ when(count.getName()).thenReturn("foo." + COUNT_FIELD);
when(count.getMetaData()).thenReturn(null);
when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count);
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobActionTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobActionTests.java
new file mode 100644
index 0000000000000..53aa0f2e63eee
--- /dev/null
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobActionTests.java
@@ -0,0 +1,24 @@
+/*
+ * 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.xpack.rollup.action;
+
+import org.elasticsearch.protocol.xpack.rollup.PutRollupJobRequest;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
+import org.elasticsearch.test.ESTestCase;
+
+import static org.elasticsearch.xpack.core.rollup.ConfigTestHelpers.randomGroupConfig;
+import static org.hamcrest.Matchers.equalTo;
+
+public class TransportPutRollupJobActionTests extends ESTestCase {
+
+ public void testBadCron() {
+ final PutRollupJobRequest putRollupJobRequest =
+ new PutRollupJobRequest(new RollupJobConfig("_id", "index", "rollup", "0 * * *", 100, randomGroupConfig(random()), null, null));
+
+ Exception e = expectThrows(IllegalArgumentException.class, () -> TransportPutRollupJobAction.validate(putRollupJobRequest));
+ assertThat(e.getMessage(), equalTo("invalid cron expression [0 * * *]"));
+ }
+}
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportTaskHelperTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportTaskHelperTests.java
index a156585b609a7..ca0d66e2a309e 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportTaskHelperTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/TransportTaskHelperTests.java
@@ -9,7 +9,7 @@
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.tasks.TaskManager;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.elasticsearch.xpack.rollup.job.RollupJobTask;
import java.util.Collections;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/config/ConfigTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/config/ConfigTests.java
index 86891eda669fa..8b10273f37289 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/config/ConfigTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/config/ConfigTests.java
@@ -5,14 +5,14 @@
*/
package org.elasticsearch.xpack.rollup.config;
+import org.elasticsearch.protocol.xpack.rollup.job.HistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.HistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.TermsGroupConfig;
import org.joda.time.DateTimeZone;
import java.util.HashMap;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/IndexerUtilsTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/IndexerUtilsTests.java
index e8c66f7e8c118..0d1a04fda30e3 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/IndexerUtilsTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/IndexerUtilsTests.java
@@ -35,13 +35,13 @@
import org.elasticsearch.search.aggregations.metrics.avg.AvgAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.max.MaxAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.sum.SumAggregationBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.HistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.HistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
import org.elasticsearch.xpack.core.rollup.job.RollupJobStats;
-import org.elasticsearch.xpack.core.rollup.job.TermsGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.TermsGroupConfig;
import org.joda.time.DateTime;
import org.mockito.stubbing.Answer;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java
index 6d29ee9f9ba6d..af37856ea56e5 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java
@@ -48,12 +48,12 @@
import org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.job.DateHistogramGroupConfig;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.DateHistogramGroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
import org.elasticsearch.xpack.core.rollup.job.IndexerState;
-import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.MetricConfig;
import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Before;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerStateTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerStateTests.java
index 955dcbc2beb48..3a73621d30d48 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerStateTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerStateTests.java
@@ -21,11 +21,11 @@
import org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregation;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.RollupField;
-import org.elasticsearch.xpack.core.rollup.job.GroupConfig;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.job.GroupConfig;
import org.elasticsearch.xpack.core.rollup.job.IndexerState;
import org.elasticsearch.xpack.core.rollup.job.RollupJob;
-import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
import org.mockito.stubbing.Answer;
import java.io.IOException;
diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupJobTaskTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupJobTaskTests.java
index 13290f09e8eb8..c892188e30507 100644
--- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupJobTaskTests.java
+++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupJobTaskTests.java
@@ -20,7 +20,7 @@
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.RollupField;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.xpack.core.rollup.action.StartRollupJobAction;
import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction;
import org.elasticsearch.xpack.core.rollup.job.IndexerState;
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/PutRollupJobRequest.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/PutRollupJobRequest.java
new file mode 100644
index 0000000000000..3a1abcdbcf5f8
--- /dev/null
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/PutRollupJobRequest.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.elasticsearch.protocol.xpack.rollup;
+
+import org.elasticsearch.action.ActionRequestValidationException;
+import org.elasticsearch.action.IndicesRequest;
+import org.elasticsearch.action.ValidateActions;
+import org.elasticsearch.action.fieldcaps.FieldCapabilities;
+import org.elasticsearch.action.support.IndicesOptions;
+import org.elasticsearch.action.support.master.AcknowledgedRequest;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.common.xcontent.ToXContentObject;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.job.RollupJobConfig;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Objects;
+
+public class PutRollupJobRequest extends AcknowledgedRequest implements IndicesRequest, ToXContentObject {
+
+ private RollupJobConfig config;
+ private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false);
+
+ public PutRollupJobRequest(final RollupJobConfig config) {
+ this.config = config;
+ }
+
+ public PutRollupJobRequest() {
+ }
+
+ /**
+ * @return the configuration of the rollup job to create
+ */
+ public RollupJobConfig getConfig() {
+ return config;
+ }
+
+ /**
+ * Sets the configuration of the rollup job to create
+ * @param config the {@link RollupJobConfig}
+ */
+ public void setConfig(final RollupJobConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ public void readFrom(StreamInput in) throws IOException {
+ super.readFrom(in);
+ this.config = new RollupJobConfig(in);
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ super.writeTo(out);
+ this.config.writeTo(out);
+ }
+
+ @Override
+ public ActionRequestValidationException validate() {
+ ActionRequestValidationException validationException = null;
+ if (config == null) {
+ validationException = ValidateActions.addValidationError("configuration of the rollup job is missing", validationException);
+ }
+ return validationException;
+ }
+
+ public ActionRequestValidationException validateMappings(final Map> fieldCapsResponse) {
+ final ActionRequestValidationException validationException = new ActionRequestValidationException();
+ if (fieldCapsResponse.size() == 0) {
+ validationException.addValidationError("Could not find any fields in the index/index-pattern that were configured in job");
+ return validationException;
+ }
+ config.validateMappings(fieldCapsResponse, validationException);
+ if (validationException.validationErrors().size() > 0) {
+ return validationException;
+ }
+ return null;
+ }
+
+ @Override
+ public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
+ return config.toXContent(builder, params);
+ }
+
+ @Override
+ public String[] indices() {
+ return new String[]{this.config.getIndexPattern()};
+ }
+
+ @Override
+ public IndicesOptions indicesOptions() {
+ return indicesOptions;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(config, indicesOptions, timeout);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final PutRollupJobRequest other = (PutRollupJobRequest) obj;
+ return Objects.equals(config, other.config);
+ }
+
+ public static PutRollupJobRequest fromXContent(final XContentParser parser, final String id) throws IOException {
+ return new PutRollupJobRequest(RollupJobConfig.fromXContent(parser, id));
+ }
+}
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/PutRollupJobResponse.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/PutRollupJobResponse.java
new file mode 100644
index 0000000000000..a298cb20919c4
--- /dev/null
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/PutRollupJobResponse.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.elasticsearch.protocol.xpack.rollup;
+
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
+import org.elasticsearch.common.xcontent.XContentParser;
+
+public class PutRollupJobResponse extends AcknowledgedResponse {
+
+ public PutRollupJobResponse() {
+ super();
+ }
+
+ public PutRollupJobResponse(final boolean acknowledged) {
+ super(acknowledged);
+ }
+
+ public static PutRollupJobResponse fromXContent(final XContentParser parser) {
+ return new PutRollupJobResponse(parseAcknowledged(parser));
+ }
+}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/RollupField.java
similarity index 83%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/RollupField.java
index 134ce6c87b3f7..5f1958c7d6f02 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/RollupField.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup;
+package org.elasticsearch.protocol.xpack.rollup;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.index.mapper.NumberFieldMapper;
@@ -54,7 +67,7 @@ public class RollupField {
* @param extra The type of value this field is (VALUE, INTERVAL, etc)
* @return formatted field name
*/
- public static String formatFieldName(ValuesSourceAggregationBuilder source, String extra) {
+ public static String formatFieldName(ValuesSourceAggregationBuilder, ?> source, String extra) {
return source.field() + "." + source.getType() + "." + extra;
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfig.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/DateHistogramGroupConfig.java
similarity index 92%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfig.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/DateHistogramGroupConfig.java
index 77dfa1cbbb1c3..08dfb07e26dfb 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/DateHistogramGroupConfig.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/DateHistogramGroupConfig.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup.job;
+package org.elasticsearch.protocol.xpack.rollup.job;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
@@ -20,11 +33,11 @@
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.composite.DateHistogramValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import org.joda.time.DateTimeZone;
import java.io.IOException;
@@ -119,7 +132,7 @@ public DateHistogramGroupConfig(final String field,
}
}
- DateHistogramGroupConfig(final StreamInput in) throws IOException {
+ public DateHistogramGroupConfig(final StreamInput in) throws IOException {
interval = new DateHistogramInterval(in);
field = in.readString();
delay = in.readOptionalWriteable(DateHistogramInterval::new);
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/GroupConfig.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/GroupConfig.java
similarity index 87%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/GroupConfig.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/GroupConfig.java
index f7685f4e6143b..df267f8f89d96 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/GroupConfig.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/GroupConfig.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup.job;
+package org.elasticsearch.protocol.xpack.rollup.job;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
@@ -75,7 +88,7 @@ public GroupConfig(final DateHistogramGroupConfig dateHistogram,
this.terms = terms;
}
- GroupConfig(final StreamInput in) throws IOException {
+ public GroupConfig(final StreamInput in) throws IOException {
dateHistogram = new DateHistogramGroupConfig(in);
histogram = in.readOptionalWriteable(HistogramGroupConfig::new);
terms = in.readOptionalWriteable(TermsGroupConfig::new);
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfig.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/HistogramGroupConfig.java
similarity index 87%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfig.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/HistogramGroupConfig.java
index 0480050bf52f0..9d76b2bd52e04 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/HistogramGroupConfig.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/HistogramGroupConfig.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup.job;
+package org.elasticsearch.protocol.xpack.rollup.job;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
@@ -16,10 +29,10 @@
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.composite.HistogramValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import java.io.IOException;
import java.util.Arrays;
@@ -73,7 +86,7 @@ public HistogramGroupConfig(final long interval, final String... fields) {
this.fields = fields;
}
- HistogramGroupConfig(final StreamInput in) throws IOException {
+ public HistogramGroupConfig(final StreamInput in) throws IOException {
interval = in.readVLong();
fields = in.readStringArray();
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/MetricConfig.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/MetricConfig.java
similarity index 87%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/MetricConfig.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/MetricConfig.java
index cc673c4ed0d35..c5790b267d86d 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/MetricConfig.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/MetricConfig.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup.job;
+package org.elasticsearch.protocol.xpack.rollup.job;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
@@ -16,6 +29,7 @@
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.search.aggregations.metrics.avg.AvgAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.max.MaxAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.min.MinAggregationBuilder;
@@ -23,7 +37,6 @@
import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCountAggregationBuilder;
import org.elasticsearch.search.aggregations.support.ValueType;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import java.io.IOException;
import java.util.ArrayList;
@@ -93,7 +106,7 @@ public MetricConfig(final String field, final List metrics) {
this.metrics = metrics;
}
- MetricConfig(final StreamInput in) throws IOException {
+ public MetricConfig(final StreamInput in) throws IOException {
field = in.readString();
metrics = in.readList(StreamInput::readString);
}
@@ -116,14 +129,14 @@ public List getMetrics() {
* This returns a set of aggregation builders which represent the configured
* set of metrics. Used by the rollup indexer to iterate over historical data
*/
- public List toBuilders() {
+ public List> toBuilders() {
if (metrics.size() == 0) {
return Collections.emptyList();
}
- List aggs = new ArrayList<>(metrics.size());
+ List> aggs = new ArrayList<>(metrics.size());
for (String metric : metrics) {
- ValuesSourceAggregationBuilder.LeafOnly newBuilder;
+ ValuesSourceAggregationBuilder.LeafOnly, ?> newBuilder;
if (metric.equals(MIN.getPreferredName())) {
newBuilder = new MinAggregationBuilder(RollupField.formatFieldName(field, MinAggregationBuilder.NAME, RollupField.VALUE));
} else if (metric.equals(MAX.getPreferredName())) {
@@ -131,7 +144,7 @@ public List toBuilders() {
} else if (metric.equals(AVG.getPreferredName())) {
// Avgs are sum + count
newBuilder = new SumAggregationBuilder(RollupField.formatFieldName(field, AvgAggregationBuilder.NAME, RollupField.VALUE));
- ValuesSourceAggregationBuilder.LeafOnly countBuilder
+ ValuesSourceAggregationBuilder.LeafOnly, ?> countBuilder
= new ValueCountAggregationBuilder(
RollupField.formatFieldName(field, AvgAggregationBuilder.NAME, RollupField.COUNT_FIELD), ValueType.NUMERIC);
countBuilder.field(field);
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/RollupJobConfig.java
similarity index 92%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/RollupJobConfig.java
index 27461c62b6724..20669533189e9 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/RollupJobConfig.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup.job;
+package org.elasticsearch.protocol.xpack.rollup.job;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
@@ -20,7 +33,6 @@
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.xpack.core.scheduler.Cron;
import java.io.IOException;
import java.util.Collections;
@@ -116,10 +128,6 @@ public RollupJobConfig(final String id,
if (pageSize <= 0) {
throw new IllegalArgumentException("Page size is mandatory and must be a positive long");
}
- // Cron doesn't have a parse helper method to see if the cron is valid,
- // so just construct a temporary cron object and if the cron is bad, it'll
- // throw an exception
- Cron testCron = new Cron(cron);
if (groupConfig == null && (metricsConfig == null || metricsConfig.isEmpty())) {
throw new IllegalArgumentException("At least one grouping or metric must be configured");
}
@@ -222,7 +230,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
builder.endArray();
}
if (timeout != null) {
- builder.field(TIMEOUT, timeout);
+ builder.field(TIMEOUT, timeout.getStringRep());
}
builder.field(PAGE_SIZE, pageSize);
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfig.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/TermsGroupConfig.java
similarity index 86%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfig.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/TermsGroupConfig.java
index 32507d57f32b0..9ac640a087566 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/TermsGroupConfig.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/job/TermsGroupConfig.java
@@ -1,9 +1,22 @@
/*
- * 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.
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.elasticsearch.xpack.core.rollup.job;
+package org.elasticsearch.protocol.xpack.rollup.job;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
@@ -18,10 +31,10 @@
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.mapper.KeywordFieldMapper;
import org.elasticsearch.index.mapper.TextFieldMapper;
+import org.elasticsearch.protocol.xpack.rollup.RollupField;
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.composite.TermsValuesSourceBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupField;
import java.io.IOException;
import java.util.Arrays;
@@ -69,7 +82,7 @@ public TermsGroupConfig(final String... fields) {
this.fields = fields;
}
- TermsGroupConfig(StreamInput in) throws IOException {
+ public TermsGroupConfig(StreamInput in) throws IOException {
fields = in.readStringArray();
}
@@ -87,7 +100,7 @@ public String[] getFields() {
public List> toBuilders() {
return Arrays.stream(fields).map(f -> {
TermsValuesSourceBuilder vsBuilder
- = new TermsValuesSourceBuilder(RollupField.formatIndexerAggName(f, TermsAggregationBuilder.NAME));
+ = new TermsValuesSourceBuilder(RollupField.formatIndexerAggName(f, TermsAggregationBuilder.NAME));
vsBuilder.field(f);
vsBuilder.missingBucket(true);
return vsBuilder;
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/package-info.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/package-info.java
new file mode 100644
index 0000000000000..e3c42fa876b25
--- /dev/null
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/rollup/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Request and Response objects for the default distribution's Rollup
+ * APIs.
+ */
+package org.elasticsearch.protocol.xpack.rollup;