Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NCBC-161: Be tolerant of nodes which lack couchApiBase

Change-Id: Id9b2c0ff9e03580606b1291994e083088e0e6384
Reviewed-on: http://review.couchbase.org/22770
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Reviewed-by: John C. Zablocki <john@couchbase.com>
Tested-by: John C. Zablocki <john@couchbase.com>
  • Loading branch information...
commit 32b2bab9a69d831cbdb857212e750b2f72591fe2 1 parent 9f20a63
@mnunberg mnunberg authored John C. Zablocki committed
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/Couchbase/CouchbaseClient.cs
View
18 src/Couchbase/CouchbaseClient.cs
@@ -782,15 +782,15 @@ private void getViewSetup(ref string designName, ref string viewName)
IHttpClient IHttpClientLocator.Locate(string designDocument)
{
- //pick a node at random to avoid overloading a single node with view requests
- var nodes = this.Pool.GetWorkingNodes().ToArray();
- var idx = new Random(Environment.TickCount).Next(nodes.Length);
- var node = nodes[idx] as CouchbaseNode;
-
- // return null if the node is dead
- return (node != null && node.IsAlive)
- ? node.Client
- : null;
+ //pick a node at random to avoid overloading a single node with view requests
+ var nodes = Pool.GetWorkingNodes()
+ .Where(n => n is CouchbaseNode && n.IsAlive)
+ .Select(n => n as CouchbaseNode)
+ .ToList();
+
+ var idx = new Random(Environment.TickCount).Next(nodes.Count);
+ var node = nodes[idx] as CouchbaseNode;
+ return node.Client;
}
#endregion
Please sign in to comment.
Something went wrong with that request. Please try again.