Skip to content

Commit 48d0d40

Browse files
committed
Merge branch 'master' into initial-search-phase-async-on-next
* master: Timed runnable should delegate to abstract runnable Expose adaptive replica selection stats in /_nodes/stats API Remove dangerous `ByteBufStreamInput` methods (elastic#27076) Blacklist Gradle 4.2 and above Remove duplicated test (elastic#27091) Update numbers to reflect 4-byte UTF-8-encoded characters (elastic#27083) test: avoid generating duplicate multiple fields (elastic#27080) Reduce the default number of cached queries. (elastic#26949) removed unused import ingest: date processor should not fail if timestamp is specified as json number
2 parents 8b406da + 7a792d2 commit 48d0d40

File tree

24 files changed

+466
-90
lines changed

24 files changed

+466
-90
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,19 @@ class BuildPlugin implements Plugin<Project> {
123123
}
124124
println " Random Testing Seed : ${project.testSeed}"
125125

126-
// enforce gradle version
127-
GradleVersion minGradle = GradleVersion.version('3.3')
128-
if (GradleVersion.current() < minGradle) {
126+
// enforce Gradle version
127+
final GradleVersion currentGradleVersion = GradleVersion.current();
128+
129+
final GradleVersion minGradle = GradleVersion.version('3.3')
130+
if (currentGradleVersion < minGradle) {
129131
throw new GradleException("${minGradle} or above is required to build elasticsearch")
130132
}
131133

134+
final GradleVersion maxGradle = GradleVersion.version('4.2')
135+
if (currentGradleVersion >= maxGradle) {
136+
throw new GradleException("${maxGradle} or above is not compatible with the elasticsearch build")
137+
}
138+
132139
// enforce Java version
133140
if (javaVersionEnum < minimumJava) {
134141
throw new GradleException("Java ${minimumJava} or above is required to build Elasticsearch")

core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.cluster.node.stats;
2121

22+
import org.elasticsearch.Version;
2223
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
2324
import org.elasticsearch.cluster.node.DiscoveryNode;
2425
import org.elasticsearch.common.Nullable;
@@ -36,6 +37,7 @@
3637
import org.elasticsearch.monitor.jvm.JvmStats;
3738
import org.elasticsearch.monitor.os.OsStats;
3839
import org.elasticsearch.monitor.process.ProcessStats;
40+
import org.elasticsearch.node.AdaptiveSelectionStats;
3941
import org.elasticsearch.script.ScriptStats;
4042
import org.elasticsearch.threadpool.ThreadPoolStats;
4143
import org.elasticsearch.transport.TransportStats;
@@ -86,6 +88,9 @@ public class NodeStats extends BaseNodeResponse implements ToXContentFragment {
8688
@Nullable
8789
private IngestStats ingestStats;
8890

91+
@Nullable
92+
private AdaptiveSelectionStats adaptiveSelectionStats;
93+
8994
NodeStats() {
9095
}
9196

@@ -95,7 +100,8 @@ public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats
95100
@Nullable AllCircuitBreakerStats breaker,
96101
@Nullable ScriptStats scriptStats,
97102
@Nullable DiscoveryStats discoveryStats,
98-
@Nullable IngestStats ingestStats) {
103+
@Nullable IngestStats ingestStats,
104+
@Nullable AdaptiveSelectionStats adaptiveSelectionStats) {
99105
super(node);
100106
this.timestamp = timestamp;
101107
this.indices = indices;
@@ -110,6 +116,7 @@ public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats
110116
this.scriptStats = scriptStats;
111117
this.discoveryStats = discoveryStats;
112118
this.ingestStats = ingestStats;
119+
this.adaptiveSelectionStats = adaptiveSelectionStats;
113120
}
114121

115122
public long getTimestamp() {
@@ -199,6 +206,11 @@ public IngestStats getIngestStats() {
199206
return ingestStats;
200207
}
201208

209+
@Nullable
210+
public AdaptiveSelectionStats getAdaptiveSelectionStats() {
211+
return adaptiveSelectionStats;
212+
}
213+
202214
public static NodeStats readNodeStats(StreamInput in) throws IOException {
203215
NodeStats nodeInfo = new NodeStats();
204216
nodeInfo.readFrom(in);
@@ -223,6 +235,11 @@ public void readFrom(StreamInput in) throws IOException {
223235
scriptStats = in.readOptionalWriteable(ScriptStats::new);
224236
discoveryStats = in.readOptionalWriteable(DiscoveryStats::new);
225237
ingestStats = in.readOptionalWriteable(IngestStats::new);
238+
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
239+
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
240+
} else {
241+
adaptiveSelectionStats = null;
242+
}
226243
}
227244

228245
@Override
@@ -246,6 +263,9 @@ public void writeTo(StreamOutput out) throws IOException {
246263
out.writeOptionalWriteable(scriptStats);
247264
out.writeOptionalWriteable(discoveryStats);
248265
out.writeOptionalWriteable(ingestStats);
266+
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
267+
out.writeOptionalWriteable(adaptiveSelectionStats);
268+
}
249269
}
250270

251271
@Override
@@ -306,6 +326,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
306326
if (getIngestStats() != null) {
307327
getIngestStats().toXContent(builder, params);
308328
}
329+
if (getAdaptiveSelectionStats() != null) {
330+
getAdaptiveSelectionStats().toXContent(builder, params);
331+
}
309332
return builder;
310333
}
311334
}

core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.cluster.node.stats;
2121

22+
import org.elasticsearch.Version;
2223
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
2324
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
2425
import org.elasticsearch.common.io.stream.StreamInput;
@@ -43,6 +44,7 @@ public class NodesStatsRequest extends BaseNodesRequest<NodesStatsRequest> {
4344
private boolean script;
4445
private boolean discovery;
4546
private boolean ingest;
47+
private boolean adaptiveSelection;
4648

4749
public NodesStatsRequest() {
4850
}
@@ -71,6 +73,7 @@ public NodesStatsRequest all() {
7173
this.script = true;
7274
this.discovery = true;
7375
this.ingest = true;
76+
this.adaptiveSelection = true;
7477
return this;
7578
}
7679

@@ -90,6 +93,7 @@ public NodesStatsRequest clear() {
9093
this.script = false;
9194
this.discovery = false;
9295
this.ingest = false;
96+
this.adaptiveSelection = false;
9397
return this;
9498
}
9599

@@ -265,6 +269,18 @@ public NodesStatsRequest ingest(boolean ingest) {
265269
return this;
266270
}
267271

272+
public boolean adaptiveSelection() {
273+
return adaptiveSelection;
274+
}
275+
276+
/**
277+
* Should adaptiveSelection statistics be returned.
278+
*/
279+
public NodesStatsRequest adaptiveSelection(boolean adaptiveSelection) {
280+
this.adaptiveSelection = adaptiveSelection;
281+
return this;
282+
}
283+
268284
@Override
269285
public void readFrom(StreamInput in) throws IOException {
270286
super.readFrom(in);
@@ -280,6 +296,11 @@ public void readFrom(StreamInput in) throws IOException {
280296
script = in.readBoolean();
281297
discovery = in.readBoolean();
282298
ingest = in.readBoolean();
299+
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
300+
adaptiveSelection = in.readBoolean();
301+
} else {
302+
adaptiveSelection = false;
303+
}
283304
}
284305

285306
@Override
@@ -297,5 +318,8 @@ public void writeTo(StreamOutput out) throws IOException {
297318
out.writeBoolean(script);
298319
out.writeBoolean(discovery);
299320
out.writeBoolean(ingest);
321+
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
322+
out.writeBoolean(adaptiveSelection);
323+
}
300324
}
301325
}

core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected NodeStats nodeOperation(NodeStatsRequest nodeStatsRequest) {
7373
NodesStatsRequest request = nodeStatsRequest.request;
7474
return nodeService.stats(request.indices(), request.os(), request.process(), request.jvm(), request.threadPool(),
7575
request.fs(), request.transport(), request.http(), request.breaker(), request.script(), request.discovery(),
76-
request.ingest());
76+
request.ingest(), request.adaptiveSelection());
7777
}
7878

7979
public static class NodeStatsRequest extends BaseNodeRequest {

core/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ protected ClusterStatsNodeResponse newNodeResponse() {
9292
@Override
9393
protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) {
9494
NodeInfo nodeInfo = nodeService.info(true, true, false, true, false, true, false, true, false, false);
95-
NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE, true, true, true, false, true, false, false, false, false, false, false);
95+
NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE,
96+
true, true, true, false, true, false, false, false, false, false, false, false);
9697
List<ShardStats> shardsStats = new ArrayList<>();
9798
for (IndexService indexService : indicesService) {
9899
for (IndexShard indexShard : indexService) {

core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
import java.io.IOException;
6262
import java.io.UncheckedIOException;
63+
import java.util.Collections;
6364
import java.util.HashMap;
6465
import java.util.Map;
6566
import java.util.function.BiFunction;
@@ -94,6 +95,10 @@ public SearchTransportService(Settings settings, TransportService transportServi
9495
this.responseWrapper = responseWrapper;
9596
}
9697

98+
public Map<String, Long> getClientConnections() {
99+
return Collections.unmodifiableMap(clientConnections);
100+
}
101+
97102
public void sendFreeContext(Transport.Connection connection, final long contextId, OriginalIndices originalIndices) {
98103
transportService.sendRequest(connection, FREE_CONTEXT_ACTION_NAME, new SearchFreeContextRequest(originalIndices, contextId),
99104
TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(new ActionListener<SearchFreeContextResponse>() {

core/src/main/java/org/elasticsearch/common/util/concurrent/TimedRunnable.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
* A class used to wrap a {@code Runnable} that allows capturing the time of the task since creation
2424
* through execution as well as only execution time.
2525
*/
26-
class TimedRunnable implements Runnable {
26+
class TimedRunnable extends AbstractRunnable {
2727
private final Runnable original;
2828
private final long creationTimeNanos;
2929
private long startTimeNanos;
3030
private long finishTimeNanos = -1;
3131

32-
TimedRunnable(Runnable original) {
32+
TimedRunnable(final Runnable original) {
3333
this.original = original;
3434
this.creationTimeNanos = System.nanoTime();
3535
}
3636

3737
@Override
38-
public void run() {
38+
public void doRun() {
3939
try {
4040
startTimeNanos = System.nanoTime();
4141
original.run();
@@ -44,6 +44,32 @@ public void run() {
4444
}
4545
}
4646

47+
@Override
48+
public void onRejection(final Exception e) {
49+
if (original instanceof AbstractRunnable) {
50+
((AbstractRunnable) original).onRejection(e);
51+
}
52+
}
53+
54+
@Override
55+
public void onAfter() {
56+
if (original instanceof AbstractRunnable) {
57+
((AbstractRunnable) original).onAfter();
58+
}
59+
}
60+
61+
@Override
62+
public void onFailure(final Exception e) {
63+
if (original instanceof AbstractRunnable) {
64+
((AbstractRunnable) original).onFailure(e);
65+
}
66+
}
67+
68+
@Override
69+
public boolean isForceExecution() {
70+
return original instanceof AbstractRunnable && ((AbstractRunnable) original).isForceExecution();
71+
}
72+
4773
/**
4874
* Return the time since this task was created until it finished running.
4975
* If the task is still running or has not yet been run, returns -1.
@@ -67,4 +93,5 @@ long getTotalExecutionNanos() {
6793
}
6894
return finishTimeNanos - startTimeNanos;
6995
}
96+
7097
}

core/src/main/java/org/elasticsearch/indices/IndicesQueryCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class IndicesQueryCache extends AbstractComponent implements QueryCache,
5353
public static final Setting<ByteSizeValue> INDICES_CACHE_QUERY_SIZE_SETTING =
5454
Setting.memorySizeSetting("indices.queries.cache.size", "10%", Property.NodeScope);
5555
public static final Setting<Integer> INDICES_CACHE_QUERY_COUNT_SETTING =
56-
Setting.intSetting("indices.queries.cache.count", 10000, 1, Property.NodeScope);
56+
Setting.intSetting("indices.queries.cache.count", 1000, 1, Property.NodeScope);
5757
// enables caching on all segments instead of only the larger ones, for testing only
5858
public static final Setting<Boolean> INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING =
5959
Setting.boolSetting("indices.queries.cache.all_segments", false, Property.NodeScope);

0 commit comments

Comments
 (0)