Skip to content

Commit 5fa66cd

Browse files
committed
Node Stats: Allow to explicitly get specific indices level node stats element
closes elastic#2871
1 parent 15d7ae5 commit 5fa66cd

File tree

11 files changed

+528
-254
lines changed

11 files changed

+528
-254
lines changed

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

Lines changed: 18 additions & 11 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.action.admin.indices.stats.CommonStatsFlags;
2223
import org.elasticsearch.action.support.nodes.NodesOperationRequest;
2324
import org.elasticsearch.common.io.stream.StreamInput;
2425
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -30,7 +31,7 @@
3031
*/
3132
public class NodesStatsRequest extends NodesOperationRequest<NodesStatsRequest> {
3233

33-
private boolean indices = true;
34+
private CommonStatsFlags indices = new CommonStatsFlags();
3435
private boolean os;
3536
private boolean process;
3637
private boolean jvm;
@@ -55,7 +56,7 @@ public NodesStatsRequest(String... nodesIds) {
5556
* Sets all the request flags.
5657
*/
5758
public NodesStatsRequest all() {
58-
this.indices = true;
59+
this.indices.all();
5960
this.os = true;
6061
this.process = true;
6162
this.jvm = true;
@@ -71,7 +72,7 @@ public NodesStatsRequest all() {
7172
* Clears all the request flags.
7273
*/
7374
public NodesStatsRequest clear() {
74-
this.indices = false;
75+
this.indices.clear();
7576
this.os = false;
7677
this.process = false;
7778
this.jvm = false;
@@ -83,18 +84,24 @@ public NodesStatsRequest clear() {
8384
return this;
8485
}
8586

86-
/**
87-
* Should indices stats be returned.
88-
*/
89-
public boolean indices() {
90-
return this.indices;
87+
public CommonStatsFlags indices() {
88+
return indices;
89+
}
90+
91+
public NodesStatsRequest indices(CommonStatsFlags indices) {
92+
this.indices = indices;
93+
return this;
9194
}
9295

9396
/**
9497
* Should indices stats be returned.
9598
*/
9699
public NodesStatsRequest indices(boolean indices) {
97-
this.indices = indices;
100+
if (indices) {
101+
this.indices.all();
102+
} else {
103+
this.indices.clear();
104+
}
98105
return this;
99106
}
100107

@@ -221,7 +228,7 @@ public NodesStatsRequest http(boolean http) {
221228
@Override
222229
public void readFrom(StreamInput in) throws IOException {
223230
super.readFrom(in);
224-
indices = in.readBoolean();
231+
indices = CommonStatsFlags.readCommonStatsFlags(in);
225232
os = in.readBoolean();
226233
process = in.readBoolean();
227234
jvm = in.readBoolean();
@@ -235,7 +242,7 @@ public void readFrom(StreamInput in) throws IOException {
235242
@Override
236243
public void writeTo(StreamOutput out) throws IOException {
237244
super.writeTo(out);
238-
out.writeBoolean(indices);
245+
indices.writeTo(out);
239246
out.writeBoolean(os);
240247
out.writeBoolean(process);
241248
out.writeBoolean(jvm);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.action.admin.cluster.node.stats;
2121

2222
import org.elasticsearch.action.ActionListener;
23+
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
2324
import org.elasticsearch.action.support.nodes.NodesOperationRequestBuilder;
2425
import org.elasticsearch.client.ClusterAdminClient;
2526
import org.elasticsearch.client.internal.InternalClusterAdminClient;
@@ -57,6 +58,14 @@ public NodesStatsRequestBuilder setIndices(boolean indices) {
5758
return this;
5859
}
5960

61+
/**
62+
* Should the node indices stats be returned.
63+
*/
64+
public NodesStatsRequestBuilder setIndices(CommonStatsFlags indices) {
65+
request.indices(indices);
66+
return this;
67+
}
68+
6069
/**
6170
* Should the node OS stats be returned.
6271
*/

src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,40 @@
4545
public class CommonStats implements Streamable, ToXContent {
4646

4747
@Nullable
48-
DocsStats docs;
48+
public DocsStats docs;
4949

5050
@Nullable
51-
StoreStats store;
51+
public StoreStats store;
5252

5353
@Nullable
54-
IndexingStats indexing;
54+
public IndexingStats indexing;
5555

5656
@Nullable
57-
GetStats get;
57+
public GetStats get;
5858

5959
@Nullable
60-
SearchStats search;
60+
public SearchStats search;
6161

6262
@Nullable
63-
MergeStats merge;
63+
public MergeStats merge;
6464

6565
@Nullable
66-
RefreshStats refresh;
66+
public RefreshStats refresh;
6767

6868
@Nullable
69-
FlushStats flush;
69+
public FlushStats flush;
7070

7171
@Nullable
72-
WarmerStats warmer;
72+
public WarmerStats warmer;
7373

7474
@Nullable
75-
FilterCacheStats filterCache;
75+
public FilterCacheStats filterCache;
7676

7777
@Nullable
78-
IdCacheStats idCache;
78+
public IdCacheStats idCache;
7979

8080
@Nullable
81-
FieldDataStats fieldData;
81+
public FieldDataStats fieldData;
8282

8383
public void add(CommonStats stats) {
8484
if (docs == null) {

0 commit comments

Comments
 (0)