Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script_cache to Node Stats API #4744

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Nest/Cluster/NodesStats/NodeStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public class NodeStats
[DataMember(Name = "script")]
public ScriptStats Script { get; internal set; }

/// <summary>
/// Available in Elasticsearch 7.8.0+
/// </summary>
[DataMember(Name = "script_cache")]
[JsonFormatter(typeof(VerbatimInterfaceReadOnlyDictionaryKeysFormatter<string, ScriptStats>))]
public IReadOnlyDictionary<string, ScriptStats> ScriptCache { get; internal set; }

[DataMember(Name = "thread_pool")]
[JsonFormatter(typeof(VerbatimInterfaceReadOnlyDictionaryKeysFormatter<string, ThreadCountStats>))]
public IReadOnlyDictionary<string, ThreadCountStats> ThreadPool { get; internal set; }
Expand All @@ -85,6 +92,9 @@ public class ScriptStats

[DataMember(Name = "compilations")]
public long Compilations { get; internal set; }

[DataMember(Name = "compilation_limit_triggered")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking this always comes back as 0 from the server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value returned is always 0? Might be tricky to have a valid greater than 0 returned in tests.

The server side defines the property here

https://github.com/elastic/elasticsearch/blob/32f46f2214808c0b2c2271bf977f2f08fe6d6fbc/server/src/main/java/org/elasticsearch/script/ScriptCacheStats.java#L108

public long CompilationLimitTriggered { get; internal set; }
}

[DataContract]
Expand Down
11 changes: 8 additions & 3 deletions tests/Tests/Cluster/NodesStats/NodesStatsApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ protected override void ExpectResponse(NodesStatsResponse response)
Assert(node.Jvm);
Assert(node.AdaptiveSelection);
Assert(node.Ingest);

if (TestClient.Configuration.InRange(">=7.8.0"))
{
Assert(node.ScriptCache);
}
}

protected void Assert(NodeIngestStats nodeIngestStats)
Expand All @@ -94,9 +99,6 @@ protected void Assert(NodeIngestStats nodeIngestStats)

processorStats.Type.Should().Be("set");
processorStats.Statistics.Should().NotBeNull();



}

protected void Assert(IReadOnlyDictionary<string, AdaptiveSelectionStats> adaptiveSelectionStats) =>
Expand Down Expand Up @@ -187,6 +189,9 @@ protected void Assert(ProcessStats process)

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

protected void Assert(IReadOnlyDictionary<string, ScriptStats> scriptCache) =>
scriptCache.Should().NotBeNull();

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

protected void Assert(HttpStats http) => http.Should().NotBeNull();
Expand Down