Skip to content

Commit 2f285b2

Browse files
committed
Add missing allocation decision enum values
This commit adds missing allocation decision enum values, based on https://github.com/elastic/elasticsearch/blob/5.6/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationDecision.java Fixes #3210
1 parent b183504 commit 2f285b2

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainResponse.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,25 @@ public enum Decision
251251
Yes,
252252

253253
[EnumMember(Value = "no")]
254-
No
254+
No,
255+
256+
[EnumMember(Value = "worse_balance")]
257+
WorseBalance,
258+
259+
[EnumMember(Value = "throttled")]
260+
Throttled,
261+
262+
[EnumMember(Value = "awaiting_info")]
263+
AwaitingInfo,
264+
265+
[EnumMember(Value = "allocation_delayed")]
266+
AllocationDelayed,
267+
268+
[EnumMember(Value = "no_valid_shard_copy")]
269+
NoValidShardCopy,
270+
271+
[EnumMember(Value = "no_attempt")]
272+
NoAttempt
255273
}
256274

257275
[JsonConverter(typeof(StringEnumConverter))]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Linq.Expressions;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using Elasticsearch.Net;
8+
using Nest;
9+
using Tests.Framework;
10+
using Tests.Framework.Integration;
11+
using Xunit;
12+
using FluentAssertions;
13+
14+
namespace Tests.Reproduce
15+
{
16+
public class GithubIssue3210
17+
{
18+
private const string ClusterAllocationResponse = @"{
19+
""index"" : ""idx"",
20+
""shard"" : 0,
21+
""primary"" : true,
22+
""current_state"" : ""unassigned"",
23+
""unassigned_info"" : {
24+
""reason"" : ""INDEX_CREATED"",
25+
""at"" : ""2017-01-04T18:08:16.600Z"",
26+
""last_allocation_status"" : ""no""
27+
},
28+
""can_allocate"" : ""no"",
29+
""allocate_explanation"" : ""cannot allocate because allocation is not permitted to any of the nodes"",
30+
""node_allocation_decisions"" : [
31+
{
32+
""node_id"": ""_3APDoyWQUGJC2J_LbxQVw"",
33+
""node_name"": ""node"",
34+
""transport_address"": ""10.10.10.10:9300"",
35+
""node_attributes"": {
36+
""ml.max_open_jobs"": ""10"",
37+
""rack_id"": ""2"",
38+
""ml.enabled"": ""true"",
39+
""machinetype"": ""warm""
40+
},
41+
""node_decision"": ""worse_balance"",
42+
""weight_ranking"": 4
43+
}
44+
]
45+
}";
46+
47+
[U] public void MissingNodeDecisionOptionsInResponseThrowExceptionWhenAttemptingToDeserializeResponse()
48+
{
49+
var client = TestClient.GetFixedStringResponseClient(ClusterAllocationResponse);
50+
var response = client.ClusterAllocationExplain();
51+
52+
var nodeAllocationDecisions = response.NodeAllocationDecisions;
53+
nodeAllocationDecisions.Should().NotBeNullOrEmpty();
54+
nodeAllocationDecisions.First().NodeDecision.Should().NotBeNull().And.Be(Decision.WorseBalance);
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)