I think the answer is that the selection strategy needs to be extracted such that it can be configurable. It is entirely reasonable that you would want to connect to the local node unless it is down. Would you please file an issue on https://github.com/basho/riak-python-client/issues ? We'll investigate it further for the next major client release.
On Sat, Feb 8, 2014 at 3:07 PM, Massimiliano Ciancio < [email protected]> wrote: > Hi Sean, > thanks for your answer! > > > I believe it may still be possible for the node to be selected if no > other > > connections are available in the pool, because the logic used to > establish a > > new connection might not use the filter. > > My problem is not to avoid that a node will be selected again after a > fail (well, if this can be avoided by sure it's better...) but to set > an order in the nodes: I want to connect first to the node on which my > app is running and only in case of fail to the other nodes. The reason > is to avoid network traffic: every instance of my app have to connect > to the node on the same machine where it resides. > How can I suggest a "preferred node" to RiakClient? > My first idea was to use a connection with only the preferred node > and, using a try/except, use an "emergency connection" with the list > of all nodes to be used only in case of fail. But it's not so > elegant.... > Massimiliano > > 2014-02-08 13:47 GMT+01:00 Sean Cribbs <[email protected]>: > > Hi Massimilliano, > > > > The list of nodes does not imply an order of connection. Usually, a > random > > node is chosen after nodes with error rates greater than a threshold are > > removed from the candidates. You can see the implementation in > > RiakClient._choose_node: > > > https://github.com/basho/riak-python-client/blob/master/riak/client/__init__.py#L278 > > > > When a request fails such that the connection is known to be bad (such > as a > > TCP error), the retry logic filters out that node from existing > connections. > > I believe it may still be possible for the node to be selected if no > other > > connections are available in the pool, because the logic used to > establish a > > new connection might not use the filter. I will investigate further and > > determine if this is actually the case. > > > > > > On Sat, Feb 8, 2014 at 1:03 PM, Massimiliano Ciancio > > <[email protected]> wrote: > >> > >> Hi all, > >> I'm using python client to connect to a five nodes riak server. > >> Since I'm running my app on the same servers on which is running Riak, > >> I want that the app on server x get and store data asking to the Riak > >> on the same server. If the Riak on the same server is not available, > >> tha app must connect to another Riak server randomly choosed. > >> How can I implement this? > >> Does the list of nodes passed to the RiakClient > >> (http://basho.github.io/riak-python-client/client.html) imply an > >> 'order of connection' ? That is, first connect to the first node then, > >> if this fails, connect to the second and so on... > >> Thanks in advance > >> Massimiliano > >> > >> _______________________________________________ > >> riak-users mailing list > >> [email protected] > >> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com > > > > > > > > > > -- > > Sean Cribbs <[email protected]> > > Software Engineer > > Basho Technologies, Inc. > > http://basho.com/ > -- Sean Cribbs <[email protected]> Software Engineer Basho Technologies, Inc. http://basho.com/
_______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
