Skip to content

Commit c6d611b

Browse files
committed
Merge remote-tracking branch 'elastic/master' into geosql
2 parents d7647c8 + f4c12f0 commit c6d611b

File tree

109 files changed

+3721
-1312
lines changed

Some content is hidden

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

109 files changed

+3721
-1312
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.dataframe.transforms;
21+
22+
import org.elasticsearch.common.ParseField;
23+
import org.elasticsearch.common.io.stream.StreamInput;
24+
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
25+
import org.elasticsearch.common.xcontent.XContentParser;
26+
27+
import java.io.IOException;
28+
import java.util.Objects;
29+
30+
public class DataFrameTransformCheckpointStats {
31+
public static final ParseField TIMESTAMP_MILLIS = new ParseField("timestamp_millis");
32+
public static final ParseField TIME_UPPER_BOUND_MILLIS = new ParseField("time_upper_bound_millis");
33+
34+
public static DataFrameTransformCheckpointStats EMPTY = new DataFrameTransformCheckpointStats(0L, 0L);
35+
36+
private final long timestampMillis;
37+
private final long timeUpperBoundMillis;
38+
39+
public static final ConstructingObjectParser<DataFrameTransformCheckpointStats, Void> LENIENT_PARSER = new ConstructingObjectParser<>(
40+
"data_frame_transform_checkpoint_stats", true, args -> {
41+
long timestamp = args[0] == null ? 0L : (Long) args[0];
42+
long timeUpperBound = args[1] == null ? 0L : (Long) args[1];
43+
44+
return new DataFrameTransformCheckpointStats(timestamp, timeUpperBound);
45+
});
46+
47+
static {
48+
LENIENT_PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), TIMESTAMP_MILLIS);
49+
LENIENT_PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), TIME_UPPER_BOUND_MILLIS);
50+
}
51+
52+
public static DataFrameTransformCheckpointStats fromXContent(XContentParser parser) throws IOException {
53+
return LENIENT_PARSER.parse(parser, null);
54+
}
55+
56+
public DataFrameTransformCheckpointStats(final long timestampMillis, final long timeUpperBoundMillis) {
57+
this.timestampMillis = timestampMillis;
58+
this.timeUpperBoundMillis = timeUpperBoundMillis;
59+
}
60+
61+
public DataFrameTransformCheckpointStats(StreamInput in) throws IOException {
62+
this.timestampMillis = in.readLong();
63+
this.timeUpperBoundMillis = in.readLong();
64+
}
65+
66+
public long getTimestampMillis() {
67+
return timestampMillis;
68+
}
69+
70+
public long getTimeUpperBoundMillis() {
71+
return timeUpperBoundMillis;
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
return Objects.hash(timestampMillis, timeUpperBoundMillis);
77+
}
78+
79+
@Override
80+
public boolean equals(Object other) {
81+
if (this == other) {
82+
return true;
83+
}
84+
85+
if (other == null || getClass() != other.getClass()) {
86+
return false;
87+
}
88+
89+
DataFrameTransformCheckpointStats that = (DataFrameTransformCheckpointStats) other;
90+
91+
return this.timestampMillis == that.timestampMillis && this.timeUpperBoundMillis == that.timeUpperBoundMillis;
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.dataframe.transforms;
21+
22+
import org.elasticsearch.common.ParseField;
23+
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
24+
import org.elasticsearch.common.xcontent.XContentParser;
25+
26+
import java.util.Objects;
27+
28+
public class DataFrameTransformCheckpointingInfo {
29+
30+
public static final ParseField CURRENT_CHECKPOINT = new ParseField("current");
31+
public static final ParseField IN_PROGRESS_CHECKPOINT = new ParseField("in_progress");
32+
public static final ParseField OPERATIONS_BEHIND = new ParseField("operations_behind");
33+
34+
private final DataFrameTransformCheckpointStats current;
35+
private final DataFrameTransformCheckpointStats inProgress;
36+
private final long operationsBehind;
37+
38+
39+
private static final ConstructingObjectParser<DataFrameTransformCheckpointingInfo, Void> LENIENT_PARSER =
40+
new ConstructingObjectParser<>(
41+
"data_frame_transform_checkpointing_info", true, a -> {
42+
long behind = a[2] == null ? 0L : (Long) a[2];
43+
44+
return new DataFrameTransformCheckpointingInfo(
45+
a[0] == null ? DataFrameTransformCheckpointStats.EMPTY : (DataFrameTransformCheckpointStats) a[0],
46+
a[1] == null ? DataFrameTransformCheckpointStats.EMPTY : (DataFrameTransformCheckpointStats) a[1], behind);
47+
});
48+
49+
static {
50+
LENIENT_PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),
51+
(p, c) -> DataFrameTransformCheckpointStats.fromXContent(p), CURRENT_CHECKPOINT);
52+
LENIENT_PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),
53+
(p, c) -> DataFrameTransformCheckpointStats.fromXContent(p), IN_PROGRESS_CHECKPOINT);
54+
LENIENT_PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), OPERATIONS_BEHIND);
55+
}
56+
57+
public DataFrameTransformCheckpointingInfo(DataFrameTransformCheckpointStats current, DataFrameTransformCheckpointStats inProgress,
58+
long operationsBehind) {
59+
this.current = Objects.requireNonNull(current);
60+
this.inProgress = Objects.requireNonNull(inProgress);
61+
this.operationsBehind = operationsBehind;
62+
}
63+
64+
public DataFrameTransformCheckpointStats getCurrent() {
65+
return current;
66+
}
67+
68+
public DataFrameTransformCheckpointStats getInProgress() {
69+
return inProgress;
70+
}
71+
72+
public long getOperationsBehind() {
73+
return operationsBehind;
74+
}
75+
76+
public static DataFrameTransformCheckpointingInfo fromXContent(XContentParser p) {
77+
return LENIENT_PARSER.apply(p, null);
78+
}
79+
80+
@Override
81+
public int hashCode() {
82+
return Objects.hash(current, inProgress, operationsBehind);
83+
}
84+
85+
@Override
86+
public boolean equals(Object other) {
87+
if (this == other) {
88+
return true;
89+
}
90+
91+
if (other == null || getClass() != other.getClass()) {
92+
return false;
93+
}
94+
95+
DataFrameTransformCheckpointingInfo that = (DataFrameTransformCheckpointingInfo) other;
96+
97+
return Objects.equals(this.current, that.current) &&
98+
Objects.equals(this.inProgress, that.inProgress) &&
99+
this.operationsBehind == that.operationsBehind;
100+
}
101+
102+
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class DataFrameTransformState {
4242
private static final ParseField INDEXER_STATE = new ParseField("indexer_state");
4343
private static final ParseField TASK_STATE = new ParseField("task_state");
4444
private static final ParseField CURRENT_POSITION = new ParseField("current_position");
45-
private static final ParseField GENERATION = new ParseField("generation");
45+
private static final ParseField CHECKPOINT = new ParseField("checkpoint");
4646
private static final ParseField REASON = new ParseField("reason");
4747

4848
@SuppressWarnings("unchecked")
@@ -69,7 +69,7 @@ public class DataFrameTransformState {
6969
}
7070
throw new IllegalArgumentException("Unsupported token [" + p.currentToken() + "]");
7171
}, CURRENT_POSITION, ObjectParser.ValueType.VALUE_OBJECT_ARRAY);
72-
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), GENERATION);
72+
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), CHECKPOINT);
7373
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), REASON);
7474
}
7575

@@ -79,19 +79,19 @@ public static DataFrameTransformState fromXContent(XContentParser parser) throws
7979

8080
private final DataFrameTransformTaskState taskState;
8181
private final IndexerState indexerState;
82-
private final long generation;
82+
private final long checkpoint;
8383
private final SortedMap<String, Object> currentPosition;
8484
private final String reason;
8585

8686
public DataFrameTransformState(DataFrameTransformTaskState taskState,
8787
IndexerState indexerState,
8888
@Nullable Map<String, Object> position,
89-
long generation,
89+
long checkpoint,
9090
@Nullable String reason) {
9191
this.taskState = taskState;
9292
this.indexerState = indexerState;
9393
this.currentPosition = position == null ? null : Collections.unmodifiableSortedMap(new TreeMap<>(position));
94-
this.generation = generation;
94+
this.checkpoint = checkpoint;
9595
this.reason = reason;
9696
}
9797

@@ -108,8 +108,8 @@ public Map<String, Object> getPosition() {
108108
return currentPosition;
109109
}
110110

111-
public long getGeneration() {
112-
return generation;
111+
public long getCheckpoint() {
112+
return checkpoint;
113113
}
114114

115115
@Nullable
@@ -132,13 +132,13 @@ public boolean equals(Object other) {
132132
return Objects.equals(this.taskState, that.taskState) &&
133133
Objects.equals(this.indexerState, that.indexerState) &&
134134
Objects.equals(this.currentPosition, that.currentPosition) &&
135-
this.generation == that.generation &&
135+
this.checkpoint == that.checkpoint &&
136136
Objects.equals(this.reason, that.reason);
137137
}
138138

139139
@Override
140140
public int hashCode() {
141-
return Objects.hash(taskState, indexerState, currentPosition, generation, reason);
141+
return Objects.hash(taskState, indexerState, currentPosition, checkpoint, reason);
142142
}
143143

144144
}

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ public class DataFrameTransformStateAndStats {
3131
public static final ParseField ID = new ParseField("id");
3232
public static final ParseField STATE_FIELD = new ParseField("state");
3333
public static final ParseField STATS_FIELD = new ParseField("stats");
34+
public static final ParseField CHECKPOINTING_INFO_FIELD = new ParseField("checkpointing");
3435

3536
public static final ConstructingObjectParser<DataFrameTransformStateAndStats, Void> PARSER = new ConstructingObjectParser<>(
3637
"data_frame_transform_state_and_stats", true,
37-
a -> new DataFrameTransformStateAndStats((String) a[0], (DataFrameTransformState) a[1], (DataFrameIndexerTransformStats) a[2]));
38+
a -> new DataFrameTransformStateAndStats((String) a[0], (DataFrameTransformState) a[1], (DataFrameIndexerTransformStats) a[2],
39+
(DataFrameTransformCheckpointingInfo) a[3]));
3840

3941
static {
4042
PARSER.declareString(ConstructingObjectParser.constructorArg(), ID);
4143
PARSER.declareObject(ConstructingObjectParser.constructorArg(), DataFrameTransformState.PARSER::apply, STATE_FIELD);
4244
PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> DataFrameIndexerTransformStats.fromXContent(p),
4345
STATS_FIELD);
46+
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),
47+
(p, c) -> DataFrameTransformCheckpointingInfo.fromXContent(p), CHECKPOINTING_INFO_FIELD);
4448
}
4549

4650
public static DataFrameTransformStateAndStats fromXContent(XContentParser parser) throws IOException {
@@ -50,11 +54,14 @@ public static DataFrameTransformStateAndStats fromXContent(XContentParser parser
5054
private final String id;
5155
private final DataFrameTransformState transformState;
5256
private final DataFrameIndexerTransformStats transformStats;
57+
private final DataFrameTransformCheckpointingInfo checkpointingInfo;
5358

54-
public DataFrameTransformStateAndStats(String id, DataFrameTransformState state, DataFrameIndexerTransformStats stats) {
59+
public DataFrameTransformStateAndStats(String id, DataFrameTransformState state, DataFrameIndexerTransformStats stats,
60+
DataFrameTransformCheckpointingInfo checkpointingInfo) {
5561
this.id = id;
5662
this.transformState = state;
5763
this.transformStats = stats;
64+
this.checkpointingInfo = checkpointingInfo;
5865
}
5966

6067
public String getId() {
@@ -69,9 +76,13 @@ public DataFrameTransformState getTransformState() {
6976
return transformState;
7077
}
7178

79+
public DataFrameTransformCheckpointingInfo getCheckpointingInfo() {
80+
return checkpointingInfo;
81+
}
82+
7283
@Override
7384
public int hashCode() {
74-
return Objects.hash(id, transformState, transformStats);
85+
return Objects.hash(id, transformState, transformStats, checkpointingInfo);
7586
}
7687

7788
@Override
@@ -87,6 +98,7 @@ public boolean equals(Object other) {
8798
DataFrameTransformStateAndStats that = (DataFrameTransformStateAndStats) other;
8899

89100
return Objects.equals(this.id, that.id) && Objects.equals(this.transformState, that.transformState)
90-
&& Objects.equals(this.transformStats, that.transformStats);
101+
&& Objects.equals(this.transformStats, that.transformStats)
102+
&& Objects.equals(this.checkpointingInfo, that.checkpointingInfo);
91103
}
92104
}
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
/*
2-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License;
4-
* you may not use this file except in compliance with the Elastic License.
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
518
*/
6-
package org.elasticsearch.protocol;
19+
package org.elasticsearch.client;
720

821
import org.elasticsearch.common.io.stream.Streamable;
922
import org.elasticsearch.common.xcontent.ToXContent;
@@ -14,6 +27,11 @@
1427

1528
import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;
1629

30+
/**
31+
* @deprecated Use {@link AbstractResponseTestCase} instead of this class.
32+
*/
33+
// TODO: Remove and change subclasses to use AbstractResponseTestCase instead
34+
@Deprecated
1735
public abstract class AbstractHlrcStreamableXContentTestCase<T extends ToXContent & Streamable, H>
1836
extends AbstractStreamableXContentTestCase<T> {
1937

0 commit comments

Comments
 (0)