Skip to content

Commit 03ca71a

Browse files
committed
Change Node settings to Dictionary<string,object>
Elasticsearch 6.1.0 returns path.data as an array of values. Cater for this by making settings a Dictionary<string,object> as opposed to Dictionary<string,string>
1 parent 3530838 commit 03ca71a

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

src/Elasticsearch.Net/ConnectionPool/Node.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public Node(Uri uri)
4747
/// <summary>The name of the node, defaults to null when unknown/unspecified</summary>
4848
public string Name { get; set; }
4949

50-
private static readonly IReadOnlyDictionary<string, string> EmptySettings = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>());
51-
public IReadOnlyDictionary<string, string> Settings { get; set; } = EmptySettings;
50+
private static readonly IReadOnlyDictionary<string, object> EmptySettings = new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());
51+
public IReadOnlyDictionary<string, object> Settings { get; set; } = EmptySettings;
5252

5353
/// <summary> The number of failed attempts trying to use this node, resets when a node is marked alive</summary>
5454
public int FailedAttempts { get; private set; }

src/Elasticsearch.Net/Responses/Sniff/SniffResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public IEnumerable<Node> ToNodes(bool forceHttp = false)
5353
HoldsData = info.HoldsData,
5454
IngestEnabled = info.IngestEnabled,
5555
HttpEnabled = info.HttpEnabled,
56-
Settings = new ReadOnlyDictionary<string, string>(info.settings)
56+
Settings = new ReadOnlyDictionary<string, object>(info.settings)
5757
};
5858
yield return node;
5959
}
@@ -70,7 +70,7 @@ internal class NodeInfo
7070
public string build_hash { get; set; }
7171
public IList<string> roles { get; set; }
7272
public NodeInfoHttp http { get; set; }
73-
public IDictionary<string, string> settings { get; set; }
73+
public IDictionary<string, object> settings { get; set; }
7474

7575
internal bool MasterEligible => this.roles?.Contains("master") ?? false;
7676
internal bool HoldsData => this.roles?.Contains("data") ?? false;

src/Tests/ClientConcepts/ConnectionPooling/BuildingBlocks/ConnectionPooling.doc.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ [U] public void SniffingSortedSticky()
200200

201201
var pool = new StickySniffingConnectionPool(uris, n =>
202202
(n.ClientNode ? 10 : 0)
203-
+ (n.Settings.TryGetValue("node.attr.rack_id", out string rackId)
204-
&& rackId == "rack_one" ? 10 : 0));
203+
+ (n.Settings.TryGetValue("node.attr.rack_id", out var rackId)
204+
&& rackId.ToString() == "rack_one" ? 10 : 0));
205205

206206
pool.SupportsReseeding.Should().BeTrue();
207207
pool.SupportsPinging.Should().BeTrue();

src/Tests/ClientConcepts/ConnectionPooling/Sniffing/RoleDetection.doc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public async Task RespectsCustomPredicate()
215215
.DisablePing() // <1> for testing simplicity, disable pings
216216
.NodePredicate(node => // <2> We only want to execute API calls to nodes in rack_one
217217
node.Settings.ContainsKey(setting) &&
218-
node.Settings[setting] == value
218+
node.Settings[setting].ToString() == value
219219
)
220220
)
221221
)

src/Tests/ClientConcepts/ConnectionPooling/Sticky/StickySniffingConnectionPool.doc.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ IEnumerable<Node> Nodes(int start) => Enumerable.Range(start, 4)
5050
.Select(i => new Uri($"http://localhost:{9200 + i}"))
5151
.Select((u, i) => new Node(u)
5252
{
53-
Settings = new Dictionary<string, string> {{"rack", $"rack_{u.Port - 9200}"}}
53+
Settings = new Dictionary<string, object> {{"rack", $"rack_{u.Port - 9200}"}}
5454
});
5555

5656
/** We set up a cluster with 4 nodes all having a different rack id
@@ -68,8 +68,8 @@ We initially only seed nodes `9200-9203` in racks 0 to 3. So we should be sticky
6868
.ClientCalls(p => p.SucceedAlways()))
6969
)
7070
.StickySniffingConnectionPool(n=>
71-
(n.Settings.TryGetValue("rack", out string v) && v == "rack_2" ? 10 : 0)
72-
+(n.Settings.TryGetValue("rack", out string r) && r == "rack_11" ? 10 : 0)
71+
(n.Settings.TryGetValue("rack", out var v) && v.ToString() == "rack_2" ? 10 : 0)
72+
+(n.Settings.TryGetValue("rack", out var r) && r.ToString() == "rack_11" ? 10 : 0)
7373
)
7474
.Settings(p => p.DisablePing().SniffOnStartup(false))
7575
);
@@ -105,7 +105,7 @@ IEnumerable<Node> Nodes(int start) => Enumerable.Range(start, 4)
105105
.Select(i => new Uri($"http://localhost:{9200 + i}"))
106106
.Select((u, i) => new Node(u)
107107
{
108-
Settings = new Dictionary<string, string> {{"rack", $"rack_{u.Port - 9200}"}}
108+
Settings = new Dictionary<string, object> {{"rack", $"rack_{u.Port - 9200}"}}
109109
});
110110

111111
/** We seed a cluster with an array of 4 Uri's starting at port 9200.
@@ -119,7 +119,7 @@ IEnumerable<Node> Nodes(int start) => Enumerable.Range(start, 4)
119119
.ClientCalls(p => p.SucceedAlways()))
120120
)
121121
.StickySniffingConnectionPool(n=>
122-
(n.Settings.TryGetValue("rack", out string v) && v == "rack_2" ? 10 : 0)
122+
(n.Settings.TryGetValue("rack", out var v) && v.ToString() == "rack_2" ? 10 : 0)
123123
)
124124
.Settings(p => p.DisablePing())
125125
);

src/Tests/Framework/VirtualClustering/VirtualCluster.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public VirtualCluster StoresNoData(params int[] ports)
5656
public VirtualCluster HasSetting(string key, string value, params int[] ports)
5757
{
5858
foreach (var node in this._nodes.Where(n => ports.Contains(n.Uri.Port)))
59-
node.Settings = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>{{key, value}});
59+
node.Settings = new ReadOnlyDictionary<string, object>(new Dictionary<string, object>{{key, value}});
6060
return this;
6161
}
6262
public VirtualCluster HttpDisabled(params int[] ports)

0 commit comments

Comments
 (0)