-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/runtime_fields
- Loading branch information
Showing
474 changed files
with
1,489 additions
and
892 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...t/java/org/elasticsearch/search/aggregations/metrics/CardinalityWithRequestBreakerIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.search.aggregations.metrics; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.ExceptionsHelper; | ||
import org.elasticsearch.action.index.IndexRequestBuilder; | ||
import org.elasticsearch.common.breaker.CircuitBreakingException; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService; | ||
import org.elasticsearch.search.aggregations.Aggregator; | ||
import org.elasticsearch.search.aggregations.BucketOrder; | ||
import org.elasticsearch.test.ESIntegTestCase; | ||
|
||
import java.util.Map; | ||
import java.util.stream.IntStream; | ||
|
||
import static org.elasticsearch.search.aggregations.AggregationBuilders.cardinality; | ||
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; | ||
|
||
public class CardinalityWithRequestBreakerIT extends ESIntegTestCase { | ||
|
||
/** | ||
* Test that searches using cardinality aggregations returns all request breaker memory. | ||
*/ | ||
public void testRequestBreaker() throws Exception { | ||
final String requestBreaker = randomIntBetween(1, 10000) + "kb"; | ||
logger.info("--> Using request breaker setting: {}", requestBreaker); | ||
|
||
indexRandom(true, IntStream.range(0, randomIntBetween(10, 1000)) | ||
.mapToObj(i -> | ||
client().prepareIndex("test").setId("id_" + i) | ||
.setSource(Map.of("field0", randomAlphaOfLength(5), "field1", randomAlphaOfLength(5))) | ||
).toArray(IndexRequestBuilder[]::new)); | ||
|
||
client().admin().cluster().prepareUpdateSettings() | ||
.setTransientSettings(Settings.builder().put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), | ||
requestBreaker)) | ||
.get(); | ||
|
||
try { | ||
client().prepareSearch("test") | ||
.addAggregation(terms("terms").field("field0.keyword") | ||
.collectMode(randomFrom(Aggregator.SubAggCollectionMode.values())) | ||
.order(BucketOrder.aggregation("cardinality", randomBoolean())) | ||
.subAggregation(cardinality("cardinality").precisionThreshold(randomLongBetween(1, 40000)).field("field1.keyword"))) | ||
.get(); | ||
} catch (ElasticsearchException e) { | ||
if (ExceptionsHelper.unwrap(e, CircuitBreakingException.class) == null) { | ||
throw e; | ||
} | ||
} | ||
|
||
client().admin().cluster().prepareUpdateSettings() | ||
.setTransientSettings(Settings.builder().putNull(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey())) | ||
.get(); | ||
|
||
// validation done by InternalTestCluster.ensureEstimatedStats() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.