Skip to content

Support for /_cluster/state APIs #292

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

Merged
merged 3 commits into from
Jun 18, 2013
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
50 changes: 50 additions & 0 deletions src/Nest.Tests.Integration/Cluster/StateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Collections.Generic;
using NUnit.Framework;

namespace Nest.Tests.Integration.Cluster
{
[TestFixture]
public class StateTests : IntegrationTests
{
[Test]
public void SimpleState()
{
var r = this._client.ClusterState(ClusterStateInfo.All);
Assert.True(r.IsValid);
Assert.NotNull(r.ClusterName);
Assert.NotNull(r.MasterNode);
Assert.NotNull(r.Metadata);
Assert.NotNull(r.Metadata.Indices);
Assert.True(r.Metadata.Indices.Count > 0);
Assert.NotNull(r.Nodes);
Assert.True(r.Nodes.Count > 0);
Assert.NotNull(r.RoutingNodes);
Assert.True(r.RoutingNodes.Nodes.Count > 0);
Assert.NotNull(r.RoutingTable);
}
[Test]
public void StateWithoutMetadata()
{
var r = this._client.ClusterState(ClusterStateInfo.ExcludeMetadata);
Assert.IsNull(r.Metadata);
}
[Test]
public void StateWithoutNodes()
{
var r = this._client.ClusterState(ClusterStateInfo.ExcludeNodes);
Assert.IsNull(r.Nodes);
}
[Test]
public void StateWithoutRoutingTable()
{
var r = this._client.ClusterState(ClusterStateInfo.ExcludeRoutingTable);
Assert.IsNull(r.RoutingTable);
}
//[Test]
//public void StateWithoutBlocks()
//{
// var r = this._client.ClusterState(ClusterStateInfo.ExcludeRoutingTable);
// Assert.IsNull(r.Blocks);
//}
}
}
1 change: 1 addition & 0 deletions src/Nest.Tests.Integration/Nest.Tests.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Compile Include="Indices\Analysis\Analyzers\AnalyzerTest.cs" />
<Compile Include="Indices\Analysis\Analyzers\AnalyzerTestResult.cs" />
<Compile Include="Indices\Analysis\Analyzers\AnalyzerTests.cs" />
<Compile Include="Cluster\StateTests.cs" />
<Compile Include="IntegrationTests.cs" />
<Compile Include="Cluster\HealthTests.cs" />
<Compile Include="Cluster\NodeTests.cs" />
Expand Down
40 changes: 40 additions & 0 deletions src/Nest/Domain/Responses/ClusterStateResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Nest
{
public interface IClusterStateResponse : IResponse
{
string ClusterName { get; }
string MasterNode { get; }
Dictionary<string, NodeState> Nodes { get; }
MetadataState Metadata { get; }
RoutingTableState RoutingTable { get; }
RoutingNodesState RoutingNodes { get; }
}

[JsonObject]
public class ClusterStateResponse : BaseResponse, IClusterStateResponse
{
public ClusterStateResponse()
{
this.IsValid = true;
}
[JsonProperty("cluster_name")]
public string ClusterName { get; internal set; }
[JsonProperty("master_node")]
public string MasterNode { get; internal set; }

[JsonProperty("nodes")]
public Dictionary<string, NodeState> Nodes { get; internal set; }

[JsonProperty("metadata")]
public MetadataState Metadata { get; internal set; }

[JsonProperty("routing_table")]
public RoutingTableState RoutingTable { get; internal set; }

[JsonProperty("routing_nodes")]
public RoutingNodesState RoutingNodes { get; internal set; }
}
}
86 changes: 86 additions & 0 deletions src/Nest/Domain/State/ClusterState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Nest
{
public class NodeState
{
[JsonProperty("name")]
public string Name { get; internal set; }

[JsonProperty("transport_address")]
public string TransportAddress { get; internal set; }

[JsonProperty("attributes")]
public Dictionary<string, string> Attributes { get; internal set; }
}

public class RoutingTableState
{
[JsonProperty("indices")]
public Dictionary<string, IndexRoutingTable> Indices { get; internal set; }
}

public class IndexRoutingTable
{
[JsonProperty("shards")]
public Dictionary<string, List<RoutingShard>> Shards { get; internal set; }
}

public class RoutingShard
{
[JsonProperty("state")]
public string State { get; internal set; }

[JsonProperty("primary")]
public bool Primary { get; internal set; }

[JsonProperty("node")]
public string Node { get; internal set; }

[JsonProperty("relocating_node")]
public string RelocatingNode { get; internal set; }

[JsonProperty("shard")]
public int Shard { get; internal set; }

[JsonProperty("index")]
public string Index { get; internal set; }
}

public class RoutingNodesState
{
[JsonProperty("unassigned")]
public List<RoutingShard> Unassigned { get; internal set; }

[JsonProperty("nodes")]
public Dictionary<string, List<RoutingShard>> Nodes { get; internal set; }
}

public class MetadataState
{
//[JsonProperty("templates")]
//public ?? Templates { get; internal set; }

[JsonProperty("indices")]
public Dictionary<string, MetadataIndexState> Indices { get; internal set; }
}

public class MetadataIndexState
{
[JsonProperty("state")]
public string State { get; internal set; }

[JsonProperty("settings")]
public Dictionary<string, string> Settings { get; internal set; }

//[JsonProperty("mappings")]
//public Dictionary<string, MetadataIndexStateMapping> Mappings { get; internal set; }

//[JsonProperty("aliases")]
//public ?? Aliases { get; internal set; }
}
}
74 changes: 38 additions & 36 deletions src/Nest/Domain/Stats/NodeStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,34 @@ public class IndexStoreStats : StoreStats
[JsonProperty("throttle_time")]
public string ThrottleTime { get; internal set; }
[JsonProperty("throttle_time_in_millis")]
public int ThrottleTimeInMilliseconds { get; internal set; }
public long ThrottleTimeInMilliseconds { get; internal set; }
}

[JsonObject]
public class IndexCacheStats
{
[JsonProperty(PropertyName = "field_evictions")]
public int FieldEvictions { get; internal set; }
public long FieldEvictions { get; internal set; }
[JsonProperty(PropertyName = "field_size")]
public string FieldSize { get; internal set; }
[JsonProperty(PropertyName = "field_size_in_bytes")]
public int FieldSizeInBytes { get; internal set; }
public long FieldSizeInBytes { get; internal set; }
[JsonProperty(PropertyName = "filter_count")]
public int FilterCount { get; internal set; }
public long FilterCount { get; internal set; }
[JsonProperty(PropertyName = "filter_evictions")]
public int FilterEvictions { get; internal set; }
public long FilterEvictions { get; internal set; }
[JsonProperty(PropertyName = "filter_size")]
public string FilterSize { get; internal set; }
[JsonProperty(PropertyName = "filter_size_in_bytes")]
public int FilterSizeInBytes { get; internal set; }
public long FilterSizeInBytes { get; internal set; }
[JsonProperty(PropertyName = "bloom_size")]
public string BloomSize { get; internal set; }
[JsonProperty(PropertyName = "bloom_size_in_bytes")]
public int BloomSizeInBytes { get; internal set; }
public long BloomSizeInBytes { get; internal set; }
[JsonProperty(PropertyName = "id_cache_size")]
public string IDCacheSize { get; internal set; }
[JsonProperty(PropertyName = "id_cache_size_in_bytes")]
public int IDCacheSizeInBytes { get; internal set; }
public long IDCacheSizeInBytes { get; internal set; }
}
}

Expand All @@ -114,6 +114,8 @@ public class UptimeStats
public string Uptime { get; internal set; }
[JsonProperty("uptime_in_millis")]
public long UptimeInMilliseconds { get; internal set; }
[JsonProperty("load_average")]
public float[] LoadAverage { get; internal set; }
}

[JsonObject]
Expand Down Expand Up @@ -190,15 +192,15 @@ public class CPUStats
[JsonProperty("sys")]
public string System { get; internal set; }
[JsonProperty("sys_in_millis")]
public int SystemInMilliseconds { get; internal set; }
public long SystemInMilliseconds { get; internal set; }
[JsonProperty("user")]
public string User { get; internal set; }
[JsonProperty("user_in_millis")]
public int UserInMilliseconds { get; internal set; }
public long UserInMilliseconds { get; internal set; }
[JsonProperty("total")]
public string Total { get; internal set; }
[JsonProperty("total_in_millis")]
public int TotalInMilliseconds { get; internal set; }
public long TotalInMilliseconds { get; internal set; }
}

[JsonObject]
Expand All @@ -207,11 +209,11 @@ public class MemoryStats
[JsonProperty("resident")]
public string Resident { get; internal set; }
[JsonProperty("resident_in_bytes")]
public int ResidentInBytes { get; internal set; }
public long ResidentInBytes { get; internal set; }
[JsonProperty("share")]
public string Share { get; internal set; }
[JsonProperty("share_in_bytes")]
public int ShareInBytes { get; internal set; }
public long ShareInBytes { get; internal set; }
[JsonProperty("total_virtual")]
public string TotalVirtual { get; internal set; }
[JsonProperty("total_virtual_in_bytes")]
Expand Down Expand Up @@ -259,19 +261,19 @@ public class JVMPool
[JsonProperty("used")]
public string Used { get; internal set; }
[JsonProperty("")]
public int UsedInBytes { get; internal set; }
public long UsedInBytes { get; internal set; }
[JsonProperty("max")]
public string Max { get; internal set; }
[JsonProperty("max_in_bytes")]
public int MaxInBytes { get; internal set; }
public long MaxInBytes { get; internal set; }
[JsonProperty("peak_used")]
public string PeakUsed { get; internal set; }
[JsonProperty("peak_used_in_bytes")]
public int PeakUsedInBytes { get; internal set; }
public long PeakUsedInBytes { get; internal set; }
[JsonProperty("peak_max")]
public string PeakMax { get; internal set; }
[JsonProperty("peak_max_in_bytes")]
public int PeakMaxInBytes { get; internal set; }
public long PeakMaxInBytes { get; internal set; }
}
}

Expand Down Expand Up @@ -299,7 +301,7 @@ public class GarbageCollectorStats
[JsonProperty("collection_time")]
public string CollectionTime { get; internal set; }
[JsonProperty("collection_time_in_millis")]
public int CollectionTimeInMilliseconds { get; internal set; }
public long CollectionTimeInMilliseconds { get; internal set; }
}

[JsonObject]
Expand All @@ -322,17 +324,17 @@ public class NodeBufferPool
public class ThreadCountStats
{
[JsonProperty("threads")]
public int Threads { get; internal set; }
public long Threads { get; internal set; }
[JsonProperty("queue")]
public int Queue { get; internal set; }
public long Queue { get; internal set; }
[JsonProperty("active")]
public int Active { get; internal set; }
public long Active { get; internal set; }
[JsonProperty("rejected")]
public int Rejected { get; internal set; }
public long Rejected { get; internal set; }
[JsonProperty("largest")]
public int Largest { get; internal set; }
public long Largest { get; internal set; }
[JsonProperty("completed")]
public int Completed { get; internal set; }
public long Completed { get; internal set; }
}

[JsonObject]
Expand All @@ -345,25 +347,25 @@ public class NetworkStats
public class TCPStats
{
[JsonProperty("active_opens")]
public int ActiveOpens { get; internal set; }
public long ActiveOpens { get; internal set; }
[JsonProperty("passive_opens")]
public int PassiceOpens { get; internal set; }
public long PassiceOpens { get; internal set; }
[JsonProperty("curr_estab")]
public int CurrentEstablished { get; internal set; }
public long CurrentEstablished { get; internal set; }
[JsonProperty("in_segs")]
public int InSegments { get; internal set; }
public long InSegments { get; internal set; }
[JsonProperty("out_segs")]
public int OutSegments { get; internal set; }
public long OutSegments { get; internal set; }
[JsonProperty("retrans_segs")]
public int RetransmittedSegments { get; internal set; }
public long RetransmittedSegments { get; internal set; }
[JsonProperty("estab_resets")]
public int EstablishedResets { get; internal set; }
public long EstablishedResets { get; internal set; }
[JsonProperty("attempt_fails")]
public int AttemptFails { get; internal set; }
public long AttemptFails { get; internal set; }
[JsonProperty("in_errs")]
public int InErrors { get; internal set; }
public long InErrors { get; internal set; }
[JsonProperty("out_rsts")]
public int OutResets { get; internal set; }
public long OutResets { get; internal set; }
}
}

Expand Down Expand Up @@ -397,9 +399,9 @@ public class DatumStats
[JsonProperty("available_in_bytes")]
public long AvailableInBytes { get; internal set; }
[JsonProperty("disk_reads")]
public int DiskReads { get; internal set; }
public long DiskReads { get; internal set; }
[JsonProperty("disk_writes")]
public int DiskWrites { get; internal set; }
public long DiskWrites { get; internal set; }
[JsonProperty("disk_read_size")]
public string DiskReadSize { get; internal set; }
[JsonProperty("disk_read_size_in_bytes")]
Expand Down
Loading