Facilitates operations on the master file in Hyperspace. More...
#include <HyperspaceMasterFile.h>
Public Member Functions | |
HyperspaceMasterFile (PropertiesPtr props, SessionPtr &hyperspace) | |
Constructor. More... | |
HyperspaceMasterFile (const HyperspaceMasterFile &)=delete | |
HyperspaceMasterFile & | operator= (const HyperspaceMasterFile &)=delete |
~HyperspaceMasterFile () | |
Destructor. More... | |
template<typename Function > | |
bool | obtain_master_lock (const std::string &toplevel_dir, Function set_startup_status) |
Acquires lock on toplevel_dir/master file in hyperspace. More... | |
bool | lock_acquired () |
Returns flag indicating if lock was acquired. More... | |
void | write_master_address () |
Writes Master's listen address to Hyperspace. More... | |
uint64_t | next_server_id () |
Obtains next server ID. More... | |
void | shutdown () |
Private Attributes | |
std::mutex | m_mutex |
Mutex for serializing member access More... | |
std::condition_variable | m_cond |
Condition variable signalling shutdown. More... | |
PropertiesPtr | m_props |
Properties. More... | |
SessionPtr | m_hyperspace |
Hyperspace session. More... | |
uint64_t | m_handle |
Master file handle More... | |
bool | m_shutdown {} |
Shutdown flag. More... | |
bool | m_acquired {} |
Lock acquired flag. More... | |
Facilitates operations on the master file in Hyperspace.
Definition at line 48 of file HyperspaceMasterFile.h.
|
inline |
Constructor.
props | Smart pointer to properties object |
hyperspace | Smart pointer to hyperspace session |
Definition at line 54 of file HyperspaceMasterFile.h.
|
delete |
HyperspaceMasterFile::~HyperspaceMasterFile | ( | ) |
Destructor.
Definition at line 40 of file HyperspaceMasterFile.cc.
|
inline |
Returns flag indicating if lock was acquired.
Definition at line 157 of file HyperspaceMasterFile.h.
uint64_t HyperspaceMasterFile::next_server_id | ( | ) |
Obtains next server ID.
Increments and returns the value of the next_server_id attribute of the hyperspace master file.
Definition at line 65 of file HyperspaceMasterFile.cc.
|
inline |
Acquires lock on toplevel_dir/master
file in hyperspace.
Attempts to acquire an exclusive lock on the file toplevel_dir/master
in Hyperspace. The file is opened and the handle is stored in m_handle. If the lock is successfully acquired, the next_server_id attribute is created and initialized to "1" if it doesn't already exist. It also creates the following directories in Hyperspace if they do not already exist:
/hypertable/servers
/hypertable/tables
/hypertable/root
If the the lock is not successfully acquired, it will go into a retry loop in which the function will sleep for Hypertable.Connection.Retry.Interval
milliseconds and then re-attempt to acquire the lock.
Function | Startup function type |
toplevel_dir | Top-level directory containing master file in Hyperspace |
set_startup_status | Function to be called to set startup status |
Definition at line 86 of file HyperspaceMasterFile.h.
|
delete |
void HyperspaceMasterFile::shutdown | ( | ) |
Definition at line 70 of file HyperspaceMasterFile.cc.
void HyperspaceMasterFile::write_master_address | ( | ) |
Writes Master's listen address to Hyperspace.
This method writes the address on which the Master is listening to the address attribute of the /hypertable/master
in Hyperspace (format is IP:port).
/hypertable
may be different depending on the Hypertable.Directory
property. Definition at line 54 of file HyperspaceMasterFile.cc.
|
private |
Lock acquired flag.
Definition at line 189 of file HyperspaceMasterFile.h.
|
private |
Condition variable signalling shutdown.
Definition at line 174 of file HyperspaceMasterFile.h.
|
private |
Master file handle
Definition at line 183 of file HyperspaceMasterFile.h.
|
private |
Hyperspace session.
Definition at line 180 of file HyperspaceMasterFile.h.
|
private |
Mutex for serializing member access
Definition at line 171 of file HyperspaceMasterFile.h.
|
private |
Definition at line 177 of file HyperspaceMasterFile.h.
|
private |
Shutdown flag.
Definition at line 186 of file HyperspaceMasterFile.h.