[ML] Removed public constructors for testing.
Original commit: elastic/x-pack-elasticsearch@a5d45f2b66
This commit is contained in:
parent
c12d487c01
commit
3f5d9850ae
|
@ -262,24 +262,16 @@ public class StartDatafeedAction
|
||||||
private final String datafeedId;
|
private final String datafeedId;
|
||||||
private final long startTime;
|
private final long startTime;
|
||||||
private final Long endTime;
|
private final Long endTime;
|
||||||
private volatile DatafeedJobRunner datafeedJobRunner;
|
/* only pck protected for testing */
|
||||||
|
volatile DatafeedJobRunner datafeedJobRunner;
|
||||||
|
|
||||||
public DatafeedTask(long id, String type, String action, TaskId parentTaskId, Request request) {
|
DatafeedTask(long id, String type, String action, TaskId parentTaskId, Request request) {
|
||||||
super(id, type, action, "datafeed-" + request.getDatafeedId(), parentTaskId);
|
super(id, type, action, "datafeed-" + request.getDatafeedId(), parentTaskId);
|
||||||
this.datafeedId = request.getDatafeedId();
|
this.datafeedId = request.getDatafeedId();
|
||||||
this.startTime = request.getStartTime();
|
this.startTime = request.getStartTime();
|
||||||
this.endTime = request.getEndTime();
|
this.endTime = request.getEndTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only for testing */
|
|
||||||
public DatafeedTask(long id, String type, String action, TaskId parentTaskId, Request request, DatafeedJobRunner datafeedJobRunner) {
|
|
||||||
super(id, type, action, "datafeed-" + request.getDatafeedId(), parentTaskId);
|
|
||||||
this.datafeedId = request.getDatafeedId();
|
|
||||||
this.startTime = request.startTime;
|
|
||||||
this.endTime = request.endTime;
|
|
||||||
this.datafeedJobRunner = datafeedJobRunner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDatafeedId() {
|
public String getDatafeedId() {
|
||||||
return datafeedId;
|
return datafeedId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,11 @@ import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
|
import org.elasticsearch.tasks.TaskId;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.ml.MlMetadata;
|
import org.elasticsearch.xpack.ml.MlMetadata;
|
||||||
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.DatafeedJobRunnerTests;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedJobRunnerTests;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedState;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedState;
|
||||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||||
|
@ -194,4 +196,13 @@ public class StartDatafeedActionTests extends ESTestCase {
|
||||||
StartDatafeedAction.validate("datafeed_id", mlMetadata1, tasks, nodes);
|
StartDatafeedAction.validate("datafeed_id", mlMetadata1, tasks, nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StartDatafeedAction.DatafeedTask createDatafeedTask(long id, String type, String action,
|
||||||
|
TaskId parentTaskId,
|
||||||
|
StartDatafeedAction.Request request,
|
||||||
|
DatafeedJobRunner datafeedJobRunner) {
|
||||||
|
StartDatafeedAction.DatafeedTask task = new StartDatafeedAction.DatafeedTask(id, type, action, parentTaskId, request);
|
||||||
|
task.datafeedJobRunner = datafeedJobRunner;
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.xpack.ml.action.FlushJobAction;
|
||||||
import org.elasticsearch.xpack.ml.action.OpenJobAction;
|
import org.elasticsearch.xpack.ml.action.OpenJobAction;
|
||||||
import org.elasticsearch.xpack.ml.action.PostDataAction;
|
import org.elasticsearch.xpack.ml.action.PostDataAction;
|
||||||
import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
|
import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
|
||||||
|
import org.elasticsearch.xpack.ml.action.StartDatafeedActionTests;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractor;
|
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractor;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory;
|
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory;
|
||||||
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
|
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
|
||||||
|
@ -271,7 +272,7 @@ public class DatafeedJobRunnerTests extends ESTestCase {
|
||||||
Consumer<Exception> handler = mockConsumer();
|
Consumer<Exception> handler = mockConsumer();
|
||||||
boolean cancelled = randomBoolean();
|
boolean cancelled = randomBoolean();
|
||||||
StartDatafeedAction.Request startDatafeedRequest = new StartDatafeedAction.Request("datafeed_id", 0L);
|
StartDatafeedAction.Request startDatafeedRequest = new StartDatafeedAction.Request("datafeed_id", 0L);
|
||||||
StartDatafeedAction.DatafeedTask task = new StartDatafeedAction.DatafeedTask(1, "type", "action", null,
|
StartDatafeedAction.DatafeedTask task = StartDatafeedActionTests.createDatafeedTask(1, "type", "action", null,
|
||||||
startDatafeedRequest, datafeedJobRunner);
|
startDatafeedRequest, datafeedJobRunner);
|
||||||
datafeedJobRunner.run(task, handler);
|
datafeedJobRunner.run(task, handler);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue