Skip to content

Commit d48cbcb

Browse files
authored
Fix #2573 bwc support for new cluster allocation explain response (#2589)
1 parent 73f6709 commit d48cbcb

File tree

8 files changed

+399
-31
lines changed

8 files changed

+399
-31
lines changed

src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainResponse.cs

Lines changed: 169 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,147 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Runtime.Serialization;
4+
using System.Security.Cryptography.X509Certificates;
45
using Newtonsoft.Json;
56
using Newtonsoft.Json.Converters;
67

78
namespace Nest
89
{
10+
[JsonConverter(typeof(ClusterAllocationExplainResponseJsonConverter))]
911
public interface IClusterAllocationExplainResponse : IResponse
1012
{
11-
[JsonProperty("shard")]
12-
ShardAllocationExplanation Shard { get; }
13+
[JsonProperty("index")]
14+
string Index { get; }
1315

14-
[JsonProperty("assigned")]
15-
bool Assigned { get; }
16+
[JsonIgnore]
17+
// TODO rename to Shard in 6.0
18+
int ShardId { get; }
1619

17-
[JsonProperty("assigned_node_id")]
18-
string AssignedNodeId { get; }
20+
[JsonProperty("primary")]
21+
bool Primary { get; }
1922

20-
[JsonProperty("shard_state_fetch_pending")]
21-
bool ShardStateFetchPending { get; }
23+
[JsonProperty("current_state")]
24+
string CurrentState { get; }
2225

2326
[JsonProperty("unassigned_info")]
2427
UnassignedInformation UnassignedInformation { get; }
2528

29+
[JsonProperty("can_allocate")]
30+
Decision? CanAllocate { get; }
31+
32+
[JsonProperty("allocate_explanation")]
33+
string AllocateExplanation { get; }
34+
35+
[JsonProperty("configured_delay")]
36+
string ConfiguredDelay { get; }
37+
38+
[JsonProperty("configured_delay_in_mills")]
39+
long ConfiguredDelayInMilliseconds { get; }
40+
41+
[JsonProperty("current_node")]
42+
CurrentNode CurrentNode { get; }
43+
44+
[JsonProperty("can_remain_on_current_node")]
45+
Decision? CanRemainOnCurrentNode { get; }
46+
47+
[JsonProperty("can_remain_decisions")]
48+
IReadOnlyCollection<AllocationDecision> CanRemainDecisions { get; }
49+
50+
[JsonProperty("can_rebalance_cluster")]
51+
Decision? CanRebalanceCluster { get; }
52+
53+
[JsonProperty("can_rebalance_to_other_nodes")]
54+
Decision? CanRebalanceToOtherNode { get; }
55+
56+
[JsonProperty("can_rebalance_cluster_decisions")]
57+
IReadOnlyCollection<AllocationDecision> CanRebalanceClusterDecisions { get; }
58+
59+
[JsonProperty("rebalance_explanation")]
60+
string RebalanceExplanation { get; }
61+
62+
[JsonProperty("node_allocation_decisions")]
63+
IReadOnlyCollection<NodeAllocationExplanation> NodeAllocationDecisions { get; }
64+
65+
[JsonProperty("can_move_to_other_node")]
66+
Decision? CanMoveToOtherNode { get; }
67+
68+
[JsonProperty("move_explanation")]
69+
string MoveExplanation { get; }
70+
2671
[JsonProperty("allocation_delay")]
2772
string AllocationDelay { get; }
2873

29-
[JsonProperty("allocation_delay_ms")]
74+
[JsonProperty("allocation_delay_in_millis")]
3075
long AllocationDelayInMilliseconds { get; }
3176

3277
[JsonProperty("remaining_delay")]
3378
string RemainingDelay { get; }
3479

35-
[JsonProperty("remaining_delay_ms")]
80+
[JsonProperty("remaining_delay_in_millis")]
3681
long RemainingDelayInMilliseconds { get; }
3782

83+
[JsonIgnore]
84+
[Obsolete("Removed in Elasticsearch 5.2. Use properties on root object instead.")]
85+
ShardAllocationExplanation Shard { get; }
86+
87+
[JsonProperty("assigned")]
88+
[Obsolete("Removed in Elasticsearch 5.2.")]
89+
bool Assigned { get; }
90+
91+
[JsonProperty("assigned_node_id")]
92+
[Obsolete("Removed in Elasticsearch 5.2.")]
93+
string AssignedNodeId { get; }
94+
95+
[JsonProperty("shard_state_fetch_pending")]
96+
[Obsolete("Removed in Elasticsearch 5.2.")]
97+
bool ShardStateFetchPending { get; }
98+
3899
[JsonProperty("nodes")]
100+
[Obsolete("Removed in Elasticsearch 5.2. Use node_allocation_decisions instead.")]
39101
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter<string, NodeAllocationExplanation>))]
40102
IReadOnlyDictionary<string, NodeAllocationExplanation> Nodes { get; }
41103
}
42104

43105
public class ClusterAllocationExplainResponse : ResponseBase, IClusterAllocationExplainResponse
44106
{
45-
public ShardAllocationExplanation Shard { get; internal set; }
107+
public string Index { get; internal set; }
46108

47-
public bool Assigned { get; internal set; }
109+
public int ShardId { get; internal set; }
48110

49-
public string AssignedNodeId { get; internal set; }
111+
public bool Primary { get; internal set; }
50112

51-
public bool ShardStateFetchPending { get; internal set; }
113+
public string CurrentState { get; internal set; }
52114

53115
public UnassignedInformation UnassignedInformation { get; internal set; }
54116

117+
public Decision? CanAllocate { get; internal set; }
118+
119+
public string AllocateExplanation { get; internal set; }
120+
121+
public string ConfiguredDelay { get; internal set; }
122+
123+
public long ConfiguredDelayInMilliseconds { get; internal set; }
124+
125+
public CurrentNode CurrentNode { get; internal set; }
126+
127+
public Decision? CanRemainOnCurrentNode { get; internal set; }
128+
129+
public IReadOnlyCollection<AllocationDecision> CanRemainDecisions { get; internal set; }
130+
131+
public Decision? CanRebalanceCluster { get; internal set; }
132+
133+
public Decision? CanRebalanceToOtherNode { get; internal set; }
134+
135+
public IReadOnlyCollection<AllocationDecision> CanRebalanceClusterDecisions { get; internal set; } = EmptyReadOnly<AllocationDecision>.Collection;
136+
137+
public string RebalanceExplanation { get; internal set; }
138+
139+
public IReadOnlyCollection<NodeAllocationExplanation> NodeAllocationDecisions { get; internal set; }
140+
141+
public Decision? CanMoveToOtherNode { get; internal set; }
142+
143+
public string MoveExplanation { get; internal set; }
144+
55145
public string AllocationDelay { get; internal set; }
56146

57147
public long AllocationDelayInMilliseconds { get; internal set; }
@@ -60,9 +150,41 @@ public class ClusterAllocationExplainResponse : ResponseBase, IClusterAllocation
60150

61151
public long RemainingDelayInMilliseconds { get; internal set; }
62152

153+
[Obsolete("Removed in Elasticsearch 5.2. Use properties on root object instead.")]
154+
public ShardAllocationExplanation Shard { get; internal set; }
155+
156+
[Obsolete("Removed in Elasticsearch 5.2.")]
157+
public bool Assigned { get; internal set; }
158+
159+
[Obsolete("Removed in Elasticsearch 5.2.")]
160+
public string AssignedNodeId { get; internal set; }
161+
162+
[Obsolete("Removed in Elasticsearch 5.2.")]
163+
public bool ShardStateFetchPending { get; internal set; }
164+
165+
[Obsolete("Removed in Elasticsearch 5.2. Usage NodeAllocationDecisions instead.")]
63166
public IReadOnlyDictionary<string, NodeAllocationExplanation> Nodes { get; internal set; } = EmptyReadOnly<string, NodeAllocationExplanation>.Dictionary;
64167
}
65168

169+
[JsonObject]
170+
public class CurrentNode
171+
{
172+
[JsonProperty("id")]
173+
public string Id { get; internal set; }
174+
175+
[JsonProperty("name")]
176+
public string Name { get; internal set; }
177+
178+
[JsonProperty("transport_address")]
179+
public string TransportAddress { get; internal set; }
180+
181+
[JsonProperty("weight_ranking")]
182+
public string WeightRanking { get; internal set; }
183+
184+
[JsonProperty("attributes")]
185+
public IReadOnlyDictionary<string, string> NodeAttributes { get; set; } = EmptyReadOnly<string, string>.Dictionary;
186+
}
187+
66188
[JsonConverter(typeof(StringEnumConverter))]
67189
public enum AllocationExplainDecision
68190
{
@@ -82,29 +204,59 @@ public enum AllocationExplainDecision
82204
[JsonObject]
83205
public class NodeAllocationExplanation
84206
{
207+
[JsonProperty("node_id")]
208+
public string NodeId { get; set; }
209+
85210
[JsonProperty("node_name")]
86211
public string NodeName { get; set; }
87212

213+
[JsonProperty("transport_address")]
214+
public string TransportAddress { get; set; }
215+
216+
[JsonProperty("node_decision")]
217+
public Decision? NodeDecision { get; set; }
218+
88219
[JsonProperty("node_attributes")]
89220
public IReadOnlyDictionary<string, string> NodeAttributes { get; set; } = EmptyReadOnly<string, string>.Dictionary;
90221

91222
[JsonProperty("store")]
92223
public AllocationStore Store { get; set; }
93224

94225
[JsonProperty("final_decision")]
226+
[Obsolete("Removed in Elasticsearch 5.2.")]
95227
public FinalDecision FinalDecision { get; set; }
96228

97229
[JsonProperty("final_explanation")]
230+
[Obsolete("Removed in Elasticsearch 5.2.")]
98231
public string FinalExplanation { get; set; }
99232

100233
[JsonProperty("weight")]
234+
[Obsolete("Removed in Elasticsearch 5.2. Use WeightRanking instead.")]
101235
public float Weight { get; set; }
102236

237+
[JsonProperty("weight_ranking")]
238+
public int? WeightRanking { get; set; }
239+
103240
[JsonProperty("decisions")]
241+
[Obsolete("Removed in Elasticsearch 5.2. Use Deciders instead.")]
104242
public IReadOnlyCollection<AllocationDecision> Decisions { get; set; } = EmptyReadOnly<AllocationDecision>.Collection;
243+
244+
[JsonProperty("deciders")]
245+
public IReadOnlyCollection<AllocationDecision> Deciders { get; set; } = EmptyReadOnly<AllocationDecision>.Collection;
246+
}
247+
248+
[JsonConverter(typeof(StringEnumConverter))]
249+
public enum Decision
250+
{
251+
[EnumMember(Value = "yes")]
252+
Yes,
253+
254+
[EnumMember(Value = "no")]
255+
No
105256
}
106257

107258
[JsonConverter(typeof(StringEnumConverter))]
259+
[Obsolete("Removed in Elasticsearch 5.2")]
108260
public enum FinalDecision
109261
{
110262
[EnumMember(Value = "YES")]
@@ -159,14 +311,16 @@ public class AllocationDecision
159311
public string Explanation { get; set; }
160312
}
161313

162-
163314
public class UnassignedInformation
164315
{
165316
[JsonProperty("reason")]
166317
public UnassignedInformationReason Reason { get; set; }
167318

168319
[JsonProperty("at")]
169320
public DateTime At { get; set; }
321+
322+
[JsonProperty("last_allocation_status")]
323+
public string LastAllocationStatus { get; set; }
170324
}
171325

172326
public class ShardAllocationExplanation

0 commit comments

Comments
 (0)