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

Timer handler for periodically flushing a shared mutator. More...

#include <TableMutatorIntervalHandler.h>

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

Public Member Functions

 TableMutatorIntervalHandler (Comm *comm, ApplicationQueueInterface *app_queue, TableMutatorShared *shared_mutator)
 Constructor. More...
 
void start ()
 Starts interval timer. More...
 
virtual void handle (EventPtr &event)
 Handles the timer interrupt. More...
 
void flush ()
 Flushes shared mutator shared_mutator. More...
 
void stop ()
 Stops the periodic flushing of the shared mutator. More...
 
- Public Member Functions inherited from Hypertable::DispatchHandler
virtual ~DispatchHandler ()
 Destructor. More...
 

Private Attributes

std::mutex mutex
 Mutex for serializing access to members More...
 
std::condition_variable cond
 Condition variable signalled when complete is set to true More...
 
bool active
 Set to false to deactivate and prevent further timer interrupts. More...
 
bool complete
 Indicates if final timer interrupt has completed. More...
 
Commcomm
 Pointer to AsyncComm subsystem. More...
 
ApplicationQueueInterfaceapp_queue
 Pointer to application queue. More...
 
TableMutatorSharedshared_mutator
 Shared mutator to be periodically flushed. More...
 

Detailed Description

Timer handler for periodically flushing a shared mutator.

This class is used as the timer handler for periodically flushing a shared mutator. The class is initialized with a shared mutator (shared_mutator) which it flushes on a periodic interval. It registers itself as the timer handler in a call to Comm::set_timer(), using shared_mutator->flush_interval() as the duration, and causes the shared mutator to get flushed each time the handle() method is called.

Definition at line 51 of file TableMutatorIntervalHandler.h.

Constructor & Destructor Documentation

TableMutatorIntervalHandler::TableMutatorIntervalHandler ( Comm comm,
ApplicationQueueInterface app_queue,
TableMutatorShared shared_mutator 
)

Constructor.

Initializes members comm, app_queue, and shared_mutator with the comm, app_queue, and shared_mutator parameters, respectively. It also picks a random number between 0 and shared_mutator->flush_interval() and schedules a timer interrupt for that many milliseconds in the future. It does this to smooth out the flush times of potentially hundreds or thousands of clients that start up at the same time.

Parameters
commPointer to AsyncComm subsystem
app_queueApplication queue
shared_mutatorShared mutator

Definition at line 39 of file TableMutatorIntervalHandler.cc.

Member Function Documentation

void TableMutatorIntervalHandler::flush ( )

Flushes shared mutator shared_mutator.

If active is true, this method flushes shared_mutator, otherwise it does nothing. This method is typically called from a TableMutatorFlushHandler object that gets enqueued on app_queue from the handle() method.

Definition at line 75 of file TableMutatorIntervalHandler.cc.

void TableMutatorIntervalHandler::handle ( EventPtr event)
virtual

Handles the timer interrupt.

If active is true then a TableMutatorFlushHandler object will get created and enqueued on app_queue and then timer will be re-registered with a call to Comm::set_timer() using this object as the handler and shared_mutator->flush_interval() for the duration. Otherwise, if active is false, complete will get set to true and cond will be notified.

Parameters
eventEvent object generated from AsyncComm (usually TIMER event)

Implements Hypertable::DispatchHandler.

Definition at line 60 of file TableMutatorIntervalHandler.cc.

void TableMutatorIntervalHandler::start ( )

Starts interval timer.

Definition at line 45 of file TableMutatorIntervalHandler.cc.

void Hypertable::TableMutatorIntervalHandler::stop ( )
inline

Stops the periodic flushing of the shared mutator.

This method sets active to false and then waits on cond until complete becomes true.

Definition at line 95 of file TableMutatorIntervalHandler.h.

Member Data Documentation

bool Hypertable::TableMutatorIntervalHandler::active
private

Set to false to deactivate and prevent further timer interrupts.

Definition at line 110 of file TableMutatorIntervalHandler.h.

ApplicationQueueInterface* Hypertable::TableMutatorIntervalHandler::app_queue
private

Pointer to application queue.

Definition at line 119 of file TableMutatorIntervalHandler.h.

Comm* Hypertable::TableMutatorIntervalHandler::comm
private

Pointer to AsyncComm subsystem.

Definition at line 116 of file TableMutatorIntervalHandler.h.

bool Hypertable::TableMutatorIntervalHandler::complete
private

Indicates if final timer interrupt has completed.

Definition at line 113 of file TableMutatorIntervalHandler.h.

std::condition_variable Hypertable::TableMutatorIntervalHandler::cond
private

Condition variable signalled when complete is set to true

Definition at line 107 of file TableMutatorIntervalHandler.h.

std::mutex Hypertable::TableMutatorIntervalHandler::mutex
private

Mutex for serializing access to members

Definition at line 104 of file TableMutatorIntervalHandler.h.

TableMutatorShared* Hypertable::TableMutatorIntervalHandler::shared_mutator
private

Shared mutator to be periodically flushed.

Definition at line 122 of file TableMutatorIntervalHandler.h.


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