Skip to content

Commit 7626ef6

Browse files
Fix ScriptCacheStats (#4854) (#4859)
This commit fixes the response type for node stats script_cache to a type with "sum" and "contexts" fields, to match the shape of returned JSON Co-authored-by: Russ Cam <russ.cam@elastic.co>
1 parent 4033acc commit 7626ef6

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Nest/Cluster/NodesStats/NodeStats.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public class NodeStats
6666
/// Available in Elasticsearch 7.8.0+
6767
/// </summary>
6868
[DataMember(Name = "script_cache")]
69-
[JsonFormatter(typeof(VerbatimInterfaceReadOnlyDictionaryKeysFormatter<string, ScriptStats>))]
70-
public IReadOnlyDictionary<string, ScriptStats> ScriptCache { get; internal set; }
69+
public ScriptCacheStats ScriptCache { get; internal set; }
7170

7271
[DataMember(Name = "thread_pool")]
7372
[JsonFormatter(typeof(VerbatimInterfaceReadOnlyDictionaryKeysFormatter<string, ThreadCountStats>))]
@@ -83,6 +82,22 @@ public class NodeStats
8382
public string TransportAddress { get; internal set; }
8483
}
8584

85+
[DataContract]
86+
public class ScriptCacheStats
87+
{
88+
[DataMember(Name = "sum")]
89+
public ScriptStats Sum { get; internal set; }
90+
91+
[DataMember(Name = "contexts")]
92+
public IReadOnlyCollection<ContextScriptStats> Contexts { get; internal set; }
93+
}
94+
95+
[DataContract]
96+
public class ContextScriptStats : ScriptStats
97+
{
98+
[DataMember(Name = "context")]
99+
public string Context { get; internal set; }
100+
}
86101

87102
[DataContract]
88103
public class ScriptStats

tests/Tests/Cluster/NodesStats/NodesStatsApiTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,11 @@ protected void Assert(ProcessStats process)
189189

190190
protected void Assert(ScriptStats script) => script.Should().NotBeNull();
191191

192-
protected void Assert(IReadOnlyDictionary<string, ScriptStats> scriptCache) =>
192+
protected void Assert(ScriptCacheStats scriptCache)
193+
{
193194
scriptCache.Should().NotBeNull();
195+
scriptCache.Sum.Should().NotBeNull();
196+
}
194197

195198
protected void Assert(TransportStats transport) => transport.Should().NotBeNull();
196199

0 commit comments

Comments
 (0)