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

Handles incoming Master requests. More...

#include <ConnectionHandler.h>

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

Public Member Functions

 ConnectionHandler (ContextPtr &context)
 Constructor. More...
 
void start_timer ()
 
virtual void handle (EventPtr &event)
 Responds to Master request events. More...
 
- Public Member Functions inherited from Hypertable::DispatchHandler
virtual ~DispatchHandler ()
 Destructor. More...
 

Private Member Functions

int32_t send_id_response (EventPtr &event, OperationPtr &operation)
 Sends operation ID back to client. More...
 
int32_t send_error_response (EventPtr &event, int32_t error, const String &msg)
 Sends error response message back to client. More...
 
int32_t send_ok_response (EventPtr &event, bool silent=false)
 Sends OK response message back to client. More...
 
void maybe_dump_op_statistics ()
 Maybe dumps OperationProcessor statistics. More...
 

Private Attributes

ContextPtr m_context
 Pointer to Master context. More...
 

Detailed Description

Handles incoming Master requests.

An object of this class is installed as the dispatch handler for the listen socket on which the Master receives client connections and requests. To handle transparent master failover while requests are being carried out, most requests happen in two phases:

  1. An operation is created to carry out the request and its ID is sent back to client
  2. Client issues MasterProtocol::COMMAND_FETCH_RESULT request to fetch result of operation

After the operation has been created and persisted to the MML and the ID has been sent back to the client, the Master can fail and when the new Master comes up, it will complete the operation and send the results back to the client. This class also installs an interval timer and installs itself as the handler. When handling TIMER events, it checks to see if any of the following actions are necessary, and if so, it will create operations to carry them out.

Definition at line 65 of file ConnectionHandler.h.

Constructor & Destructor Documentation

Hypertable::ConnectionHandler::ConnectionHandler ( ContextPtr context)
inline

Constructor.

This initializes the connection handler and installs the interval timer.

Parameters
contextMaster context object

Definition at line 72 of file ConnectionHandler.h.

Member Function Documentation

void ConnectionHandler::handle ( EventPtr event)
virtual

Responds to Master request events.

Parameters
eventAsyncComm event corresponding to Master request

Implements Hypertable::DispatchHandler.

Definition at line 84 of file ConnectionHandler.cc.

void ConnectionHandler::maybe_dump_op_statistics ( )
private

Maybe dumps OperationProcessor statistics.

This method check for the existance of the file $HT_INSTALL_DIR/run/debug-op and if it exists, it will remove it and then call OperationProcessor::state_description() and will write the state description message to the file $HT_INSTALL_DIR/run/op.output.

Definition at line 325 of file ConnectionHandler.cc.

int32_t ConnectionHandler::send_error_response ( EventPtr event,
int32_t  error,
const String msg 
)
private

Sends error response message back to client.

This method sends an error respons message back to the client formatted as 32-bit error code by vstring error message.

Parameters
eventAsyncComm event corresponding to Master request
errorError code
msgError message
Returns
Error::OK if response send back successfully, otherwise error code returned by Comm::send_response

Definition at line 312 of file ConnectionHandler.cc.

int32_t ConnectionHandler::send_id_response ( EventPtr event,
OperationPtr operation 
)
private

Sends operation ID back to client.

Parameters
eventAsyncComm event corresponding to Master request
operationOperation whose ID is to be sent back

Definition at line 286 of file ConnectionHandler.cc.

int32_t ConnectionHandler::send_ok_response ( EventPtr event,
bool  silent = false 
)
private

Sends OK response message back to client.

Parameters
eventAsyncComm event corresponding to Master request
silentDon't log if errors encountered
Returns
Error::OK if response send back successfully, otherwise error code returned by Comm::send_response

Definition at line 300 of file ConnectionHandler.cc.

void ConnectionHandler::start_timer ( )

Definition at line 78 of file ConnectionHandler.cc.

Member Data Documentation

ContextPtr Hypertable::ConnectionHandler::m_context
private

Pointer to Master context.

Definition at line 118 of file ConnectionHandler.h.


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