31 #include <boost/algorithm/string.hpp>
39 std::vector<RangeServerStatistics> &statistics,
String arguments)
40 : m_context(context), m_statistics(statistics) {
41 boost::trim(arguments);
47 std::vector<RangeServerConnectionPtr> &balanced) {
49 StringSet::iterator locations_it;
54 if (!stats.stats || !stats.stats->live || !
m_context->can_accept_ranges(stats))
56 locations.insert(stats.location);
60 if (locations.empty())
62 "No destination servers found with enough room");
64 locations_it = locations.begin();
68 String last_key, last_location, last_start_row;
69 bool read_start_row =
false;
70 String location(
"Location"), start_row(
"StartRow");
74 String new_location = *locations_it;
76 if (locations_it == locations.end())
77 locations_it = locations.begin();
82 plan->moves.push_back(move);
89 scan_spec.
columns.push_back(location.c_str());
90 scan_spec.
columns.push_back(start_row.c_str());
94 while (scanner->next(cell)) {
99 read_start_row =
true;
106 last_start_row.clear();
107 read_start_row =
false;
111 last_location.clear();
112 read_start_row =
true;
117 HT_DEBUG_OUT <<
"last_key=" << last_key <<
", last_location="
118 << last_location <<
", last_start_row=" << last_start_row <<
HT_END;
121 if (last_location.size() > 0 && read_start_row &&
123 size_t pos = last_key.find(
':');
125 String table(last_key, 0, pos);
126 String end_row(last_key, pos+1);
127 String new_location = *locations_it;
129 if (locations_it == locations.end())
130 locations_it = locations.begin();
133 new_location.c_str(),
134 table.c_str(), last_start_row.c_str(),
136 plan->moves.push_back(move);
138 HT_DEBUG_OUT << table <<
"[" << last_start_row <<
".." << end_row <<
"] "
139 << last_location <<
"->" << new_location <<
HT_END;
std::set< String > StringSet
STL Set managing Strings.
BalanceAlgorithmOffload(ContextPtr &context, std::vector< RangeServerStatistics > &statistics, String arguments)
static const char * METADATA_ID
std::string String
A String is simply a typedef to std::string.
std::shared_ptr< BalancePlan > BalancePlanPtr
std::shared_ptr< TableScanner > TableScannerPtr
Smart pointer to TableScanner.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Scan predicate and control specification.
Compatibility Macros for C/C++.
virtual void compute_plan(BalancePlanPtr &plan, std::vector< RangeServerConnectionPtr > &balanced)
Declarations for general-purpose utility functions.
std::vector< RangeServerStatistics > m_statistics
const char * column_family
String root_range_location(ContextPtr &context)
Returns location of root METADATA range.
bool split(int flags)
Tests the SPLIT bit of flags
static const char * END_ROOT_ROW
std::shared_ptr< RangeMoveSpec > RangeMoveSpecPtr
Encapsulates decomposed key and value.
std::set< String > m_offload_servers
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)