mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-27 07:14:59 +00:00
wait for the allocation to be added before sending data
Original commit: elastic/x-pack-elasticsearch@504a75a2f2
This commit is contained in:
parent
02c755bfbe
commit
aa53e7177a
@ -245,7 +245,7 @@ public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.R
|
|||||||
|
|
||||||
public static class Response extends ActionResponse implements StatusToXContent {
|
public static class Response extends ActionResponse implements StatusToXContent {
|
||||||
|
|
||||||
static class JobInfo implements ToXContent, Writeable {
|
public static class JobInfo implements ToXContent, Writeable {
|
||||||
@Nullable
|
@Nullable
|
||||||
private Job jobConfig;
|
private Job jobConfig;
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -276,6 +276,26 @@ public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.R
|
|||||||
status = in.readOptionalWriteable(JobStatus::fromStream);
|
status = in.readOptionalWriteable(JobStatus::fromStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Job getJobConfig() {
|
||||||
|
return jobConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataCounts getDataCounts() {
|
||||||
|
return dataCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelSizeStats getModelSizeStats() {
|
||||||
|
return modelSizeStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SchedulerState getSchedulerState() {
|
||||||
|
return schedulerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
@ -13,6 +13,7 @@ import org.elasticsearch.plugins.Plugin;
|
|||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.xpack.prelert.PrelertPlugin;
|
import org.elasticsearch.xpack.prelert.PrelertPlugin;
|
||||||
|
import org.elasticsearch.xpack.prelert.action.GetJobsAction;
|
||||||
import org.elasticsearch.xpack.prelert.action.PostDataAction;
|
import org.elasticsearch.xpack.prelert.action.PostDataAction;
|
||||||
import org.elasticsearch.xpack.prelert.action.PutJobAction;
|
import org.elasticsearch.xpack.prelert.action.PutJobAction;
|
||||||
import org.elasticsearch.xpack.prelert.action.ScheduledJobsIT;
|
import org.elasticsearch.xpack.prelert.action.ScheduledJobsIT;
|
||||||
@ -20,10 +21,12 @@ import org.elasticsearch.xpack.prelert.job.AnalysisConfig;
|
|||||||
import org.elasticsearch.xpack.prelert.job.DataDescription;
|
import org.elasticsearch.xpack.prelert.job.DataDescription;
|
||||||
import org.elasticsearch.xpack.prelert.job.Detector;
|
import org.elasticsearch.xpack.prelert.job.Detector;
|
||||||
import org.elasticsearch.xpack.prelert.job.Job;
|
import org.elasticsearch.xpack.prelert.job.Job;
|
||||||
|
import org.elasticsearch.xpack.prelert.job.JobStatus;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
@ESIntegTestCase.ClusterScope(numDataNodes = 1)
|
@ESIntegTestCase.ClusterScope(numDataNodes = 1)
|
||||||
public class TooManyJobsIT extends ESIntegTestCase {
|
public class TooManyJobsIT extends ESIntegTestCase {
|
||||||
@ -51,6 +54,19 @@ public class TooManyJobsIT extends ESIntegTestCase {
|
|||||||
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true));
|
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true));
|
||||||
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
|
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
|
||||||
assertTrue(putJobResponse.isAcknowledged());
|
assertTrue(putJobResponse.isAcknowledged());
|
||||||
|
assertBusy(() -> {
|
||||||
|
try {
|
||||||
|
GetJobsAction.Request getJobRequest = new GetJobsAction.Request();
|
||||||
|
getJobRequest.setJobId(job.getId());
|
||||||
|
getJobRequest.status(true);
|
||||||
|
GetJobsAction.Response response = client().execute(GetJobsAction.INSTANCE, getJobRequest).get();
|
||||||
|
GetJobsAction.Response.JobInfo jobInfo = response.getResponse().results().get(0);
|
||||||
|
assertNotNull(jobInfo);
|
||||||
|
assertEquals(JobStatus.CLOSED, jobInfo.getStatus());
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("failure " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// triggers creating autodetect process:
|
// triggers creating autodetect process:
|
||||||
PostDataAction.Request postDataRequest = new PostDataAction.Request(job.getId());
|
PostDataAction.Request postDataRequest = new PostDataAction.Request(job.getId());
|
||||||
@ -60,8 +76,10 @@ public class TooManyJobsIT extends ESIntegTestCase {
|
|||||||
assertEquals(1, postDataResponse.getDataCounts().getInputRecordCount());
|
assertEquals(1, postDataResponse.getDataCounts().getInputRecordCount());
|
||||||
logger.info("Posted data {} times", i);
|
logger.info("Posted data {} times", i);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("Handling exception", e);
|
|
||||||
Throwable cause = ExceptionsHelper.unwrapCause(e.getCause());
|
Throwable cause = ExceptionsHelper.unwrapCause(e.getCause());
|
||||||
|
if (ElasticsearchStatusException.class.equals(cause.getClass()) == false) {
|
||||||
|
logger.warn("Unexpected cause", e);
|
||||||
|
}
|
||||||
assertEquals(ElasticsearchStatusException.class, cause.getClass());
|
assertEquals(ElasticsearchStatusException.class, cause.getClass());
|
||||||
assertEquals(RestStatus.TOO_MANY_REQUESTS, ((ElasticsearchStatusException) cause).status());
|
assertEquals(RestStatus.TOO_MANY_REQUESTS, ((ElasticsearchStatusException) cause).status());
|
||||||
logger.info("good news everybody --> reached threadpool capacity after starting {}th analytical process", i);
|
logger.info("good news everybody --> reached threadpool capacity after starting {}th analytical process", i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user