This commit is contained in:
parent
9d05913c8a
commit
59d377462f
|
@ -36,12 +36,15 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class StartDataFrameAnalyticsAction extends ActionType<AcknowledgedResponse> {
|
||||
|
||||
public static final StartDataFrameAnalyticsAction INSTANCE = new StartDataFrameAnalyticsAction();
|
||||
public static final String NAME = "cluster:admin/xpack/ml/data_frame/analytics/start";
|
||||
|
||||
public static final TimeValue DEFAULT_TIMEOUT = new TimeValue(20, TimeUnit.SECONDS);
|
||||
|
||||
private StartDataFrameAnalyticsAction() {
|
||||
super(NAME, AcknowledgedResponse::new);
|
||||
}
|
||||
|
@ -69,7 +72,7 @@ public class StartDataFrameAnalyticsAction extends ActionType<AcknowledgedRespon
|
|||
}
|
||||
|
||||
private String id;
|
||||
private TimeValue timeout = TimeValue.timeValueSeconds(20);
|
||||
private TimeValue timeout = DEFAULT_TIMEOUT;
|
||||
|
||||
public Request(String id) {
|
||||
setId(id);
|
||||
|
|
|
@ -33,12 +33,15 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class StopDataFrameAnalyticsAction extends ActionType<StopDataFrameAnalyticsAction.Response> {
|
||||
|
||||
public static final StopDataFrameAnalyticsAction INSTANCE = new StopDataFrameAnalyticsAction();
|
||||
public static final String NAME = "cluster:admin/xpack/ml/data_frame/analytics/stop";
|
||||
|
||||
public static final TimeValue DEFAULT_TIMEOUT = new TimeValue(30, TimeUnit.SECONDS);
|
||||
|
||||
private StopDataFrameAnalyticsAction() {
|
||||
super(NAME, StopDataFrameAnalyticsAction.Response::new);
|
||||
}
|
||||
|
@ -75,6 +78,7 @@ public class StopDataFrameAnalyticsAction extends ActionType<StopDataFrameAnalyt
|
|||
private Set<String> expandedIds = Collections.emptySet();
|
||||
|
||||
public Request(String id) {
|
||||
this();
|
||||
setId(id);
|
||||
}
|
||||
|
||||
|
@ -86,7 +90,9 @@ public class StopDataFrameAnalyticsAction extends ActionType<StopDataFrameAnalyt
|
|||
expandedIds = new HashSet<>(Arrays.asList(in.readStringArray()));
|
||||
}
|
||||
|
||||
public Request() {}
|
||||
public Request() {
|
||||
setTimeout(DEFAULT_TIMEOUT);
|
||||
}
|
||||
|
||||
public final void setId(String id) {
|
||||
this.id = ExceptionsHelper.requireNonNull(id, DataFrameAnalyticsConfig.ID);
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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.core.ml.action;
|
||||
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.core.ml.action.DeleteDataFrameAnalyticsAction.Request;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class DeleteDataFrameAnalyticsActionRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
|
||||
@Override
|
||||
protected Request createTestInstance() {
|
||||
Request request = new Request(randomAlphaOfLength(10));
|
||||
request.setForce(randomBoolean());
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
|
||||
public void testDefaultTimeout() {
|
||||
assertThat(createTestInstance().timeout(), is(notNullValue()));
|
||||
}
|
||||
}
|
|
@ -109,4 +109,8 @@ public class PutDataFrameAnalyticsActionRequestTests extends AbstractSerializing
|
|||
|
||||
assertThat(e, is(nullValue()));
|
||||
}
|
||||
|
||||
public void testDefaultTimeout() {
|
||||
assertThat(createTestInstance().timeout(), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,16 @@ package org.elasticsearch.xpack.core.ml.action;
|
|||
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.core.ml.action.StartDataFrameAnalyticsAction.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class StartDataFrameAnalyticsRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
|
||||
@Override
|
||||
|
@ -25,4 +32,15 @@ public class StartDataFrameAnalyticsRequestTests extends AbstractWireSerializing
|
|||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
|
||||
public void testDefaultTimeout() throws IOException {
|
||||
{
|
||||
Request request = new Request("foo");
|
||||
assertThat(request.getTimeout(), is(notNullValue()));
|
||||
}
|
||||
try (XContentParser parser = createParser(JsonXContent.jsonXContent, "{}")) {
|
||||
Request request = Request.parseRequest("foo", parser);
|
||||
assertThat(request.getTimeout(), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,18 @@ package org.elasticsearch.xpack.core.ml.action;
|
|||
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.core.ml.action.StopDataFrameAnalyticsAction.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class StopDataFrameAnalyticsRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
|
||||
@Override
|
||||
|
@ -40,4 +46,15 @@ public class StopDataFrameAnalyticsRequestTests extends AbstractWireSerializingT
|
|||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
|
||||
public void testDefaultTimeout() throws IOException {
|
||||
{
|
||||
Request request = new Request("foo");
|
||||
assertThat(request.getTimeout(), is(notNullValue()));
|
||||
}
|
||||
try (XContentParser parser = createParser(JsonXContent.jsonXContent, "{}")) {
|
||||
Request request = Request.parseRequest("foo", parser);
|
||||
assertThat(request.getTimeout(), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue