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

DispatchHandler class for managing async RangeServer requests. More...

#include <DispatchHandlerOperation.h>

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

Classes

struct  LtEventPtr
 Strict Weak Ordering for comparing events by source address. More...
 
class  Result
 Holds request result information. More...
 

Public Member Functions

 DispatchHandlerOperation (ContextPtr &context)
 Constructor. More...
 
void start (StringSet &locations)
 Starts asynchronous request. More...
 
virtual void start (const String &location)=0
 Method overridden in derived class for issuing requests. More...
 
virtual void result_callback (const EventPtr &event)
 Post-request hook method. More...
 
virtual void handle (EventPtr &event)
 Process response event. More...
 
bool wait_for_completion ()
 Waits for requests to complete. More...
 
void process_events ()
 Processes m_events set. More...
 
void get_results (std::set< Result > &results)
 Returns the Result set. More...
 
- Public Member Functions inherited from Hypertable::DispatchHandler
virtual ~DispatchHandler ()
 Destructor. More...
 

Protected Attributes

ContextPtr m_context
 Master context More...
 
RangeServer::Client m_rsclient
 Range server client 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...
 
std::set< EventPtr, LtEventPtrm_events
 Set of events generated by range server responses. More...
 
int m_outstanding {}
 Outstanding request count that have not completed. More...
 
int m_error_count {}
 Error count More...
 
StringSet m_locations
 Set of servers participating in operation. More...
 
std::set< Resultm_results
 Set of result objects. More...
 

Detailed Description

DispatchHandler class for managing async RangeServer requests.

This class is a DispatchHandler class that is used for managing asynchronous requests to a set of range servers.

Definition at line 57 of file DispatchHandlerOperation.h.

Constructor & Destructor Documentation

DispatchHandlerOperation::DispatchHandlerOperation ( ContextPtr context)

Constructor.

Parameters
contextMaster context

Definition at line 41 of file DispatchHandlerOperation.cc.

Member Function Documentation

void DispatchHandlerOperation::get_results ( std::set< Result > &  results)

Returns the Result set.

This method copies m_results to the results parameter.

Parameters
resultsReference to Result set to be populated.

Definition at line 132 of file DispatchHandlerOperation.cc.

void DispatchHandlerOperation::handle ( EventPtr event)
virtual

Process response event.

This method inserts event int m_events set, decrements m_outstanding, and then signals m_cond if m_outstanding has dropped to zero

Parameters
eventResponse event

Implements Hypertable::DispatchHandler.

Definition at line 78 of file DispatchHandlerOperation.cc.

void DispatchHandlerOperation::process_events ( )

Processes m_events set.

For each event in m_events, this method creates a Result object, sets the error code and error message extracted from the event payload, and adds the result object to the m_results set. This method also makes a call to result_callback() for each event.

Definition at line 94 of file DispatchHandlerOperation.cc.

virtual void Hypertable::DispatchHandlerOperation::result_callback ( const EventPtr event)
inlinevirtual

Post-request hook method.

This method can be overridden by derived classes to do post-processing on each request result.

Parameters
eventResponse event

Reimplemented in Hypertable::DispatchHandlerOperationSystemStatus, and Hypertable::DispatchHandlerOperationGetStatistics.

Definition at line 107 of file DispatchHandlerOperation.h.

void DispatchHandlerOperation::start ( StringSet locations)

Starts asynchronous request.

This method first initializes m_error_count to 0, m_locations to locations, and m_outstanding to locations.size(), and then kicks of a request for each location with a call to start().

Parameters
locationsSet of locations for which to issue requests

Definition at line 46 of file DispatchHandlerOperation.cc.

virtual void Hypertable::DispatchHandlerOperation::start ( const String location)
pure virtual
bool DispatchHandlerOperation::wait_for_completion ( )

Waits for requests to complete.

This method waits on m_cond until m_outstanding drops to zero and then calls process_events().

Returns
true if all requests completed without error, false otherwise.

Definition at line 124 of file DispatchHandlerOperation.cc.

Member Data Documentation

std::condition_variable Hypertable::DispatchHandlerOperation::m_cond
private

Condition variable used to wait for completion.

Definition at line 160 of file DispatchHandlerOperation.h.

ContextPtr Hypertable::DispatchHandlerOperation::m_context
protected

Master context

Definition at line 142 of file DispatchHandlerOperation.h.

int Hypertable::DispatchHandlerOperation::m_error_count {}
private

Error count

Definition at line 169 of file DispatchHandlerOperation.h.

std::set<EventPtr, LtEventPtr> Hypertable::DispatchHandlerOperation::m_events
private

Set of events generated by range server responses.

Definition at line 163 of file DispatchHandlerOperation.h.

StringSet Hypertable::DispatchHandlerOperation::m_locations
private

Set of servers participating in operation.

Definition at line 172 of file DispatchHandlerOperation.h.

std::mutex Hypertable::DispatchHandlerOperation::m_mutex
private

Mutex for serializing concurrent access

Definition at line 157 of file DispatchHandlerOperation.h.

int Hypertable::DispatchHandlerOperation::m_outstanding {}
private

Outstanding request count that have not completed.

Definition at line 166 of file DispatchHandlerOperation.h.

std::set<Result> Hypertable::DispatchHandlerOperation::m_results
private

Set of result objects.

Definition at line 175 of file DispatchHandlerOperation.h.

RangeServer::Client Hypertable::DispatchHandlerOperation::m_rsclient
protected

Range server client object

Definition at line 145 of file DispatchHandlerOperation.h.


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