#include <Master.h>
Classes | |
struct | CommandContext |
struct | EventContext |
Public Types | |
enum | { TIMER_INTERVAL_MS =1000 } |
enum | { HANDLE_NOT_DEL = 1, HANDLE_MARKED_FOR_DEL = 2 } |
Public Member Functions | |
Master (ConnectionManagerPtr &, PropertiesPtr &, ServerKeepaliveHandlerPtr &, ApplicationQueuePtr &app_queue_ptr) | |
~Master () | |
bool | is_master () |
String | get_current_master () |
void | mkdir (ResponseCallback *cb, uint64_t session_id, const char *name, const std::vector< Attribute > &init_attrs) |
void | mkdirs (ResponseCallback *cb, uint64_t session_id, const char *name, const std::vector< Attribute > &init_attrs) |
void | unlink (ResponseCallback *cb, uint64_t session_id, const char *name) |
void | open (ResponseCallbackOpen *cb, uint64_t session_id, const char *name, uint32_t flags, uint32_t event_mask, std::vector< Attribute > &init_attrs) |
void | close (ResponseCallback *cb, uint64_t session_id, uint64_t handle) |
void | attr_set (ResponseCallback *cb, uint64_t session_id, uint64_t handle, const char *name, uint32_t oflags, const std::vector< Attribute > &attrs) |
void | attr_get (ResponseCallbackAttrGet *cb, uint64_t session_id, uint64_t handle, const char *name, const std::vector< String > &attrs) |
void | attr_incr (ResponseCallbackAttrIncr *cb, uint64_t session_id, uint64_t handle, const char *name, const char *attr) |
void | attr_del (ResponseCallback *cb, uint64_t session_id, uint64_t handle, const char *name) |
void | attr_exists (ResponseCallbackAttrExists *cb, uint64_t session_id, uint64_t handle, const char *name, const char *attr) |
void | attr_list (ResponseCallbackAttrList *cb, uint64_t session_id, uint64_t handle) |
void | exists (ResponseCallbackExists *cb, uint64_t session_id, const char *name) |
void | readdir (ResponseCallbackReaddir *cb, uint64_t session_id, uint64_t handle) |
void | readdir_attr (ResponseCallbackReaddirAttr *cb, uint64_t session_id, uint64_t handle, const char *name, const char *attr, bool include_sub_entries) |
void | readpath_attr (ResponseCallbackReadpathAttr *cb, uint64_t session_id, uint64_t handle, const char *name, const char *attr) |
void | shutdown (ResponseCallback *cb, uint64_t session_id) |
void | status (ResponseCallbackStatus *cb) |
void | lock (ResponseCallbackLock *cb, uint64_t session_id, uint64_t handle, uint32_t mode, bool try_lock) |
void | release (ResponseCallback *cb, uint64_t session_id, uint64_t handle) |
uint64_t | create_session (struct sockaddr_in &addr) |
bool | get_session (uint64_t session_id, SessionDataPtr &session_data) |
void | destroy_session (uint64_t session_id) |
void | initialize_session (uint64_t session_id, const String &name) |
int | renew_session_lease (uint64_t session_id) |
bool | next_expired_session (SessionDataPtr &, std::chrono::steady_clock::time_point now) |
void | remove_expired_sessions () |
void | get_datagram_send_address (struct sockaddr_in *addr) |
void | tick () |
void | handle_sleep () |
Handle sleep event (e.g. More... | |
void | handle_wakeup () |
Handle wakeup event (e.g. More... | |
void | do_maintenance () |
Private Types | |
typedef std::vector < SessionDataPtr > | SessionDataVec |
typedef std::unordered_map < uint64_t, SessionDataPtr > | SessionMap |
Private Member Functions | |
void | mkdir (CommandContext &ctx, const char *name) |
void | unlink (CommandContext &ctx, const char *name) |
void | open (CommandContext &ctx, const char *name, uint32_t flags, uint32_t event_mask, std::vector< Attribute > &init_attrs, uint64_t &handle, bool &created, uint64_t &lock_generation) |
void | close (CommandContext &ctx, uint64_t handle) |
void | attr_set (CommandContext &ctx, uint64_t handle, const char *name, const std::vector< Attribute > &attrs) |
void | attr_get (CommandContext &ctx, uint64_t handle, const char *name, const char *attr, DynamicBuffer &dbuf) |
void | attr_get (CommandContext &ctx, uint64_t handle, const char *name, const std::vector< String > &attrs, std::vector< DynamicBufferPtr > &dbufs) |
void | attr_incr (CommandContext &ctx, uint64_t handle, const char *name, const char *attr, uint64_t &attr_val) |
void | attr_del (CommandContext &ctx, uint64_t handle, const char *name) |
void | attr_exists (CommandContext &ctx, uint64_t handle, const char *name, const char *attr, bool &exists) |
void | attr_list (CommandContext &ctx, uint64_t handle, std::vector< String > &attributes) |
void | exists (CommandContext &ctx, const char *name, bool &file_exists) |
void | readdir (CommandContext &ctx, uint64_t handle, std::vector< DirEntry > &listing) |
void | readdir_attr (CommandContext &ctx, uint64_t handle, const char *name, const char *attr, bool include_sub_entries, std::vector< DirEntryAttr > &listing) |
void | readpath_attr (CommandContext &ctx, uint64_t handle, const char *name, const char *attr, std::vector< DirEntryAttr > &listing) |
bool | get_handle_node (CommandContext &ctx, uint64_t handle, const char *attr, String &node) |
bool | get_named_node (CommandContext &ctx, const char *name, const char *attr, String &node, bool *is_dir=0) |
void | create_event (CommandContext &ctx, const String &node, uint32_t event_mask, const String &name) |
void | deliver_event_notifications (CommandContext &ctx, bool wait_for_notify=true) |
void | deliver_event_notifications (EventContext &evt, bool wait_for_notify=true) |
void | get_generation_number () |
void | normalize_name (std::string name, std::string &normal) |
void | deliver_event_notifications (HyperspaceEventPtr &event_ptr, NotificationMap &handles_to_sessions, bool wait_for_notify=true) |
void | persist_event_notifications (BDbTxn &txn, uint64_t event_id, NotificationMap &handles_to_sessions) |
void | persist_event_notifications (BDbTxn &txn, uint64_t event_id, uint64_t handle) |
bool | validate_and_create_node_data (BDbTxn &txn, const String &node) |
bool | find_parent_node (const std::string &normal_name, std::string &parent_name, std::string &child_name) |
bool | destroy_handle (uint64_t handle, int &error, String &errmsg, bool wait_for_notify=true) |
void | release_lock (BDbTxn &txn, uint64_t handle, const String &node, HyperspaceEventPtr &release_event, NotificationMap &release_notifications) |
void | lock_handle (BDbTxn &txn, uint64_t handle, uint32_t mode, String &node) |
void | lock_handle (BDbTxn &txn, uint64_t handle, uint32_t mode, const String &node) |
void | lock_handle_with_notification (uint64_t handle, uint32_t mode, bool wait_for_notify=true) |
void | grant_pending_lock_reqs (BDbTxn &txn, const String &node, HyperspaceEventPtr &lock_granted_event, NotificationMap &lock_granted_notifications, HyperspaceEventPtr &lock_acquired_event, NotificationMap &lock_acquired_notifications) |
Private Attributes | |
bool | m_verbose |
uint32_t | m_lease_interval |
uint32_t | m_keep_alive_interval |
uint32_t | m_maintenance_interval |
std::string | m_base_dir |
std::string | m_lock_file |
int | m_lock_fd |
uint32_t | m_generation |
uint64_t | m_next_handle_number |
uint64_t | m_next_session_id |
ServerKeepaliveHandlerPtr | m_keepalive_handler_ptr |
struct sockaddr_in | m_local_addr |
SessionDataVec | m_session_heap |
SessionMap | m_session_map |
MetricsHandlerPtr | m_metrics_handler |
std::mutex | m_session_map_mutex |
std::mutex | m_last_tick_mutex |
std::mutex | m_maintenance_mutex |
bool | m_maintenance_outstanding |
std::chrono::steady_clock::time_point | m_last_tick |
std::chrono::steady_clock::time_point | m_sleep_time |
Suspension time recorded by handle_sleep() More... | |
bool | m_shutdown {} |
BerkeleyDbFilesystem * | m_bdb_fs |
Status | m_status |
Program status tracker. More... | |
|
private |
|
private |
anonymous enum |
Hyperspace::Master::Master | ( | ConnectionManagerPtr & | conn_mgr, |
PropertiesPtr & | props, | ||
ServerKeepaliveHandlerPtr & | keepalive_handler, | ||
ApplicationQueuePtr & | app_queue_ptr | ||
) |
void Hyperspace::Master::attr_del | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name | ||
) |
|
private |
void Hyperspace::Master::attr_exists | ( | ResponseCallbackAttrExists * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name, | ||
const char * | attr | ||
) |
|
private |
void Hyperspace::Master::attr_get | ( | ResponseCallbackAttrGet * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name, | ||
const std::vector< String > & | attrs | ||
) |
|
private |
|
private |
void Hyperspace::Master::attr_incr | ( | ResponseCallbackAttrIncr * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name, | ||
const char * | attr | ||
) |
|
private |
void Hyperspace::Master::attr_list | ( | ResponseCallbackAttrList * | cb, |
uint64_t | session_id, | ||
uint64_t | handle | ||
) |
|
private |
void Hyperspace::Master::attr_set | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name, | ||
uint32_t | oflags, | ||
const std::vector< Attribute > & | attrs | ||
) |
|
private |
void Hyperspace::Master::close | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
uint64_t | handle | ||
) |
|
private |
|
private |
uint64_t Hyperspace::Master::create_session | ( | struct sockaddr_in & | addr | ) |
|
private |
|
private |
|
private |
|
private |
void Hyperspace::Master::destroy_session | ( | uint64_t | session_id | ) |
void Hyperspace::Master::exists | ( | ResponseCallbackExists * | cb, |
uint64_t | session_id, | ||
const char * | name | ||
) |
|
private |
|
private |
|
inline |
|
private |
|
private |
|
private |
bool Hyperspace::Master::get_session | ( | uint64_t | session_id, |
SessionDataPtr & | session_data | ||
) |
|
private |
void Hyperspace::Master::handle_sleep | ( | ) |
Handle sleep event (e.g.
laptop close). This method works in conjunction with handle_wakeup() to allow Hyperspace to continue working after the machine on which it is running has been suspended and resumed, for example when the laptop is closed and then reopened. It records the current time in m_sleep_time, which is then used by handle_wakeup() to extend session leases.
void Hyperspace::Master::handle_wakeup | ( | ) |
Handle wakeup event (e.g.
laptop open). This method works in conjunction with handle_sleep() to allow Hyperspace to continue working after the machine on which it is running has been suspended and resumed, for example when the laptop is closed and then reopened. It extends all session leases by an amount computed as follows:
(now - m_sleep_time) + lease_interval
void Hyperspace::Master::initialize_session | ( | uint64_t | session_id, |
const String & | name | ||
) |
void Hyperspace::Master::lock | ( | ResponseCallbackLock * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
uint32_t | mode, | ||
bool | try_lock | ||
) |
|
private |
void Hyperspace::Master::mkdir | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
const char * | name, | ||
const std::vector< Attribute > & | init_attrs | ||
) |
|
private |
void Hyperspace::Master::mkdirs | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
const char * | name, | ||
const std::vector< Attribute > & | init_attrs | ||
) |
bool Hyperspace::Master::next_expired_session | ( | SessionDataPtr & | session_data, |
std::chrono::steady_clock::time_point | now | ||
) |
|
private |
void Hyperspace::Master::open | ( | ResponseCallbackOpen * | cb, |
uint64_t | session_id, | ||
const char * | name, | ||
uint32_t | flags, | ||
uint32_t | event_mask, | ||
std::vector< Attribute > & | init_attrs | ||
) |
|
private |
|
private |
|
private |
void Hyperspace::Master::readdir | ( | ResponseCallbackReaddir * | cb, |
uint64_t | session_id, | ||
uint64_t | handle | ||
) |
|
private |
void Hyperspace::Master::readdir_attr | ( | ResponseCallbackReaddirAttr * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name, | ||
const char * | attr, | ||
bool | include_sub_entries | ||
) |
|
private |
void Hyperspace::Master::readpath_attr | ( | ResponseCallbackReadpathAttr * | cb, |
uint64_t | session_id, | ||
uint64_t | handle, | ||
const char * | name, | ||
const char * | attr | ||
) |
|
private |
void Hyperspace::Master::release | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
uint64_t | handle | ||
) |
|
private |
int Hyperspace::Master::renew_session_lease | ( | uint64_t | session_id | ) |
void Hyperspace::Master::shutdown | ( | ResponseCallback * | cb, |
uint64_t | session_id | ||
) |
void Hyperspace::Master::status | ( | ResponseCallbackStatus * | cb | ) |
void Hyperspace::Master::unlink | ( | ResponseCallback * | cb, |
uint64_t | session_id, | ||
const char * | name | ||
) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Suspension time recorded by handle_sleep()
|
private |