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

Abstract base class for server protocol drivers. More...

#include <Protocol.h>

Inheritance diagram for Hypertable::Protocol:
Inheritance graph
[legend]

Public Member Functions

virtual ~Protocol ()
 Destructor. More...
 
virtual const char * command_text (uint64_t command)=0
 Returns the string representation of a command code. More...
 

Static Public Member Functions

static int32_t response_code (const Event *event)
 Returns the response code from an event event generated in response to a request message. More...
 
static int32_t response_code (const EventPtr &event)
 Returns the response code from an event event generated in response to a request message. More...
 
static String string_format_message (const Event *event)
 Returns error message decoded standard error MESSAGE generated in response to a request message. More...
 
static String string_format_message (const EventPtr &event)
 Returns error message decoded from standard error MESSAGE generated in response to a request message. More...
 
static CommBufPtr create_error_message (CommHeader &header, int error, const char *msg)
 Creates a standard error message response. More...
 

Detailed Description

Abstract base class for server protocol drivers.

This is the base class for all server protocol drivers. A server protocol driver is responsible for encoding and decoding messages sent and received to and from a service.

Definition at line 49 of file Protocol.h.

Constructor & Destructor Documentation

virtual Hypertable::Protocol::~Protocol ( )
inlinevirtual

Destructor.

Definition at line 54 of file Protocol.h.

Member Function Documentation

virtual const char* Hypertable::Protocol::command_text ( uint64_t  command)
pure virtual

Returns the string representation of a command code.

Each protocol defines a set of command codes that are sent in the CommHeader::command field of a reqeust's message header to indicate which server command (method) is to be executed. This method returns a human readable string mnemonic for the command.

Parameters
commandCommand code
Returns
Pointer to human readable string mnemonic for command.

Implemented in Hyperspace::Protocol.

CommBufPtr Protocol::create_error_message ( CommHeader header,
int  error,
const char *  msg 
)
static

Creates a standard error message response.

This method creates a standard error message response encoded in the following format:

  [int32] error code
  [int16] error message length
  [chars] error message
Parameters
headerReference to header to use in response buffer
errorError code
msgError message
Returns
Pointer to Commbuf message holding standard error response

Definition at line 81 of file Protocol.cc.

int32_t Protocol::response_code ( const Event event)
static

Returns the response code from an event event generated in response to a request message.

If event is of type ERROR, then event->error is returned, otherwise the response code is decoded from the first four bytes of the message payload.

Returns
Error or response code from event or Error::SERIALIZATION_INPUT_OVERRUN if payload of MESSAGE event is less than 4 bytes.

Definition at line 39 of file Protocol.cc.

static int32_t Hypertable::Protocol::response_code ( const EventPtr event)
inlinestatic

Returns the response code from an event event generated in response to a request message.

If event is of type ERROR, then event->error is returned, otherwise the response code is decoded from the first four bytes of the message payload.

Returns
Error or response code from event or Error::SERIALIZATION_INPUT_OVERRUN if payload of MESSAGE event is less than 4 bytes.

Definition at line 76 of file Protocol.h.

String Protocol::string_format_message ( const Event event)
static

Returns error message decoded standard error MESSAGE generated in response to a request message.

When a request to a service method results in an error, the error code an message are typically returned in a response message encoded in the following format:

  [int32] error code
  [int16] error message length
  [chars] error message

This method extracts and returns the error message from a response MESSAGE event.

Note
The semantics of this method are wacky, it should be re-written
Parameters
eventPointer to MESSAGE event received in response to a request
Returns
Error message

Definition at line 51 of file Protocol.cc.

static String Hypertable::Protocol::string_format_message ( const EventPtr event)
inlinestatic

Returns error message decoded from standard error MESSAGE generated in response to a request message.

When a request to a service method results in an error, the error code an message are typically returned in a response message encoded in the following format:

  [int32] error code
  [int16] error message length
  [chars] error message

This method extracts and returns the error message from a response MESSAGE event.

Note
The semantics of this method are wacky, it should be re-written
Parameters
eventPointer to MESSAGE event received in response to a request
Returns
Error message

Definition at line 112 of file Protocol.h.


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