Skip to content

Commit e429cd7

Browse files
committed
Merge remote-tracking branch 'es/7.x' into enrich-7.x
2 parents 8838bcc + b189596 commit e429cd7

File tree

367 files changed

+7326
-2055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

367 files changed

+7326
-2055
lines changed

TESTING.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ These are the linux flavors supported, all of which we provide images for
374374
* debian-9 aka stretch, the current debian stable distribution
375375
* centos-6
376376
* centos-7
377+
* rhel-8
377378
* fedora-28
378379
* fedora-29
379380
* oel-6 aka Oracle Enterprise Linux 6

Vagrantfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ Vagrant.configure(2) do |config|
127127
sles_common config, box
128128
end
129129
end
130+
'rhel-8'.tap do |box|
131+
config.vm.define box, define_opts do |config|
132+
config.vm.box = 'elastic/rhel-8-x86_64'
133+
rpm_common config, box
134+
end
135+
end
130136

131137
windows_2012r2_box = ENV['VAGRANT_WINDOWS_2012R2_BOX']
132138
if windows_2012r2_box && windows_2012r2_box.empty? == false

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class VagrantTestPlugin implements Plugin<Project> {
3030
'oel-6',
3131
'oel-7',
3232
'opensuse-42',
33+
'rhel-8',
3334
'sles-12',
3435
'ubuntu-1604',
3536
'ubuntu-1804'

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class ForbiddenPatternsTask extends DefaultTask {
6666
.exclude("**/*.zip")
6767
.exclude("**/*.jks")
6868
.exclude("**/*.crt")
69+
.exclude("**/*.keystore")
6970
.exclude("**/*.png");
7071

7172
/*

buildSrc/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
elasticsearch = 7.1.0
1+
elasticsearch = 7.2.0
22
lucene = 8.0.0
33

44
bundled_jdk = 12.0.1+12@69cfe15208a647278a19ef0990eea691
@@ -20,7 +20,7 @@ slf4j = 1.6.2
2020
# when updating the JNA version, also update the version in buildSrc/build.gradle
2121
jna = 4.5.1
2222

23-
netty = 4.1.32.Final
23+
netty = 4.1.35.Final
2424
joda = 2.10.1
2525

2626
# when updating this version, you need to ensure compatibility with:

client/rest-high-level/src/main/java/org/elasticsearch/client/dataframe/transforms/DataFrameTransformConfig.java

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ public static DataFrameTransformConfig forPreview(final SourceConfig source, fin
8787
return new DataFrameTransformConfig(null, source, null, pivotConfig, null);
8888
}
8989

90-
public DataFrameTransformConfig(final String id,
91-
final SourceConfig source,
92-
final DestConfig dest,
93-
final PivotConfig pivotConfig,
94-
final String description) {
90+
DataFrameTransformConfig(final String id,
91+
final SourceConfig source,
92+
final DestConfig dest,
93+
final PivotConfig pivotConfig,
94+
final String description) {
9595
this.id = id;
9696
this.source = source;
9797
this.dest = dest;
@@ -170,4 +170,46 @@ public int hashCode() {
170170
public String toString() {
171171
return Strings.toString(this, true, true);
172172
}
173+
174+
public static Builder builder() {
175+
return new Builder();
176+
}
177+
178+
public static class Builder {
179+
180+
private String id;
181+
private SourceConfig source;
182+
private DestConfig dest;
183+
private PivotConfig pivotConfig;
184+
private String description;
185+
186+
public Builder setId(String id) {
187+
this.id = id;
188+
return this;
189+
}
190+
191+
public Builder setSource(SourceConfig source) {
192+
this.source = source;
193+
return this;
194+
}
195+
196+
public Builder setDest(DestConfig dest) {
197+
this.dest = dest;
198+
return this;
199+
}
200+
201+
public Builder setPivotConfig(PivotConfig pivotConfig) {
202+
this.pivotConfig = pivotConfig;
203+
return this;
204+
}
205+
206+
public Builder setDescription(String description) {
207+
this.description = description;
208+
return this;
209+
}
210+
211+
public DataFrameTransformConfig build() {
212+
return new DataFrameTransformConfig(id, source, dest, pivotConfig, description);
213+
}
214+
}
173215
}

client/rest-high-level/src/main/java/org/elasticsearch/client/dataframe/transforms/SourceConfig.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2424
import org.elasticsearch.common.xcontent.ToXContentObject;
2525
import org.elasticsearch.common.xcontent.XContentBuilder;
26+
import org.elasticsearch.index.query.QueryBuilder;
2627

2728
import java.io.IOException;
2829
import java.util.Arrays;
@@ -76,7 +77,7 @@ public SourceConfig(String... index) {
7677
* @param index Any number of indices. At least one non-null, non-empty, index should be provided
7778
* @param queryConfig A QueryConfig object that contains the desired query. Defaults to MatchAll query.
7879
*/
79-
public SourceConfig(String[] index, QueryConfig queryConfig) {
80+
SourceConfig(String[] index, QueryConfig queryConfig) {
8081
this.index = index;
8182
this.queryConfig = queryConfig;
8283
}
@@ -121,4 +122,46 @@ public int hashCode(){
121122
int hash = Arrays.hashCode(index);
122123
return 31 * hash + (queryConfig == null ? 0 : queryConfig.hashCode());
123124
}
125+
126+
public static Builder builder() {
127+
return new Builder();
128+
}
129+
130+
public static class Builder {
131+
private String[] index;
132+
private QueryConfig queryConfig;
133+
134+
/**
135+
* Sets what indices from which to fetch data
136+
* @param index The indices from which to fetch data
137+
* @return The {@link Builder} with indices set
138+
*/
139+
public Builder setIndex(String... index) {
140+
this.index = index;
141+
return this;
142+
}
143+
144+
/**
145+
* Sets the {@link QueryConfig} object that references the desired query to use when fetching the data
146+
* @param queryConfig The {@link QueryConfig} to use when fetching data
147+
* @return The {@link Builder} with queryConfig set
148+
*/
149+
public Builder setQueryConfig(QueryConfig queryConfig) {
150+
this.queryConfig = queryConfig;
151+
return this;
152+
}
153+
154+
/**
155+
* Sets the query to use when fetching the data. Convenience method for {@link #setQueryConfig(QueryConfig)}
156+
* @param query The {@link QueryBuilder} to use when fetch data (overwrites the {@link QueryConfig})
157+
* @return The {@link Builder} with queryConfig set
158+
*/
159+
public Builder setQuery(QueryBuilder query) {
160+
return this.setQueryConfig(new QueryConfig(query));
161+
}
162+
163+
public SourceConfig build() {
164+
return new SourceConfig(index, queryConfig);
165+
}
166+
}
124167
}

client/rest-high-level/src/main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java

Lines changed: 115 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.client.dataframe.transforms.pivot;
2121

2222
import org.elasticsearch.common.ParseField;
23+
import org.elasticsearch.common.unit.TimeValue;
2324
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2425
import org.elasticsearch.common.xcontent.ObjectParser;
2526
import org.elasticsearch.common.xcontent.ToXContentObject;
@@ -34,51 +35,66 @@
3435

3536
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
3637

38+
/**
39+
* A grouping via a date histogram aggregation referencing a timefield
40+
*/
3741
public class DateHistogramGroupSource extends SingleGroupSource implements ToXContentObject {
3842

3943
private static final ParseField TIME_ZONE = new ParseField("time_zone");
4044
private static final ParseField FORMAT = new ParseField("format");
4145

4246
private static final ConstructingObjectParser<DateHistogramGroupSource, Void> PARSER =
43-
new ConstructingObjectParser<>("date_histogram_group_source", true, (args) -> new DateHistogramGroupSource((String) args[0]));
47+
new ConstructingObjectParser<>("date_histogram_group_source",
48+
true,
49+
(args) -> {
50+
String field = (String)args[0];
51+
long interval = 0;
52+
DateHistogramInterval dateHistogramInterval = null;
53+
if (args[1] instanceof Long) {
54+
interval = (Long)args[1];
55+
} else {
56+
dateHistogramInterval = (DateHistogramInterval) args[1];
57+
}
58+
ZoneId zoneId = (ZoneId) args[2];
59+
String format = (String) args[3];
60+
return new DateHistogramGroupSource(field, interval, dateHistogramInterval, format, zoneId);
61+
});
4462

4563
static {
4664
PARSER.declareString(optionalConstructorArg(), FIELD);
47-
PARSER.declareField((histogram, interval) -> {
48-
if (interval instanceof Long) {
49-
histogram.setInterval((long) interval);
50-
} else {
51-
histogram.setDateHistogramInterval((DateHistogramInterval) interval);
52-
}
53-
}, p -> {
65+
PARSER.declareField(optionalConstructorArg(), p -> {
5466
if (p.currentToken() == XContentParser.Token.VALUE_NUMBER) {
5567
return p.longValue();
5668
} else {
5769
return new DateHistogramInterval(p.text());
5870
}
5971
}, HistogramGroupSource.INTERVAL, ObjectParser.ValueType.LONG);
60-
PARSER.declareField(DateHistogramGroupSource::setTimeZone, p -> {
72+
PARSER.declareField(optionalConstructorArg(), p -> {
6173
if (p.currentToken() == XContentParser.Token.VALUE_STRING) {
6274
return ZoneId.of(p.text());
6375
} else {
6476
return ZoneOffset.ofHours(p.intValue());
6577
}
6678
}, TIME_ZONE, ObjectParser.ValueType.LONG);
6779

68-
PARSER.declareString(DateHistogramGroupSource::setFormat, FORMAT);
80+
PARSER.declareString(optionalConstructorArg(), FORMAT);
6981
}
7082

7183
public static DateHistogramGroupSource fromXContent(final XContentParser parser) {
7284
return PARSER.apply(parser, null);
7385
}
7486

75-
private long interval = 0;
76-
private DateHistogramInterval dateHistogramInterval;
77-
private String format;
78-
private ZoneId timeZone;
87+
private final long interval;
88+
private final DateHistogramInterval dateHistogramInterval;
89+
private final String format;
90+
private final ZoneId timeZone;
7991

80-
public DateHistogramGroupSource(String field) {
92+
DateHistogramGroupSource(String field, long interval, DateHistogramInterval dateHistogramInterval, String format, ZoneId timeZone) {
8193
super(field);
94+
this.interval = interval;
95+
this.dateHistogramInterval = dateHistogramInterval;
96+
this.format = format;
97+
this.timeZone = timeZone;
8298
}
8399

84100
@Override
@@ -90,40 +106,18 @@ public long getInterval() {
90106
return interval;
91107
}
92108

93-
public void setInterval(long interval) {
94-
if (interval < 1) {
95-
throw new IllegalArgumentException("[interval] must be greater than or equal to 1.");
96-
}
97-
this.interval = interval;
98-
}
99-
100109
public DateHistogramInterval getDateHistogramInterval() {
101110
return dateHistogramInterval;
102111
}
103112

104-
public void setDateHistogramInterval(DateHistogramInterval dateHistogramInterval) {
105-
if (dateHistogramInterval == null) {
106-
throw new IllegalArgumentException("[dateHistogramInterval] must not be null");
107-
}
108-
this.dateHistogramInterval = dateHistogramInterval;
109-
}
110-
111113
public String getFormat() {
112114
return format;
113115
}
114116

115-
public void setFormat(String format) {
116-
this.format = format;
117-
}
118-
119117
public ZoneId getTimeZone() {
120118
return timeZone;
121119
}
122120

123-
public void setTimeZone(ZoneId timeZone) {
124-
this.timeZone = timeZone;
125-
}
126-
127121
@Override
128122
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
129123
builder.startObject();
@@ -168,4 +162,88 @@ public boolean equals(Object other) {
168162
public int hashCode() {
169163
return Objects.hash(field, interval, dateHistogramInterval, timeZone, format);
170164
}
165+
166+
public static Builder builder() {
167+
return new Builder();
168+
}
169+
170+
public static class Builder {
171+
172+
private String field;
173+
private long interval = 0;
174+
private DateHistogramInterval dateHistogramInterval;
175+
private String format;
176+
private ZoneId timeZone;
177+
178+
/**
179+
* The field with which to construct the date histogram grouping
180+
* @param field The field name
181+
* @return The {@link Builder} with the field set.
182+
*/
183+
public Builder setField(String field) {
184+
this.field = field;
185+
return this;
186+
}
187+
188+
/**
189+
* Set the interval for the DateHistogram grouping
190+
* @param interval the time interval in milliseconds
191+
* @return the {@link Builder} with the interval set.
192+
*/
193+
public Builder setInterval(long interval) {
194+
if (interval < 1) {
195+
throw new IllegalArgumentException("[interval] must be greater than or equal to 1.");
196+
}
197+
this.interval = interval;
198+
return this;
199+
}
200+
201+
/**
202+
* Set the interval for the DateHistogram grouping
203+
* @param timeValue The time value to use as the interval
204+
* @return the {@link Builder} with the interval set.
205+
*/
206+
public Builder setInterval(TimeValue timeValue) {
207+
return setInterval(timeValue.getMillis());
208+
}
209+
210+
/**
211+
* Sets the interval of the DateHistogram grouping
212+
*
213+
* If this DateHistogramInterval is set, it supersedes the #{@link DateHistogramGroupSource#getInterval()}
214+
* @param dateHistogramInterval the DateHistogramInterval to set
215+
* @return The {@link Builder} with the dateHistogramInterval set.
216+
*/
217+
public Builder setDateHistgramInterval(DateHistogramInterval dateHistogramInterval) {
218+
if (dateHistogramInterval == null) {
219+
throw new IllegalArgumentException("[dateHistogramInterval] must not be null");
220+
}
221+
this.dateHistogramInterval = dateHistogramInterval;
222+
return this;
223+
}
224+
225+
/**
226+
* Set the optional String formatting for the time interval.
227+
* @param format The format of the output for the time interval key
228+
* @return The {@link Builder} with the format set.
229+
*/
230+
public Builder setFormat(String format) {
231+
this.format = format;
232+
return this;
233+
}
234+
235+
/**
236+
* Sets the time zone to use for this aggregation
237+
* @param timeZone The zoneId for the timeZone
238+
* @return The {@link Builder} with the timeZone set.
239+
*/
240+
public Builder setTimeZone(ZoneId timeZone) {
241+
this.timeZone = timeZone;
242+
return this;
243+
}
244+
245+
public DateHistogramGroupSource build() {
246+
return new DateHistogramGroupSource(field, interval, dateHistogramInterval, format, timeZone);
247+
}
248+
}
171249
}

0 commit comments

Comments
 (0)