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
index 3a9759e47a20e..fa36c02d02c22 100644
--- 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
@@ -28,6 +28,8 @@
import org.elasticsearch.client.rollup.GetRollupCapsResponse;
import org.elasticsearch.client.rollup.PutRollupJobRequest;
import org.elasticsearch.client.rollup.PutRollupJobResponse;
+import org.elasticsearch.client.rollup.StartRollupJobRequest;
+import org.elasticsearch.client.rollup.StartRollupJobResponse;
import java.io.IOException;
import java.util.Collections;
@@ -80,6 +82,40 @@ public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions option
listener, Collections.emptySet());
}
+ /**
+ * Start a rollup job
+ * 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 StartRollupJobResponse startRollupJob(StartRollupJobRequest request, RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(request,
+ RollupRequestConverters::startJob,
+ options,
+ StartRollupJobResponse::fromXContent,
+ Collections.emptySet());
+ }
+
+ /**
+ * Asynchronously start a rollup job
+ * 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 startRollupJobAsync(StartRollupJobRequest request, RequestOptions options,
+ ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(request,
+ RollupRequestConverters::startJob,
+ options,
+ StartRollupJobResponse::fromXContent,
+ listener, Collections.emptySet());
+ }
+
/**
* Delete a rollup job from the cluster
* See
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java
index 6b6a05ed03c65..f662d592d1a62 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java
@@ -20,11 +20,13 @@
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
-import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
+import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.PutRollupJobRequest;
+import org.elasticsearch.client.rollup.StartRollupJobRequest;
import java.io.IOException;
@@ -38,9 +40,7 @@ private RollupRequestConverters() {
static Request putJob(final PutRollupJobRequest putRollupJobRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("rollup")
- .addPathPartAsIs("job")
+ .addPathPartAsIs("_xpack", "rollup", "job")
.addPathPart(putRollupJobRequest.getConfig().getId())
.build();
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
@@ -48,11 +48,19 @@ static Request putJob(final PutRollupJobRequest putRollupJobRequest) throws IOEx
return request;
}
+ static Request startJob(final StartRollupJobRequest startRollupJobRequest) throws IOException {
+ String endpoint = new RequestConverters.EndpointBuilder()
+ .addPathPartAsIs("_xpack", "rollup", "job")
+ .addPathPart(startRollupJobRequest.getJobId())
+ .addPathPartAsIs("_start")
+ .build();
+ Request request = new Request(HttpPost.METHOD_NAME, endpoint);
+ return request;
+ }
+
static Request getJob(final GetRollupJobRequest getRollupJobRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("rollup")
- .addPathPartAsIs("job")
+ .addPathPartAsIs("_xpack", "rollup", "job")
.addPathPart(getRollupJobRequest.getJobId())
.build();
return new Request(HttpGet.METHOD_NAME, endpoint);
@@ -60,9 +68,7 @@ static Request getJob(final GetRollupJobRequest getRollupJobRequest) {
static Request deleteJob(final DeleteRollupJobRequest deleteRollupJobRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("rollup")
- .addPathPartAsIs("job")
+ .addPathPartAsIs("_xpack", "rollup", "job")
.addPathPart(deleteRollupJobRequest.getId())
.build();
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
@@ -72,9 +78,7 @@ static Request deleteJob(final DeleteRollupJobRequest deleteRollupJobRequest) th
static Request getRollupCaps(final GetRollupCapsRequest getRollupCapsRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("rollup")
- .addPathPartAsIs("data")
+ .addPathPartAsIs("_xpack", "rollup", "data")
.addPathPart(getRollupCapsRequest.getIndexPattern())
.build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/AcknowledgedResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/AcknowledgedResponse.java
index 29cd1787c704a..4e279844afc59 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/AcknowledgedResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/AcknowledgedResponse.java
@@ -19,14 +19,21 @@
package org.elasticsearch.client.rollup;
+import org.elasticsearch.common.ParseField;
+import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.Objects;
+import java.util.function.Function;
+
+import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
public abstract class AcknowledgedResponse implements ToXContentObject {
+
+ protected static final String PARSE_FIELD_NAME = "acknowledged";
private final boolean acknowledged;
public AcknowledgedResponse(final boolean acknowledged) {
@@ -37,6 +44,12 @@ public boolean isAcknowledged() {
return acknowledged;
}
+ protected static ConstructingObjectParser generateParser(String name, Function ctor, String parseField) {
+ ConstructingObjectParser p = new ConstructingObjectParser<>(name, true, args -> ctor.apply((boolean) args[0]));
+ p.declareBoolean(constructorArg(), new ParseField(parseField));
+ return p;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -58,10 +71,16 @@ public int hashCode() {
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject();
{
- builder.field("acknowledged", isAcknowledged());
+ builder.field(getFieldName(), isAcknowledged());
}
builder.endObject();
return builder;
}
+ /**
+ * @return the field name this response uses to output the acknowledged flag
+ */
+ protected String getFieldName() {
+ return PARSE_FIELD_NAME;
+ }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/DeleteRollupJobResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/DeleteRollupJobResponse.java
index f9d3025d38a4f..35734c4a8358a 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/DeleteRollupJobResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/DeleteRollupJobResponse.java
@@ -19,28 +19,21 @@
package org.elasticsearch.client.rollup;
-import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
-import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
-
public class DeleteRollupJobResponse extends AcknowledgedResponse {
public DeleteRollupJobResponse(boolean acknowledged) {
super(acknowledged);
}
+ private static final ConstructingObjectParser PARSER = AcknowledgedResponse
+ .generateParser("delete_rollup_job_response", DeleteRollupJobResponse::new, AcknowledgedResponse.PARSE_FIELD_NAME);
+
public static DeleteRollupJobResponse fromXContent(final XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}
-
- private static final ConstructingObjectParser PARSER
- = new ConstructingObjectParser<>("delete_rollup_job_response", true,
- args -> new DeleteRollupJobResponse((boolean) args[0]));
- static {
- PARSER.declareBoolean(constructorArg(), new ParseField("acknowledged"));
- }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/PutRollupJobResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/PutRollupJobResponse.java
index d991313bb5e62..31c656b033479 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/PutRollupJobResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/PutRollupJobResponse.java
@@ -18,28 +18,21 @@
*/
package org.elasticsearch.client.rollup;
-import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
-import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
-
public class PutRollupJobResponse extends AcknowledgedResponse {
-
public PutRollupJobResponse(boolean acknowledged) {
super(acknowledged);
}
+ private static final ConstructingObjectParser PARSER = AcknowledgedResponse
+ .generateParser("delete_rollup_job_response", PutRollupJobResponse::new, AcknowledgedResponse.PARSE_FIELD_NAME);
+
public static PutRollupJobResponse fromXContent(final XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}
-
- private static final ConstructingObjectParser PARSER
- = new ConstructingObjectParser<>("put_rollup_job_response", true, args -> new PutRollupJobResponse((boolean) args[0]));
- static {
- PARSER.declareBoolean(constructorArg(), new ParseField("acknowledged"));
- }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/StartRollupJobRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/StartRollupJobRequest.java
new file mode 100644
index 0000000000000..5b67d8c9e9d20
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/StartRollupJobRequest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.rollup;
+
+import org.elasticsearch.client.Validatable;
+
+import java.util.Objects;
+
+public class StartRollupJobRequest implements Validatable {
+
+ private final String jobId;
+
+ public StartRollupJobRequest(final String jobId) {
+ this.jobId = Objects.requireNonNull(jobId, "id parameter must not be null");
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ final StartRollupJobRequest that = (StartRollupJobRequest) o;
+ return Objects.equals(jobId, that.jobId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(jobId);
+ }
+}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/StartRollupJobResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/StartRollupJobResponse.java
new file mode 100644
index 0000000000000..b953901ce0c84
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/StartRollupJobResponse.java
@@ -0,0 +1,46 @@
+/*
+ * 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.rollup;
+
+import org.elasticsearch.common.xcontent.ConstructingObjectParser;
+import org.elasticsearch.common.xcontent.XContentParser;
+
+import java.io.IOException;
+
+public class StartRollupJobResponse extends AcknowledgedResponse {
+
+ private static final String PARSE_FIELD_NAME = "started";
+
+ private static final ConstructingObjectParser PARSER = AcknowledgedResponse
+ .generateParser("delete_rollup_job_response", StartRollupJobResponse::new, PARSE_FIELD_NAME);
+
+ public StartRollupJobResponse(boolean acknowledged) {
+ super(acknowledged);
+ }
+
+ public static StartRollupJobResponse fromXContent(final XContentParser parser) throws IOException {
+ return PARSER.parse(parser, null);
+ }
+
+ @Override
+ protected String getFieldName() {
+ return PARSE_FIELD_NAME;
+ }
+}
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
index 7a5f873d45cc7..ffe75bfc1b1c3 100644
--- 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
@@ -39,6 +39,8 @@
import org.elasticsearch.client.rollup.GetRollupJobResponse.JobWrapper;
import org.elasticsearch.client.rollup.PutRollupJobRequest;
import org.elasticsearch.client.rollup.PutRollupJobResponse;
+import org.elasticsearch.client.rollup.StartRollupJobRequest;
+import org.elasticsearch.client.rollup.StartRollupJobResponse;
import org.elasticsearch.client.rollup.RollableIndexCaps;
import org.elasticsearch.client.rollup.RollupJobCaps;
import org.elasticsearch.client.rollup.job.config.DateHistogramGroupConfig;
@@ -150,7 +152,7 @@ public void testDeleteRollupJob() throws Exception {
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);
+ execute(putRollupJobRequest, rollupClient::putRollupJob, rollupClient::putRollupJobAsync);
DeleteRollupJobRequest deleteRollupJobRequest = new DeleteRollupJobRequest(id);
DeleteRollupJobResponse deleteRollupJobResponse = highLevelClient().rollup()
.deleteRollupJob(deleteRollupJobRequest, RequestOptions.DEFAULT);
@@ -164,8 +166,7 @@ public void testDeleteMissingRollupJob() {
assertThat(responseException.status().getStatus(), is(404));
}
- @SuppressWarnings("unchecked")
- public void testPutAndGetRollupJob() throws Exception {
+ public void testPutStartAndGetRollupJob() throws Exception {
// 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));
@@ -178,9 +179,9 @@ public void testPutAndGetRollupJob() throws Exception {
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());
+ StartRollupJobRequest startRequest = new StartRollupJobRequest(id);
+ StartRollupJobResponse startResponse = execute(startRequest, rollupClient::startRollupJob, rollupClient::startRollupJobAsync);
+ assertTrue(startResponse.isAcknowledged());
assertBusy(() -> {
SearchResponse searchResponse = highLevelClient().search(new SearchRequest(rollupIndex), RequestOptions.DEFAULT);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupRequestConvertersTests.java
index df7b2bbfca19e..f9363c7a429db 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupRequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupRequestConvertersTests.java
@@ -20,17 +20,19 @@
package org.elasticsearch.client;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.PutRollupJobRequest;
+import org.elasticsearch.client.rollup.StartRollupJobRequest;
import org.elasticsearch.client.rollup.job.config.RollupJobConfig;
import org.elasticsearch.client.rollup.job.config.RollupJobConfigTests;
import org.elasticsearch.test.ESTestCase;
import java.io.IOException;
-import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class RollupRequestConvertersTests extends ESTestCase {
@@ -47,6 +49,18 @@ public void testPutJob() throws IOException {
RequestConvertersTests.assertToXContentBody(put, request.getEntity());
}
+ public void testStartJob() throws IOException {
+ String jobId = randomAlphaOfLength(5);
+
+ StartRollupJobRequest startJob = new StartRollupJobRequest(jobId);
+
+ Request request = RollupRequestConverters.startJob(startJob);
+ assertThat(request.getEndpoint(), equalTo("/_xpack/rollup/job/" + jobId + "/_start"));
+ assertThat(HttpPost.METHOD_NAME, equalTo(request.getMethod()));
+ assertThat(request.getParameters().keySet(), empty());
+ assertThat(request.getEntity(), nullValue());
+ }
+
public void testGetJob() {
boolean getAll = randomBoolean();
String job = getAll ? "_all" : RequestConvertersTests.randomIndicesNames(1, 1)[0];
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
index 86562297306b2..0a0ca9215c93d 100644
--- 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
@@ -33,6 +33,7 @@
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.RollupClient;
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
import org.elasticsearch.client.rollup.DeleteRollupJobResponse;
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
@@ -46,6 +47,8 @@
import org.elasticsearch.client.rollup.PutRollupJobResponse;
import org.elasticsearch.client.rollup.RollableIndexCaps;
import org.elasticsearch.client.rollup.RollupJobCaps;
+import org.elasticsearch.client.rollup.StartRollupJobRequest;
+import org.elasticsearch.client.rollup.StartRollupJobResponse;
import org.elasticsearch.client.rollup.job.config.DateHistogramGroupConfig;
import org.elasticsearch.client.rollup.job.config.GroupConfig;
import org.elasticsearch.client.rollup.job.config.HistogramGroupConfig;
@@ -186,6 +189,7 @@ public void onFailure(Exception e) {
}
}
+ @SuppressWarnings("unused")
public void testGetRollupJob() throws Exception {
testCreateRollupJob();
RestHighLevelClient client = highLevelClient();
@@ -236,6 +240,62 @@ public void onFailure(Exception e) {
assertTrue(latch.await(30L, TimeUnit.SECONDS));
}
+
+ @SuppressWarnings("unused")
+ public void testStartRollupJob() throws Exception {
+ testCreateRollupJob();
+ RestHighLevelClient client = highLevelClient();
+
+ String id = "job_1";
+ // tag::rollup-start-job-request
+ StartRollupJobRequest request = new StartRollupJobRequest(id); // <1>
+ // end::rollup-start-job-request
+
+
+ try {
+ // tag::rollup-start-job-execute
+ RollupClient rc = client.rollup();
+ StartRollupJobResponse response = rc.startRollupJob(request, RequestOptions.DEFAULT);
+ // end::rollup-start-job-execute
+
+ // tag::rollup-start-job-response
+ response.isAcknowledged(); // <1>
+ // end::rollup-start-job-response
+ } catch (Exception e) {
+ // Swallow any exception, this test does not test actually cancelling.
+ }
+
+ // tag::rollup-start-job-execute-listener
+ ActionListener listener = new ActionListener() {
+ @Override
+ public void onResponse(StartRollupJobResponse response) {
+ // <1>
+ }
+
+ @Override
+ public void onFailure(Exception e) {
+ // <2>
+ }
+ };
+ // end::rollup-start-job-execute-listener
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ listener = new LatchedActionListener<>(listener, latch);
+
+ // tag::rollup-start-job-execute-async
+ RollupClient rc = client.rollup();
+ rc.startRollupJobAsync(request, RequestOptions.DEFAULT, listener); // <1>
+ // end::rollup-start-job-execute-async
+
+ assertTrue(latch.await(30L, TimeUnit.SECONDS));
+
+ // stop job so it can correctly be deleted by the test teardown
+ // TODO Replace this with the Rollup Stop Job API
+ Response stoptResponse = client().performRequest(new Request("POST", "/_xpack/rollup/job/" + id + "/_stop"));
+ assertEquals(RestStatus.OK.getStatus(), stoptResponse.getStatusLine().getStatusCode());
+ }
+
+ @SuppressWarnings("unused")
public void testGetRollupCaps() throws Exception {
RestHighLevelClient client = highLevelClient();
@@ -329,6 +389,7 @@ public void testGetRollupCaps() throws Exception {
ActionListener listener = new ActionListener() {
@Override
public void onResponse(GetRollupCapsResponse response) {
+
// <1>
}
@@ -406,6 +467,7 @@ private void waitForPendingRollupTasks() throws Exception {
});
}
+ @SuppressWarnings("unused")
public void testDeleteRollupJob() throws Exception {
RestHighLevelClient client = highLevelClient();
@@ -450,4 +512,4 @@ public void onFailure(Exception e) {
assertTrue(latch.await(30L, TimeUnit.SECONDS));
}
-}
+}
\ No newline at end of file
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/StartRollupJobRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/StartRollupJobRequestTests.java
new file mode 100644
index 0000000000000..6a44bac0c159e
--- /dev/null
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/StartRollupJobRequestTests.java
@@ -0,0 +1,42 @@
+/*
+ * 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.rollup;
+
+import org.elasticsearch.test.ESTestCase;
+import org.elasticsearch.test.EqualsHashCodeTestUtils;
+
+public class StartRollupJobRequestTests extends ESTestCase {
+
+ public void testConstructor() {
+ String jobId = randomAlphaOfLength(5);
+ assertEquals(jobId, new StartRollupJobRequest(jobId).getJobId());
+ }
+
+ public void testEqualsAndHash() {
+ EqualsHashCodeTestUtils.checkEqualsAndHashCode(new StartRollupJobRequest(randomAlphaOfLength(5)),
+ orig -> new StartRollupJobRequest(orig.getJobId()),
+ orig -> new StartRollupJobRequest(orig.getJobId() + "_suffix"));
+ }
+
+ public void testRequireJobId() {
+ final NullPointerException e = expectThrows(NullPointerException.class, ()-> new StartRollupJobRequest(null));
+ assertEquals("id parameter must not be null", e.getMessage());
+ }
+
+}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/StartRollupJobResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/StartRollupJobResponseTests.java
new file mode 100644
index 0000000000000..724e60d2d4a75
--- /dev/null
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/StartRollupJobResponseTests.java
@@ -0,0 +1,51 @@
+/*
+ * 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.rollup;
+
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.test.AbstractXContentTestCase;
+import org.junit.Before;
+
+import java.io.IOException;
+
+public class StartRollupJobResponseTests extends AbstractXContentTestCase {
+
+ private boolean acknowledged;
+
+ @Before
+ public void setupAcknoledged() {
+ acknowledged = randomBoolean();
+ }
+
+ @Override
+ protected StartRollupJobResponse createTestInstance() {
+ return new StartRollupJobResponse(acknowledged);
+ }
+
+ @Override
+ protected StartRollupJobResponse doParseInstance(XContentParser parser) throws IOException {
+ return StartRollupJobResponse.fromXContent(parser);
+ }
+
+ @Override
+ protected boolean supportsUnknownFields() {
+ return false;
+ }
+
+}
diff --git a/docs/java-rest/high-level/rollup/start_job.asciidoc b/docs/java-rest/high-level/rollup/start_job.asciidoc
new file mode 100644
index 0000000000000..6d760dc0b33e6
--- /dev/null
+++ b/docs/java-rest/high-level/rollup/start_job.asciidoc
@@ -0,0 +1,34 @@
+--
+:api: rollup-start-job
+:request: StartRollupJobRequest
+:response: StartRollupJobResponse
+--
+
+[id="{upid}-{api}"]
+=== Start Rollup Job API
+
+[id="{upid}-{api}-request"]
+==== Request
+
+The Start Rollup Job API allows you to start a job by ID.
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests-file}[{api}-request]
+--------------------------------------------------
+<1> The ID of the job to start.
+
+[id="{upid}-{api}-response"]
+==== Response
+
+The returned +{response}+ indicates if the start command was received.
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests-file}[{api}-response]
+--------------------------------------------------
+<1> Whether or not the start job request was received.
+
+include::../execution.asciidoc[]
+
+
diff --git a/docs/java-rest/high-level/supported-apis.asciidoc b/docs/java-rest/high-level/supported-apis.asciidoc
index c8d16954abe2a..b9abcad3440fa 100644
--- a/docs/java-rest/high-level/supported-apis.asciidoc
+++ b/docs/java-rest/high-level/supported-apis.asciidoc
@@ -301,11 +301,13 @@ include::migration/get-assistance.asciidoc[]
The Java High Level REST Client supports the following Rollup APIs:
* <>
+* <<{upid}-rollup-start-job>>
* <<{upid}-rollup-delete-job>>
* <>
* <<{upid}-x-pack-rollup-get-rollup-caps>>
include::rollup/put_job.asciidoc[]
+include::rollup/start_job.asciidoc[]
include::rollup/delete_job.asciidoc[]
include::rollup/get_job.asciidoc[]
include::rollup/get_rollup_caps.asciidoc[]