[ML] Slightly adjust JobProvider#getAutodetectParams(...)
Original commit: elastic/x-pack-elasticsearch@2aaf618d78
This commit is contained in:
parent
00a5759d54
commit
cbbc3cfe20
|
@ -260,13 +260,10 @@ public class JobProvider {
|
||||||
|
|
||||||
msearch.execute(ActionListener.wrap(
|
msearch.execute(ActionListener.wrap(
|
||||||
response -> {
|
response -> {
|
||||||
for (MultiSearchResponse.Item itemResponse : response.getResponses()) {
|
for (int i = 0; i < response.getResponses().length; i++) {
|
||||||
|
MultiSearchResponse.Item itemResponse = response.getResponses()[i];
|
||||||
if (itemResponse.isFailure()) {
|
if (itemResponse.isFailure()) {
|
||||||
if (itemResponse.getFailure() instanceof IndexNotFoundException == false) {
|
errorHandler.accept(itemResponse.getFailure());
|
||||||
throw itemResponse.getFailure();
|
|
||||||
} else {
|
|
||||||
// Ignore IndexNotFoundException; AutodetectParamsBuilder has defaults for new jobs
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
SearchResponse searchResponse = itemResponse.getResponse();
|
SearchResponse searchResponse = itemResponse.getResponse();
|
||||||
ShardSearchFailure[] shardFailures = searchResponse.getShardFailures();
|
ShardSearchFailure[] shardFailures = searchResponse.getShardFailures();
|
||||||
|
@ -280,12 +277,16 @@ public class JobProvider {
|
||||||
errorHandler.accept(new ElasticsearchException("[" + jobId
|
errorHandler.accept(new ElasticsearchException("[" + jobId
|
||||||
+ "] Search request encountered [" + unavailableShards + "] unavailable shards"));
|
+ "] Search request encountered [" + unavailableShards + "] unavailable shards"));
|
||||||
} else {
|
} else {
|
||||||
SearchHit[] hits = searchResponse.getHits().getHits();
|
SearchHits hits = searchResponse.getHits();
|
||||||
if (hits.length == 1) {
|
long totalHits = hits.getTotalHits();
|
||||||
parseAutodetectParamSearchHit(paramsBuilder, hits[0], errorHandler);
|
if (totalHits == 0) {
|
||||||
} else if (hits.length > 1) {
|
SearchRequest searchRequest = msearch.request().requests().get(i);
|
||||||
errorHandler.accept(new IllegalStateException("Got ["
|
LOGGER.debug("Found 0 hits for [{}/{}]", searchRequest.indices(), searchRequest.types());
|
||||||
+ hits.length + "] even though search size was 1"));
|
} else if (totalHits == 1) {
|
||||||
|
parseAutodetectParamSearchHit(paramsBuilder, hits.getAt(0), errorHandler);
|
||||||
|
} else if (totalHits > 1) {
|
||||||
|
errorHandler.accept(new IllegalStateException("Expected total hits 0 or 1, but got [" + totalHits +
|
||||||
|
"] total hits"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,6 +299,7 @@ public class JobProvider {
|
||||||
|
|
||||||
private SearchRequestBuilder createDocIdSearch(String index, String type, String id) {
|
private SearchRequestBuilder createDocIdSearch(String index, String type, String id) {
|
||||||
return client.prepareSearch(index).setSize(1)
|
return client.prepareSearch(index).setSize(1)
|
||||||
|
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||||
.setQuery(QueryBuilders.idsQuery(type).addIds(id))
|
.setQuery(QueryBuilders.idsQuery(type).addIds(id))
|
||||||
.setRouting(id);
|
.setRouting(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,8 @@ import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@TestLogging("org.elasticsearch.xpack.ml.datafeed:DEBUG,org.elasticsearch.xpack.ml.action:DEBUG")
|
@TestLogging("org.elasticsearch.xpack.ml.datafeed:DEBUG,org.elasticsearch.xpack.ml.action:DEBUG," +
|
||||||
|
"org.elasticsearch.xpack.ml.job.persistence:DEBUG")
|
||||||
public class MlDistributedFailureIT extends BaseMlIntegTestCase {
|
public class MlDistributedFailureIT extends BaseMlIntegTestCase {
|
||||||
|
|
||||||
public void testFailOver() throws Exception {
|
public void testFailOver() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue