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::RangeServerHyperspaceCallback Class Reference

Callback class for range server lock files. More...

#include <RangeServerHyperspaceCallback.h>

Inheritance diagram for Hypertable::RangeServerHyperspaceCallback:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::RangeServerHyperspaceCallback:
Collaboration graph
[legend]

Public Member Functions

 RangeServerHyperspaceCallback (ContextPtr &context, RangeServerConnectionPtr &rsc)
 Constructor. More...
 
virtual void lock_released ()
 Responds to lock release event. More...
 
virtual void lock_acquired (uint32_t mode)
 Responds to lock acquired event. More...
 
bool wait_for_lock_acquisition (std::chrono::milliseconds max_wait)
 Waits for m_lock_held to become true. More...
 
- Public Member Functions inherited from Hyperspace::HandleCallback
 HandleCallback (uint32_t event_mask)
 Constructor. More...
 
virtual void attr_set (const std::string &name)
 Invoked when an attribute gets set on the file associated with the registered handle. More...
 
virtual void attr_del (const std::string &name)
 Invoked when an attribute gets deleted from the file associated with the registered handle. More...
 
virtual void child_node_added (const std::string &name)
 Invoked when a child node gets added to the directory associated with the registered handle. More...
 
virtual void child_node_removed (const std::string &name)
 Invoked when an attribute gets deleted from the file associated with the registered handle. More...
 
int get_event_mask ()
 Returns the event mask of this callback object. More...
 

Private Attributes

std::mutex m_mutex
 Mutex for serializing concurrent access More...
 
std::condition_variable m_cond
 Condition variable used to wait for completion. More...
 
ContextPtr m_context
 Master context More...
 
RangeServerConnectionPtr m_rsc
 Range server connection More...
 
bool m_lock_held
 Flag indicating if lock is currently held. More...
 

Additional Inherited Members

- Protected Attributes inherited from Hyperspace::HandleCallback
uint32_t m_event_mask
 

Detailed Description

Callback class for range server lock files.

An object of this class is registered with each range server lock file in Hyperspace and is used to handle the disconnect and reconnect of a range server. It specifically takes measures to ensure that a range server does not get re-registered until it has received a lock released event for the server from Hyperspace.

Definition at line 57 of file RangeServerHyperspaceCallback.h.

Constructor & Destructor Documentation

Hypertable::RangeServerHyperspaceCallback::RangeServerHyperspaceCallback ( ContextPtr context,
RangeServerConnectionPtr rsc 
)
inline

Constructor.

Initializes object by passing Hyperspace::EVENT_MASK_LOCK_ACQUIRED and Hyperspace::EVENT_MASK_LOCK_RELEASED into the parent constructor.

Parameters
contextMaster context
rscRange server connection object

Definition at line 66 of file RangeServerHyperspaceCallback.h.

Member Function Documentation

virtual void Hypertable::RangeServerHyperspaceCallback::lock_acquired ( uint32_t  mode)
inlinevirtual

Responds to lock acquired event.

This method will be called when the range server identified by m_rsc acquires the lock on its Hyperspace lock file. It sets m_lock_held to true and signals m_cond.

Parameters
modethe mode in which the lock was acquired

Reimplemented from Hyperspace::HandleCallback.

Definition at line 113 of file RangeServerHyperspaceCallback.h.

virtual void Hypertable::RangeServerHyperspaceCallback::lock_released ( )
inlinevirtual

Responds to lock release event.

This method performs the following actions:

  1. Sets m_lock_held to false and signals m_cond
  2. Removes the server from list of available servers with a call to Context::remove_available_server()
  3. If the server is connected, it advances the recovery barrier (m_context->recovery_barrier_op to Hypertable.Failover.GracePeriod milliseconds in the future and then creates an OperationRecover for the server and adds it to the OperationProcessor.
  4. Unblocks operations with obstruction label "<server-name> register" to allow any pending register server operation for this server to proceed.

Reimplemented from Hyperspace::HandleCallback.

Definition at line 85 of file RangeServerHyperspaceCallback.h.

bool Hypertable::RangeServerHyperspaceCallback::wait_for_lock_acquisition ( std::chrono::milliseconds  max_wait)
inline

Waits for m_lock_held to become true.

This method waits on m_cond until m_lock_held becomes true.

Parameters
deadlineTimeout if m_lock_held does not become true by this absolute time
Returns
false if deadline reached before m_lock_held becomes true, otherwise returns true

Definition at line 127 of file RangeServerHyperspaceCallback.h.

Member Data Documentation

std::condition_variable Hypertable::RangeServerHyperspaceCallback::m_cond
private

Condition variable used to wait for completion.

Definition at line 138 of file RangeServerHyperspaceCallback.h.

ContextPtr Hypertable::RangeServerHyperspaceCallback::m_context
private

Master context

Definition at line 141 of file RangeServerHyperspaceCallback.h.

bool Hypertable::RangeServerHyperspaceCallback::m_lock_held
private

Flag indicating if lock is currently held.

Definition at line 147 of file RangeServerHyperspaceCallback.h.

std::mutex Hypertable::RangeServerHyperspaceCallback::m_mutex
private

Mutex for serializing concurrent access

Definition at line 135 of file RangeServerHyperspaceCallback.h.

RangeServerConnectionPtr Hypertable::RangeServerHyperspaceCallback::m_rsc
private

Range server connection

Definition at line 144 of file RangeServerHyperspaceCallback.h.


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