0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
Hypertable::Master::HyperspaceMasterFile Class Reference

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
 
HyperspaceMasterFileoperator= (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...
 

Detailed Description

Facilitates operations on the master file in Hyperspace.

Definition at line 48 of file HyperspaceMasterFile.h.

Constructor & Destructor Documentation

Hypertable::Master::HyperspaceMasterFile::HyperspaceMasterFile ( PropertiesPtr  props,
SessionPtr hyperspace 
)
inline

Constructor.

Parameters
propsSmart pointer to properties object
hyperspaceSmart pointer to hyperspace session

Definition at line 54 of file HyperspaceMasterFile.h.

Hypertable::Master::HyperspaceMasterFile::HyperspaceMasterFile ( const HyperspaceMasterFile )
delete
HyperspaceMasterFile::~HyperspaceMasterFile ( )

Destructor.

Definition at line 40 of file HyperspaceMasterFile.cc.

Member Function Documentation

bool Hypertable::Master::HyperspaceMasterFile::lock_acquired ( )
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.

Returns
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.

template<typename Function >
bool Hypertable::Master::HyperspaceMasterFile::obtain_master_lock ( const std::string &  toplevel_dir,
Function  set_startup_status 
)
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.

Template Parameters
FunctionStartup function type
Parameters
toplevel_dirTop-level directory containing master file in Hyperspace
set_startup_statusFunction to be called to set startup status
Returns
true if lock successfully acquired, false if returning due to shutdown

Definition at line 86 of file HyperspaceMasterFile.h.

HyperspaceMasterFile& Hypertable::Master::HyperspaceMasterFile::operator= ( const HyperspaceMasterFile )
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).

Note
The top-level directory /hypertable may be different depending on the Hypertable.Directory property.

Definition at line 54 of file HyperspaceMasterFile.cc.

Member Data Documentation

bool Hypertable::Master::HyperspaceMasterFile::m_acquired {}
private

Lock acquired flag.

Definition at line 189 of file HyperspaceMasterFile.h.

std::condition_variable Hypertable::Master::HyperspaceMasterFile::m_cond
private

Condition variable signalling shutdown.

Definition at line 174 of file HyperspaceMasterFile.h.

uint64_t Hypertable::Master::HyperspaceMasterFile::m_handle
private

Master file handle

Definition at line 183 of file HyperspaceMasterFile.h.

SessionPtr Hypertable::Master::HyperspaceMasterFile::m_hyperspace
private

Hyperspace session.

Definition at line 180 of file HyperspaceMasterFile.h.

std::mutex Hypertable::Master::HyperspaceMasterFile::m_mutex
private

Mutex for serializing member access

Definition at line 171 of file HyperspaceMasterFile.h.

PropertiesPtr Hypertable::Master::HyperspaceMasterFile::m_props
private

Properties.

Definition at line 177 of file HyperspaceMasterFile.h.

bool Hypertable::Master::HyperspaceMasterFile::m_shutdown {}
private

Shutdown flag.

Definition at line 186 of file HyperspaceMasterFile.h.


The documentation for this class was generated from the following files: