46 #include <boost/algorithm/string.hpp>
54 : m_context(context) {
56 Path data_dir =
m_context->props->get_str(
"Hypertable.DataDirectory");
68 char location_hash[33];
69 uint16_t port =
m_context->props->get_i16(
"Hypertable.RangeServer.Port");
76 HT_ERRORF(
"Problem reading location file '%s'", m_location_file.c_str());
77 quick_exit(EXIT_FAILURE);
95 handle = hyperspace->open(filename, oflags);
96 if (hyperspace->attr_exists(handle,
"removed"))
108 lock_guard<mutex> lock(
m_mutex);
110 const char *base, *ptr;
111 String datadirs =
m_context->props->get_str(
"Hypertable.RangeServer.Monitoring.DataDirectories");
112 uint16_t port =
m_context->props->get_i16(
"Hypertable.RangeServer.Port");
114 std::vector<String> dirs;
116 base = datadirs.c_str();
117 while ((ptr = strchr(base,
',')) != 0) {
118 dir =
String(base, ptr-base);
131 CommHeader header(Master::Protocol::COMMAND_REGISTER_SERVER);
144 HT_ERROR_OUT <<
"Problem initializing Master connection - "
149 bool location_persisted =
false;
152 const uint8_t *ptr =
event->payload + 4;
153 size_t remain =
event->payload_len - 4;
155 params.
decode(&ptr, &remain);
161 lock_guard<mutex> lock(
m_mutex);
170 if (!location_persisted) {
173 quick_exit(EXIT_FAILURE);
176 lock_guard<mutex> lock(
m_mutex);
185 lock_guard<mutex> lock(
m_mutex);
190 unique_lock<mutex> lock(
m_mutex);
LocationInitializer(std::shared_ptr< Context > &context)
Constructor.
Network communication event.
String m_location_file
Local pathname to location file.
static int32_t response_code(const Event *event)
Returns the response code from an event event generated in response to a request message.
static bool read(const String &fname, String &contents)
Reads a whole file into a String.
std::string String
A String is simply a typedef to std::string.
Compatibility class for boost::filesystem::path.
static String string_format_message(const Event *event)
Returns error message decoded standard error MESSAGE generated in response to a request message...
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
virtual size_t encoded_length() const
Returns serialized object length.
Declarations for SystemVariable.
Declarations for Protocol.
bool process_initialization_response(Event *event) override
Process response to initialization message.
static ssize_t write(const String &fname, const std::string &contents)
Writes a String buffer to a file; the file is overwritten if it already exists.
static bool exists(const String &fname)
Checks if a file or directory exists.
uint8_t ** get_data_ptr_address()
Returns address of the primary buffer internal data pointer.
static bool mkdirs(const String &dirname)
Creates a directory (with all parent directories, if required)
Request parameters for register server operation.
Collecting and (de)serializing system-wide statistics.
#define HT_ON_SCOPE_EXIT(...)
CommBuf * create_initialization_request() override
Creates a connection initialization message.
std::condition_variable m_cond
Condition variable signalling completion of initialization handshake.
Compatibility class for boost::filesystem::path.
File system utility functions.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
std::shared_ptr< Session > SessionPtr
Logging routines and macros.
void close_handle_ptr(SessionPtr hyperspace, uint64_t *handlep)
Compatibility Macros for C/C++.
Functions to serialize/deserialize primitives to/from a memory buffer.
void md5_string(const char *input, char output[33])
Calculates the hex string of MD5 of null terminated input.
String m_location
Assigned location (proxy name)
int64_t generation()
Gets system state generation.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
bool m_location_persisted
Flag indicating if assigned location has been written to location file.
Collects, serializes and deserializes system-wide statistics.
const string & location() const
Gets location (proxy name)
virtual bool is_removed(const String &path, Hyperspace::SessionPtr &hyperspace)
Checks if "removed" attribute is set on Hyperspace location file.
void wait_for_handshake()
Waits for completion of initialization handshake.
bool m_lock_held
Flag indicating that Hyperspace lock on location file is held.
std::mutex m_mutex
Mutex for serializing concurrent access.
This is a generic exception class for Hypertable.
Message buffer for holding data to be transmitted over a network.
void add_categories(int32_t categories)
Adds more categories to the already existing categories.
Response parameters for register server operation.
#define HT_ERRORF(msg,...)
const vector< SystemVariable::Spec > & variables()
Gets state variables.
Declarations for LocationInitializer.
Declarations for RegisterServer response parameters.
Declarations for RegisterServer request parameters.
bool m_handshake_complete
Flag indicating completion of initialization handshake.
static const NetInfo & net_info()
Retrieves updated Network information (see SystemInfo.h)
int code() const
Returns the error code.
Executes user-defined functions when leaving the current scope.
String get()
Gets assigned location (proxy name)
std::shared_ptr< Context > m_context
Range server context