Skip to content

Commit 923a516

Browse files
committed
Fix #1154: snapshot failures are objects, not strings
1 parent 99a2e26 commit 923a516

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed
+27-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using System.Collections.Generic;
34
using Newtonsoft.Json;
45

@@ -8,24 +9,47 @@ public class Snapshot
89
{
910
[JsonProperty("snapshot")]
1011
public string Name { get; internal set; }
12+
1113
[JsonProperty("indices")]
1214
public IEnumerable<string> Indices { get; internal set; }
1315

1416
[JsonProperty("state")]
1517
public string State { get; internal set; }
18+
1619
[JsonProperty("start_time")]
1720
public DateTime StartTime { get; internal set; }
21+
1822
[JsonProperty("start_time_in_millis")]
1923
public long StartTimeInMilliseconds { get; internal set; }
24+
2025
[JsonProperty("end_time")]
2126
public DateTime EndTime { get; internal set; }
27+
2228
[JsonProperty("end_time_in_millis")]
2329
public long EndTimeInMilliseconds { get; internal set; }
30+
2431
[JsonProperty("duration_in_millis")]
2532
public long DurationInMilliseconds { get; internal set; }
26-
[JsonProperty("failures")]
27-
public IEnumerable<string> Failures { get; internal set; }
33+
2834
[JsonProperty("shards")]
29-
public ShardsMetaData Shards { get; internal set; }
35+
public ShardsMetaData Shards { get; internal set; }
36+
37+
[JsonProperty("failures")]
38+
public IEnumerable<SnapshotShardFailure> ShardFailures { get; internal set; }
39+
40+
/// <summary>
41+
/// Contains the reason for each shard failure.
42+
/// For 2.0, remove this and rename ShardFailures => Failures
43+
/// </summary>
44+
public IEnumerable<string> Failures
45+
{
46+
get
47+
{
48+
if (this.ShardFailures != null)
49+
return this.ShardFailures.Select(f => f.Reason);
50+
return new List<string>();
51+
}
52+
}
53+
3054
}
3155
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace Nest
8+
{
9+
[JsonObject]
10+
public class SnapshotShardFailure
11+
{
12+
[JsonProperty("node_id")]
13+
public string NodeId { get; set; }
14+
15+
[JsonProperty("index")]
16+
public string Index { get; set; }
17+
18+
[JsonProperty("shard_id")]
19+
public string ShardId { get; set; }
20+
21+
[JsonProperty("reason")]
22+
public string Reason { get; set; }
23+
24+
[JsonProperty("status")]
25+
public string Status { get; set; }
26+
}
27+
}

src/Nest/Nest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
<Compile Include="Domain\Mapping\SubMappings\FieldData\FieldDataStringMapping.cs" />
185185
<Compile Include="Domain\Mapping\SubMappings\NormsMapping.cs" />
186186
<Compile Include="Domain\Mapping\SubMappings\MappingTransform.cs" />
187+
<Compile Include="Domain\Repository\SnapshotShardFailure.cs" />
187188
<Compile Include="Domain\Responses\ClusterRerouteResponse.cs" />
188189
<Compile Include="Domain\Cat\CatAliasesRecord.cs" />
189190
<Compile Include="Domain\Cat\CatAllocationRecord.cs" />

0 commit comments

Comments
 (0)