Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class VagrantTestPlugin implements Plugin<Project> {
// Now we iterate over dependencies of the bats configuration. When a project dependency is found,
// we bring back its own archives, test files or test utils.
project.afterEvaluate {
project.configurations.bats.dependencies.findAll {it.configuration == BATS }.each { d ->
project.configurations.bats.dependencies.findAll {it.targetConfiguration == BATS }.each { d ->
if (d instanceof DefaultProjectDependency) {
DefaultProjectDependency externalBatsDependency = (DefaultProjectDependency) d
Project externalBatsProject = externalBatsDependency.dependencyProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ static List<BootstrapCheck> checks(final Settings settings) {
checks.add(new SystemCallFilterCheck(BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.get(settings)));
checks.add(new OnErrorCheck());
checks.add(new OnOutOfMemoryErrorCheck());
checks.add(new EarlyAccessCheck());
checks.add(new G1GCCheck());
return Collections.unmodifiableList(checks);
}
Expand Down Expand Up @@ -577,6 +578,34 @@ public String errorMessage() {

}

/**
* Bootstrap check for early-access builds from OpenJDK.
*/
static class EarlyAccessCheck implements BootstrapCheck {

@Override
public boolean check() {
return "Oracle Corporation".equals(jvmVendor()) && javaVersion().endsWith("-ea");
}

String jvmVendor() {
return Constants.JVM_VENDOR;
}

String javaVersion() {
return Constants.JAVA_VERSION;
}

@Override
public String errorMessage() {
return String.format(
Locale.ROOT,
"Java version [%s] is an early-access build, only use release builds",
javaVersion());
}

}

/**
* Bootstrap check for versions of HotSpot that are known to have issues that can lead to index corruption when G1GC is enabled.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,48 @@ private void runMightForkTest(
consumer.accept(e);
}

public void testEarlyAccessCheck() throws NodeValidationException {
final AtomicReference<String> javaVersion
= new AtomicReference<>(randomFrom("1.8.0_152-ea", "9-ea"));
final BootstrapChecks.EarlyAccessCheck eaCheck = new BootstrapChecks.EarlyAccessCheck() {

@Override
String jvmVendor() {
return "Oracle Corporation";
}

@Override
String javaVersion() {
return javaVersion.get();
}

};

final List<BootstrapCheck> checks = Collections.singletonList(eaCheck);
final NodeValidationException e = expectThrows(
NodeValidationException.class,
() -> {
BootstrapChecks.check(true, checks, "testEarlyAccessCheck");
});
assertThat(
e.getMessage(),
containsString(
"Java version ["
+ javaVersion.get()
+ "] is an early-access build, only use release builds"));

// if not on an early-access build, nothing should happen
javaVersion.set(randomFrom("1.8.0_152", "9"));
BootstrapChecks.check(true, checks, "testEarlyAccessCheck");

}

public void testG1GCCheck() throws NodeValidationException {
final AtomicBoolean isG1GCEnabled = new AtomicBoolean(true);
final AtomicBoolean isJava8 = new AtomicBoolean(true);
final AtomicReference<String> jvmVersion =
new AtomicReference<>(String.format(Locale.ROOT, "25.%d-b%d", randomIntBetween(0, 39), randomIntBetween(1, 128)));
final BootstrapChecks.G1GCCheck oracleCheck = new BootstrapChecks.G1GCCheck() {
final BootstrapChecks.G1GCCheck g1GCCheck = new BootstrapChecks.G1GCCheck() {

@Override
String jvmVendor() {
Expand All @@ -592,20 +628,20 @@ boolean isJava8() {
final NodeValidationException e =
expectThrows(
NodeValidationException.class,
() -> BootstrapChecks.check(true, Collections.singletonList(oracleCheck), "testG1GCCheck"));
() -> BootstrapChecks.check(true, Collections.singletonList(g1GCCheck), "testG1GCCheck"));
assertThat(
e.getMessage(),
containsString(
"JVM version [" + jvmVersion.get() + "] can cause data corruption when used with G1GC; upgrade to at least Java 8u40"));

// if G1GC is disabled, nothing should happen
isG1GCEnabled.set(false);
BootstrapChecks.check(true, Collections.singletonList(oracleCheck), "testG1GCCheck");
BootstrapChecks.check(true, Collections.singletonList(g1GCCheck), "testG1GCCheck");

// if on or after update 40, nothing should happen independent of whether or not G1GC is enabled
isG1GCEnabled.set(randomBoolean());
jvmVersion.set(String.format(Locale.ROOT, "25.%d-b%d", randomIntBetween(40, 112), randomIntBetween(1, 128)));
BootstrapChecks.check(true, Collections.singletonList(oracleCheck), "testG1GCCheck");
BootstrapChecks.check(true, Collections.singletonList(g1GCCheck), "testG1GCCheck");

final BootstrapChecks.G1GCCheck nonOracleCheck = new BootstrapChecks.G1GCCheck() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,61 @@ documents into buckets starting at 6am:
NOTE: The start `offset` of each bucket is calculated after the `time_zone`
adjustments have been made.

==== Keyed Response

Setting the `keyed` flag to `true` will associate a unique string key with each bucket and return the ranges as a hash rather than an array:

[source,js]
--------------------------------------------------
{
"aggs": {
"nyc_accident_histogram": {
"date_histogram": {
"field": "date",
"interval" : "year",
"keyed": true
}
}
}
}
--------------------------------------------------

Response:

[source,js]
--------------------------------------------------
{
...

"aggregations": {
"nyc_accident_histogram": {
"buckets": {
"2013-01-01T00:00:00.000Z": {
"key_as_string": "2013-01-01T00:00:00.000Z",
"key": 1356998400000,
"doc_count": 203733
},
"2014-01-01T00:00:00.000Z": {
"key_as_string": "2014-01-01T00:00:00.000Z",
"key": 1388534400000,
"doc_count": 205929
},
"2015-01-01T00:00:00.000Z": {
"key_as_string": "2015-01-01T00:00:00.000Z",
"key": 1420070400000,
"doc_count": 217637
},
"2016-01-01T00:00:00.000Z": {
"key_as_string": "2016-01-01T00:00:00.000Z",
"key": 1451606400000,
"doc_count": 227656
}
}
}
}
}
--------------------------------------------------

==== Scripts

Like with the normal <<search-aggregations-bucket-histogram-aggregation,histogram>>, both document level scripts and
Expand Down
88 changes: 88 additions & 0 deletions docs/reference/aggregations/bucket/daterange-aggregation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,91 @@ POST /sales/_search?size=0

<1> This date will be converted to `2016-02-15T00:00:00.000+01:00`.
<2> `now/d` will be rounded to the beginning of the day in the CET time zone.

==== Keyed Response

Setting the `keyed` flag to `true` will associate a unique string key with each bucket and return the ranges as a hash rather than an array:

[source,js]
--------------------------------------------------
{
"aggs" : {
"nyc_recent_accidents": {
"date_range": {
"field": "@timestamp",
"format": "MM-yyy",
"ranges": [
{ "from": "now-10M/d", "to": "now" }
],
"keyed": true
}
}
}
}
--------------------------------------------------

Response:

[source,js]
--------------------------------------------------
{
...

"aggregations": {
"nyc_recent_accidents": {
"buckets": {
"05-2016-03-2017": {
"from": 1464307200000,
"from_as_string": "05-2016",
"to": 1490604059606,
"to_as_string": "03-2017",
"doc_count": 185436
}
}
}
}
}
--------------------------------------------------

It is also possible to customize the key for each range:

[source,js]
--------------------------------------------------
{
"aggs" : {
"nyc_recent_accidents": {
"date_range": {
"field": "@timestamp",
"format": "MM-yyy",
"ranges": [
{ "from": "now-10M/d", "to": "now" }
],
"keyed": true
}
}
}
}
--------------------------------------------------

Response:

[source,js]
--------------------------------------------------
{
...

"aggregations": {
"nyc_recent_accidents": {
"buckets": {
"last-10M": {
"from": 1464307200000,
"from_as_string": "05-2016",
"to": 1490604059606,
"to_as_string": "03-2017",
"doc_count": 185436
}
}
}
}
}
--------------------------------------------------
108 changes: 108 additions & 0 deletions docs/reference/aggregations/bucket/geodistance-aggregation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,111 @@ There are two distance calculation modes: `arc` (the default), and `plane`. The
}
}
--------------------------------------------------

==== Keyed Response

Setting the `keyed` flag to `true` will associate a unique string key with each bucket and return the ranges as a hash rather than an array:

[source,js]
--------------------------------------------------
{
"aggs": {
"accidents_near_empire_state": {
"geo_distance": {
"field": "coords",
"unit": "km",
"origin" : { "lat" : 40.7484, "lon" : -73.9857 },
"ranges": [
{ "to": 3 },
{ "from" : 3, "to" : 8 },
{ "from" : 8 }
],
"keyed": true
}
}
}
}
--------------------------------------------------

Response:

[source,js]
--------------------------------------------------
{
...

"aggregations": {
"accidents_near_empire_state": {
"buckets": {
"*-3.0": {
"from": 0,
"to": 3,
"doc_count": 102090
},
"3.0-8.0": {
"from": 3,
"to": 8,
"doc_count": 170287
},
"8.0-*": {
"from": 8,
"doc_count": 526590
}
}
}
}
}
--------------------------------------------------

It is also possible to customize the key for each range:

[source,js]
--------------------------------------------------
{
"aggs": {
"accidents_near_empire_state": {
"geo_distance": {
"field": "coords",
"unit": "km",
"origin" : { "lat" : 40.7484, "lon" : -73.9857 },
"ranges": [
{ "key": "very-close", "to": 3 },
{ "key": "close", "from" : 3, "to" : 8 },
{ "key": "far", "from" : 8 }
],
"keyed": true
}
}
}
}
--------------------------------------------------

Response:

[source,js]
--------------------------------------------------
{
...

"aggregations": {
"accidents_near_empire_state": {
"buckets": {
"very-close": {
"from": 0,
"to": 3,
"doc_count": 102090
},
"close": {
"from": 3,
"to": 8,
"doc_count": 170287
},
"far": {
"from": 8,
"doc_count": 526590
}
}
}
}
}
--------------------------------------------------
Loading