give preference to local data during query

Until dynamic snitch is implemented this is better than nothing.

Fixes #322
This commit is contained in:
Gleb Natapov
2015-09-09 13:33:06 +03:00
committed by Avi Kivity
parent 6a0d4e3ade
commit 04d2bef55b

View File

@@ -25,6 +25,7 @@
#include "db/consistency_level.hh"
#include <boost/range/algorithm/partition.hpp>
#include <boost/range/algorithm/find.hpp>
#include "exceptions/exceptions.hh"
#include "core/sstring.hh"
#include "schema.hh"
@@ -171,6 +172,11 @@ filter_for_query(consistency_level cl,
* replica gets the data read) or not (since we'll take the block_for first
* ones).
*/
// FIXME: before dynamic snitch is implement put local address (if present) at the beginning
auto it = boost::range::find(live_endpoints, utils::fb_utilities::get_broadcast_address());
if (it != live_endpoints.end() && it != live_endpoints.begin()) {
std::iter_swap(it, live_endpoints.begin());
}
if (is_datacenter_local(cl)) {
boost::range::partition(live_endpoints, is_local);
}