66 if (context->test_mode) {
67 context->get_available_servers(servers);
72 start_row =
format(
"%s:",
id.c_str());
76 start_row =
format(
"%s:%s",
id.c_str(), row.c_str());
84 scan_spec.
columns.push_back(
"Location");
86 ri.
start = start_row.c_str();
87 ri.
end = end_row.c_str();
90 scanner.reset( context->metadata_table->create_scanner(scan_spec) );
92 while (scanner->next(cell)) {
94 boost::trim(location);
96 servers.insert(location);
105 if (!context->namemap->name_to_id(name,
id, &is_namespace) ||
109 String tablefile = context->toplevel_dir +
"/tables/" + id;
112 if (context->hyperspace->attr_exists(tablefile,
"x"))
128 for (
auto cf_spec : s->get_column_families()) {
129 if (cf_spec && !cf_spec->get_deleted()) {
130 if (cf_spec->get_value_index())
132 if (cf_spec->get_qualifier_index())
142 String tablefile = context->toplevel_dir +
"/tables/" + id;
145 if (context->hyperspace->attr_exists(tablefile,
"x"))
163 if (!context->namemap->name_to_id(name,
id, &is_namespace))
169 String tablefile = context->toplevel_dir +
"/tables/" + id;
172 if (context->hyperspace->attr_exists(tablefile,
"x"))
187 if (table_name[0] ==
'/')
188 table_name = table_name.substr(1);
194 context->namemap->add_mapping(table_name, table_id, 0,
true);
204 String tablefile = context->toplevel_dir +
"/tables/" + table_id;
208 context->hyperspace->attr_set(tablefile, oflags,
"schema", schema_str.c_str(),
209 schema_str.length());
215 String table_basedir = context->toplevel_dir +
"/tables/" + table_id +
"/";
219 for (
auto ag_spec : schema->get_access_groups()) {
220 String agdir = table_basedir + ag_spec->get_name();
221 context->dfs->mkdirs(agdir);
230 const String &schema_str,
bool qualifier,
250 primary_schema->get_group_commit_interval());
259 if (index_name ==
"/")
265 if (index_name ==
"/")
271 index_schema_str = index_schema->
render_xml();
277 if (context->test_mode) {
278 HT_WARN(
"Skipping create_table_write_metadata due to TEST MODE");
282 TableMutatorPtr mutator_ptr(context->metadata_table->create_mutator());
287 key.
row = metadata_key_str.c_str();
288 key.
row_len = metadata_key_str.length();
296 mutator_ptr->set(key, 0, 0);
298 mutator_ptr->flush();
306 if (!context->rsc_manager->next_available_server(rsc, urgent))
308 location = rsc->location();
318 if (context->test_mode) {
320 HT_WARNF(
"Skipping %s::load_range() because in TEST MODE", location.c_str());
321 HT_ASSERT(context->rsc_manager->find_server_by_location(location, rsc));
322 if (!rsc->connected())
331 int64_t split_size = context->props->get_i64(
"Hypertable.RangeServer.Range.SplitSize");
334 range_state.
soft_limit = context->props->get_i64(
"Hypertable.RangeServer.Range.MetadataSplitSize", split_size);
337 if (context->props->get_bool(
"Hypertable.Master.Split.SoftLimitEnabled"))
338 range_state.
soft_limit /= std::min(64, (
int)context->rsc_manager->server_count()*2);
341 rsc.
load_range(addr, table, range, range_state, needs_compaction);
355 if (context->test_mode) {
357 HT_WARNF(
"Skipping %s::acknowledge_load() because in TEST MODE", location.c_str());
358 HT_ASSERT(context->rsc_manager->find_server_by_location(location, rsc));
359 if (!rsc->connected())
367 vector<QualifiedRangeSpec *> range_vec;
368 map<QualifiedRangeSpec, int> response_map;
369 range_vec.push_back(&qrs);
371 map<QualifiedRangeSpec, int>::iterator it = response_map.begin();
375 HT_THROW(it->second,
"Problem acknowledging load range");
380 if (!qualifier.empty())
392 uint64_t root_handle=0;
393 String toplevel_dir = context->props->get_str(
"Hypertable.Directory");
397 root_handle = context->hyperspace->open(toplevel_dir +
"/root",
OPEN_FLAG_READ);
398 context->hyperspace->attr_get(root_handle,
"Location", value);
399 location = (
const char *)value.
base;
409 if (context->startup_in_progress())
411 else if (context->shutdown_in_progress())
413 else if (!context->master_file->lock_acquired())
415 else if (context->quorum_reached) {
416 size_t connected_servers = context->available_server_count();
417 size_t total_servers = context->rsc_manager->server_count();
418 if (connected_servers < total_servers) {
420 = context->props->get_i32(
"Hypertable.Failover.Quorum.Percentage");
421 size_t quorum = ((total_servers * failover_pct) + 99) / 100;
422 if (connected_servers == 0)
424 "RangeServer recovery blocked because 0 servers available.");
425 else if (connected_servers < quorum)
427 format(
"RangeServer recovery blocked (%d servers "
428 "available, quorum of %d is required)",
429 (
int)connected_servers, (
int)quorum));
434 context->dfs->status(status, &timer);
437 status.
get(&code, text);
439 status.
set(code,
format(
"FsBroker %s", text.c_str()));
std::set< String > StringSet
STL Set managing Strings.
#define HT_THROW2F(_code_, _ex_, _fmt_,...)
void set_version(int32_t version)
Sets version number.
bool next_available_server(ContextPtr &context, String &location, bool urgent)
Gets name of next available server.
#define HT_WARNF(msg,...)
void prepare_index(ContextPtr &context, const String &name, const String &schema_str, bool qualifier, String &index_name, String &index_schema_str)
Prepares index schema and table name.
The FailureInducer simulates errors.
int64_t md5_hash(const char *input)
Returns a 64-bit hash checksum of a null terminated input buffer.
static const char * METADATA_ID
Holds Nagios-style program status information.
std::shared_ptr< RangeServerConnection > RangeServerConnectionPtr
std::string String
A String is simply a typedef to std::string.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
static constexpr const char * SERVER_IS_SHUTTING_DOWN
static const char * METADATA_NAME
Declarations for TableIdentifier and TableIdentifierManaged.
const char * column_qualifier
void acknowledge_load(const CommAddress &addr, const vector< QualifiedRangeSpec * > &ranges, std::map< QualifiedRangeSpec, int > &response_map)
Issues a synchronous "acknowledge load" request for multiple ranges.
Column family specification.
uint64_t soft_limit
Soft split size limit.
Declarations for CommAddress.
void create_table_load_range(ContextPtr &context, const String &location, TableIdentifier &table, RangeSpec &range, bool needs_compaction)
Loads a table's initial range.
void create_table_acknowledge_range(ContextPtr &context, const String &location, TableIdentifier &table, RangeSpec &range)
Calls RangeServer::acknowledge_load for a range.
int64_t range_hash_code(const TableIdentifier &table, const RangeSpec &range, const String &qualifier)
Returns a hash code for a range with an optional qualifer string.
#define HT_ON_SCOPE_EXIT(...)
size_t column_qualifier_len
Declarations for RangeServerClient.
std::shared_ptr< TableScanner > TableScannerPtr
Smart pointer to TableScanner.
void set(Code code, const std::string &text)
Sets status code and text.
A dynamic, resizable and reference counted memory buffer.
Represents a set of table parts (sub-tables).
Code
Enumeration for status codes.
Represents a row interval.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
String range_hash_string(const TableIdentifier &table, const RangeSpec &range, const String &qualifier)
Returns string representation of hash code for a range with an optional qualifer string.
Wrapper for TableIdentifier providing member storage.
void verify_table_name_availability(ContextPtr &context, const String &name, String &id)
Checks if table name is available.
Scan predicate and control specification.
std::shared_ptr< TableMutator > TableMutatorPtr
Smart pointer to TableMutator.
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
static constexpr const char * STANDBY
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
void set_proxy(const String &str)
Sets address type to CommAddress::PROXY and proxy name to p.
void shutdown(const CommAddress &addr)
Issues a "shutdown" request.
void close_handle_ptr(SessionPtr hyperspace, uint64_t *handlep)
Compatibility Macros for C/C++.
AccessGroupOptions & access_group_defaults()
Returns reference to default access group options.
static String basename(String name, char separator= '/')
A posix-compliant basename() which strips directory names from a filename.
Time related declarations.
void merge(const ColumnFamilyOptions &other)
Merges options from another ColumnFamilyOptions object.
Declarations for RangeSpec and RangeSpecManaged.
Access group specification.
bool table_exists(ContextPtr &context, const String &id)
Checks if table ID exists.
static Schema * new_instance(const std::string &buf)
Creates schema object from XML schema string.
void set_id(const std::string &new_name)
static void get(Status &status)
Gets persistent status.
Declarations for general-purpose utility functions.
void add_access_group(AccessGroupSpec *ag)
Adds access group specification.
void create_table_in_hyperspace(ContextPtr &context, const String &name, const String &schema_str, TableIdentifierManaged *table)
Creates a table in Hyperspace.
void set_access_group(const std::string &ag)
Sets access group.
ColumnFamilyOptions & column_family_defaults()
Returns reference to default column family options.
void create_table_write_metadata(ContextPtr &context, TableIdentifier *table)
Creates initial METADATA table entry for table.
Client interface to RangeServer.
uint8_t * base
Pointer to the allocated memory buffer.
void get(Code *code, std::string &text) const
Gets status code and text.
void get_table_server_set(ContextPtr &context, const String &id, const String &row, StringSet &servers)
Gets set of servers holding ranges for a given table.
String root_range_location(ContextPtr &context)
Returns location of root METADATA range.
RowIntervals row_intervals
A timer class to keep timeout states across AsyncComm related calls.
This is a generic exception class for Hypertable.
void set_group_commit_interval(int32_t interval)
Sets group commit interval.
static const char * END_ROOT_ROW
Declarations for StatusPersister.
Qualified (with table identifier) range specification.
Create file if it does not exist.
void shutdown_rangeserver(ContextPtr &context, CommAddress &addr)
Sends a shutdown command to a rangeserver.
static String dirname(String name, char separator= '/')
A posix-compliant dirname() which strips the last component from a file name.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
TableParts get_index_parts(const std::string &schema)
Gets index parts specified in schema.
void load_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range_spec, const RangeState &range_state, bool needs_compaction)
Issues a synchronous "load range" request.
#define HT_MAYBE_FAIL(_label_)
Encapsulates decomposed key and value.
String extensions and helpers: sets, maps, append operators etc.
const char * column_family
#define HT_THROW(_code_, _msg_)
void add_column(ColumnFamilySpec *cf)
Adds column family specification.
static const char * END_ROW_MARKER
Declarations for Context.
static constexpr const char * SERVER_IS_COMING_UP
const std::string render_xml(bool with_ids=false)
Renders schema in XML format.
Address abstraction to hold either proxy name or IPv4:port address.
int64_t get_ts64()
Returns the current time in nanoseconds as a 64bit number.
int code() const
Returns the error code.
void update_generation(int64_t generation)
Updates generation and assigns column family IDs.
void merge(const AccessGroupOptions &other)
Merges options from another AccessGroupOptions object.
#define HT_THROW2(_code_, _ex_, _msg_)
Executes user-defined functions when leaving the current scope.