Fixed timeout (de-)serialization for start and stop datafeeder and open job apis.
Original commit: elastic/x-pack-elasticsearch@be054db48c
This commit is contained in:
parent
5684caece0
commit
b636a4b829
|
@ -113,7 +113,7 @@ public class OpenJobAction extends Action<OpenJobAction.Request, OpenJobAction.R
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(jobId, ignoreDowntime);
|
return Objects.hash(jobId, ignoreDowntime, openTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,7 +126,8 @@ public class OpenJobAction extends Action<OpenJobAction.Request, OpenJobAction.R
|
||||||
}
|
}
|
||||||
OpenJobAction.Request other = (OpenJobAction.Request) obj;
|
OpenJobAction.Request other = (OpenJobAction.Request) obj;
|
||||||
return Objects.equals(jobId, other.jobId) &&
|
return Objects.equals(jobId, other.jobId) &&
|
||||||
Objects.equals(ignoreDowntime, other.ignoreDowntime);
|
Objects.equals(ignoreDowntime, other.ignoreDowntime) &&
|
||||||
|
Objects.equals(openTimeout, other.openTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.tasks.LoggingTaskListener;
|
import org.elasticsearch.tasks.LoggingTaskListener;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
|
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunner;
|
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||||
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunner;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedStatus;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedStatus;
|
||||||
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
|
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
|
||||||
import org.elasticsearch.xpack.ml.utils.DatafeedStatusObserver;
|
import org.elasticsearch.xpack.ml.utils.DatafeedStatusObserver;
|
||||||
|
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -152,13 +152,16 @@ public class StartDatafeedAction
|
||||||
if (endTime != null) {
|
if (endTime != null) {
|
||||||
builder.field(END_TIME.getPreferredName(), endTime);
|
builder.field(END_TIME.getPreferredName(), endTime);
|
||||||
}
|
}
|
||||||
|
if (startTimeout != null) {
|
||||||
|
builder.field(START_TIMEOUT.getPreferredName(), startTimeout.getStringRep());
|
||||||
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(datafeedId, startTime, endTime);
|
return Objects.hash(datafeedId, startTime, endTime, startTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,7 +175,8 @@ public class StartDatafeedAction
|
||||||
Request other = (Request) obj;
|
Request other = (Request) obj;
|
||||||
return Objects.equals(datafeedId, other.datafeedId) &&
|
return Objects.equals(datafeedId, other.datafeedId) &&
|
||||||
Objects.equals(startTime, other.startTime) &&
|
Objects.equals(startTime, other.startTime) &&
|
||||||
Objects.equals(endTime, other.endTime);
|
Objects.equals(endTime, other.endTime) &&
|
||||||
|
Objects.equals(startTimeout, other.startTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,13 @@ import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.tasks.TaskInfo;
|
import org.elasticsearch.tasks.TaskInfo;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
import org.elasticsearch.xpack.ml.job.messages.Messages;
|
|
||||||
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
|
|
||||||
import org.elasticsearch.xpack.ml.datafeed.Datafeed;
|
import org.elasticsearch.xpack.ml.datafeed.Datafeed;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedStatus;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedStatus;
|
||||||
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
|
import org.elasticsearch.xpack.ml.job.messages.Messages;
|
||||||
|
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
|
||||||
import org.elasticsearch.xpack.ml.utils.DatafeedStatusObserver;
|
import org.elasticsearch.xpack.ml.utils.DatafeedStatusObserver;
|
||||||
|
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -93,17 +93,19 @@ public class StopDatafeedAction
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
datafeedId = in.readString();
|
datafeedId = in.readString();
|
||||||
|
stopTimeout = TimeValue.timeValueMillis(in.readVLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
out.writeString(datafeedId);
|
out.writeString(datafeedId);
|
||||||
|
out.writeVLong(stopTimeout.millis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(datafeedId);
|
return Objects.hash(datafeedId, stopTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,7 +117,8 @@ public class StopDatafeedAction
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Request other = (Request) obj;
|
Request other = (Request) obj;
|
||||||
return Objects.equals(datafeedId, other.datafeedId);
|
return Objects.equals(datafeedId, other.datafeedId) &&
|
||||||
|
Objects.equals(stopTimeout, other.stopTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,19 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.action;
|
package org.elasticsearch.xpack.ml.action;
|
||||||
|
|
||||||
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.xpack.ml.action.CloseJobAction.Request;
|
import org.elasticsearch.xpack.ml.action.CloseJobAction.Request;
|
||||||
|
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
||||||
|
|
||||||
public class CloseJobActionRequestTests extends AbstractStreamableTestCase<Request> {
|
public class CloseJobActionRequestTests extends AbstractStreamableTestCase<Request> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createTestInstance() {
|
protected Request createTestInstance() {
|
||||||
return new Request(randomAsciiOfLengthBetween(1, 20));
|
Request request = new Request(randomAsciiOfLengthBetween(1, 20));
|
||||||
|
if (randomBoolean()) {
|
||||||
|
request.setCloseTimeout(TimeValue.timeValueMillis(randomNonNegativeLong()));
|
||||||
|
}
|
||||||
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.action;
|
package org.elasticsearch.xpack.ml.action;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.xpack.ml.action.OpenJobAction.Request;
|
import org.elasticsearch.xpack.ml.action.OpenJobAction.Request;
|
||||||
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
||||||
|
|
||||||
|
@ -12,7 +13,11 @@ public class OpenJobActionRequestTests extends AbstractStreamableTestCase<Reques
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createTestInstance() {
|
protected Request createTestInstance() {
|
||||||
return new Request(randomAsciiOfLengthBetween(1, 20));
|
Request request = new Request(randomAsciiOfLengthBetween(1, 20));
|
||||||
|
if (randomBoolean()) {
|
||||||
|
request.setOpenTimeout(TimeValue.timeValueMillis(randomNonNegativeLong()));
|
||||||
|
}
|
||||||
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.action;
|
package org.elasticsearch.xpack.ml.action;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.ml.action.StartDatafeedAction.Request;
|
import org.elasticsearch.xpack.ml.action.StartDatafeedAction.Request;
|
||||||
import org.elasticsearch.xpack.ml.support.AbstractStreamableXContentTestCase;
|
import org.elasticsearch.xpack.ml.support.AbstractStreamableXContentTestCase;
|
||||||
|
@ -17,6 +18,9 @@ public class StartDatafeedActionRequestTests extends AbstractStreamableXContentT
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
request.setEndTime(randomNonNegativeLong());
|
request.setEndTime(randomNonNegativeLong());
|
||||||
}
|
}
|
||||||
|
if (randomBoolean()) {
|
||||||
|
request.setStartTimeout(TimeValue.timeValueMillis(randomNonNegativeLong()));
|
||||||
|
}
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,14 @@ import org.elasticsearch.ElasticsearchStatusException;
|
||||||
import org.elasticsearch.ResourceNotFoundException;
|
import org.elasticsearch.ResourceNotFoundException;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.xpack.ml.action.StopDatafeedAction.Request;
|
import org.elasticsearch.xpack.ml.action.StopDatafeedAction.Request;
|
||||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
|
||||||
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
|
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedStatus;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedStatus;
|
||||||
|
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||||
|
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
|
||||||
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunnerTests.createDatafeedJob;
|
|
||||||
import static org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunnerTests.createDatafeedConfig;
|
import static org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunnerTests.createDatafeedConfig;
|
||||||
|
import static org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunnerTests.createDatafeedJob;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class StopDatafeedActionRequestTests extends AbstractStreamableTestCase<StopDatafeedAction.Request> {
|
public class StopDatafeedActionRequestTests extends AbstractStreamableTestCase<StopDatafeedAction.Request> {
|
||||||
|
@ -24,7 +24,9 @@ public class StopDatafeedActionRequestTests extends AbstractStreamableTestCase<S
|
||||||
@Override
|
@Override
|
||||||
protected Request createTestInstance() {
|
protected Request createTestInstance() {
|
||||||
Request r = new Request(randomAsciiOfLengthBetween(1, 20));
|
Request r = new Request(randomAsciiOfLengthBetween(1, 20));
|
||||||
r.setStopTimeout(TimeValue.timeValueSeconds(randomIntBetween(0, 999)));
|
if (randomBoolean()) {
|
||||||
|
r.setStopTimeout(TimeValue.timeValueMillis(randomNonNegativeLong()));
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue