Fix compilation errors in ML integration tests

After elastic/elasticsearch#29109, the `needsReassignment` method has
been moved to the PersistentTasksClusterService. This commit fixes
some compilation in tests I introduced.

Original commit: elastic/x-pack-elasticsearch@b5bca2a191
This commit is contained in:
Tanguy Leroux 2018-03-19 09:46:52 +01:00
parent 83aae92353
commit c0be4d7055
2 changed files with 9 additions and 6 deletions

View File

@ -16,6 +16,8 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.AggregatorFactories;
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
@ -38,8 +40,6 @@ import org.elasticsearch.xpack.core.ml.job.config.Detector;
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.job.config.JobState;
import org.elasticsearch.xpack.core.ml.job.config.JobTaskStatus;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask;
import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase;
@ -50,6 +50,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.persistent.PersistentTasksClusterService.needsReassignment;
import static org.hamcrest.Matchers.hasEntry;
public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
@ -390,7 +391,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
if (hasExecutorNode) {
assertNotNull(task.getExecutorNode());
assertFalse(task.needsReassignment(clusterState.nodes()));
assertFalse(needsReassignment(task.getAssignment(), clusterState.nodes()));
DiscoveryNode node = clusterState.nodes().resolveNode(task.getExecutorNode());
assertThat(node.getAttributes(), hasEntry(MachineLearning.ML_ENABLED_NODE_ATTR, "true"));
assertThat(node.getAttributes(), hasEntry(MachineLearning.MAX_OPEN_JOBS_NODE_ATTR, "20"));

View File

@ -18,6 +18,8 @@ import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.xpack.core.ml.action.CloseJobAction;
import org.elasticsearch.xpack.core.ml.action.GetDatafeedsStatsAction;
@ -34,14 +36,14 @@ import org.elasticsearch.xpack.core.ml.datafeed.DatafeedState;
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.job.config.JobState;
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask;
import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase;
import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.persistent.PersistentTasksClusterService.needsReassignment;
public class MlDistributedFailureIT extends BaseMlIntegTestCase {
public void testFailOver() throws Exception {
@ -210,7 +212,7 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
assertNotNull(tasks);
assertEquals("Expected 2 tasks, but got [" + tasks.taskMap() + "]", 2, tasks.taskMap().size());
for (PersistentTask<?> task : tasks.tasks()) {
assertFalse(task.needsReassignment(clusterState.nodes()));
assertFalse(needsReassignment(task.getAssignment(), clusterState.nodes()));
}
GetJobsStatsAction.Request jobStatsRequest = new GetJobsStatsAction.Request(jobId);