25
25
*/
26
26
@ Getter
27
27
public class NeuralStatsResponse extends BaseNodesResponse <NeuralStatsNodeResponse > implements ToXContentObject {
28
+ public static final String INFO_KEY_PREFIX = "info" ;
29
+ public static final String NODES_KEY_PREFIX = "nodes" ;
30
+ public static final String AGGREGATED_NODES_KEY_PREFIX = "all_nodes" ;
28
31
29
- private static final String NODES_KEY = "nodes" ;
30
- private Map <String , StatSnapshot <?>> clusterLevelStats ;
32
+ private Map < String , StatSnapshot <?>> infoStats ;
33
+ private Map <String , StatSnapshot <?>> aggregatedNodeStats ;
31
34
private Map <String , Map <String , StatSnapshot <?>>> nodeIdToNodeEventStats ;
32
35
private boolean flatten ;
33
36
private boolean includeMetadata ;
@@ -40,11 +43,13 @@ public class NeuralStatsResponse extends BaseNodesResponse<NeuralStatsNodeRespon
40
43
*/
41
44
public NeuralStatsResponse (StreamInput in ) throws IOException {
42
45
super (new ClusterName (in ), in .readList (NeuralStatsNodeResponse ::readStats ), in .readList (FailedNodeException ::new ));
43
- Map <String , StatSnapshot <?>> castedStats = (Map <String , StatSnapshot <?>>) (Map ) in .readMap ();
46
+ Map <String , StatSnapshot <?>> castedInfoStats = (Map <String , StatSnapshot <?>>) (Map ) in .readMap ();
47
+ Map <String , StatSnapshot <?>> castedAggregatedNodeStats = (Map <String , StatSnapshot <?>>) (Map ) in .readMap ();
44
48
Map <String , Map <String , StatSnapshot <?>>> castedNodeIdToNodeEventStats = (Map <String , Map <String , StatSnapshot <?>>>) (Map ) in
45
49
.readMap ();
46
50
47
- this .clusterLevelStats = castedStats ;
51
+ this .infoStats = castedInfoStats ;
52
+ this .aggregatedNodeStats = castedAggregatedNodeStats ;
48
53
this .nodeIdToNodeEventStats = castedNodeIdToNodeEventStats ;
49
54
this .flatten = in .readBoolean ();
50
55
this .includeMetadata = in .readBoolean ();
@@ -56,19 +61,20 @@ public NeuralStatsResponse(StreamInput in) throws IOException {
56
61
* @param clusterName name of cluster
57
62
* @param nodes List of NeuralStatsNodeResponses
58
63
* @param failures List of failures from nodes
59
- * @param clusterLevelStats
60
64
*/
61
65
public NeuralStatsResponse (
62
66
ClusterName clusterName ,
63
67
List <NeuralStatsNodeResponse > nodes ,
64
68
List <FailedNodeException > failures ,
65
- Map <String , StatSnapshot <?>> clusterLevelStats ,
69
+ Map <String , StatSnapshot <?>> infoStats ,
70
+ Map <String , StatSnapshot <?>> aggregatedNodeStats ,
66
71
Map <String , Map <String , StatSnapshot <?>>> nodeIdToNodeEventStats ,
67
72
boolean flatten ,
68
73
boolean includeMetadata
69
74
) {
70
75
super (clusterName , nodes , failures );
71
- this .clusterLevelStats = clusterLevelStats ;
76
+ this .infoStats = infoStats ;
77
+ this .aggregatedNodeStats = aggregatedNodeStats ;
72
78
this .nodeIdToNodeEventStats = nodeIdToNodeEventStats ;
73
79
this .flatten = flatten ;
74
80
this .includeMetadata = includeMetadata ;
@@ -77,10 +83,13 @@ public NeuralStatsResponse(
77
83
@ Override
78
84
public void writeTo (StreamOutput out ) throws IOException {
79
85
super .writeTo (out );
80
- Map <String , Object > downcastedStats = (Map <String , Object >) (Map ) (clusterLevelStats );
81
- Map <String , Object > downcastedNodeStats = (Map <String , Object >) (Map ) (nodeIdToNodeEventStats );
82
- out .writeMap (downcastedStats );
83
- out .writeMap (downcastedNodeStats );
86
+ Map <String , Object > downcastedInfoStats = (Map <String , Object >) (Map ) (infoStats );
87
+ Map <String , Object > downcastedAggregatedNodeStats = (Map <String , Object >) (Map ) (aggregatedNodeStats );
88
+ Map <String , Object > downcastedNodeIdToNodeEventStats = (Map <String , Object >) (Map ) (nodeIdToNodeEventStats );
89
+
90
+ out .writeMap (downcastedInfoStats );
91
+ out .writeMap (downcastedAggregatedNodeStats );
92
+ out .writeMap (downcastedNodeIdToNodeEventStats );
84
93
out .writeBoolean (flatten );
85
94
out .writeBoolean (includeMetadata );
86
95
}
@@ -97,12 +106,18 @@ public List<NeuralStatsNodeResponse> readNodesFrom(StreamInput in) throws IOExce
97
106
98
107
@ Override
99
108
public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
100
- Map <String , Object > formattedClusterLevelStats = formatStats (clusterLevelStats );
101
- builder .mapContents (formattedClusterLevelStats );
109
+ Map <String , Object > formattedInfoStats = formatStats (infoStats );
110
+ builder .startObject (INFO_KEY_PREFIX );
111
+ builder .mapContents (formattedInfoStats );
112
+ builder .endObject ();
102
113
103
- Map <String , Object > formattedNodeEventStats = formatNodeEventStats (nodeIdToNodeEventStats );
114
+ Map <String , Object > formattedAggregatedNodeStats = formatStats (aggregatedNodeStats );
115
+ builder .startObject (AGGREGATED_NODES_KEY_PREFIX );
116
+ builder .mapContents (formattedAggregatedNodeStats );
117
+ builder .endObject ();
104
118
105
- builder .startObject (NODES_KEY );
119
+ Map <String , Object > formattedNodeEventStats = formatNodeEventStats (nodeIdToNodeEventStats );
120
+ builder .startObject (NODES_KEY_PREFIX );
106
121
builder .mapContents (formattedNodeEventStats );
107
122
builder .endObject ();
108
123
0 commit comments