LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Friends
LogCabin::Client::LeaderRPCBase Class Reference

This class is used to send RPCs from clients to the leader of the LogCabin cluster. More...

#include <LeaderRPC.h>

Inheritance diagram for LogCabin::Client::LeaderRPCBase:
LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC LogCabin::Client::LeaderRPC LogCabin::Client::LeaderRPCMock

List of all members.

Classes

class  Call
 An asynchronous version of call(). More...

Public Types

enum  Status {
  OK,
  TIMEOUT,
  INVALID_REQUEST
}
 Return type for LeaderRPCBase::call(). More...
typedef RPC::ClientRPC::Clock Clock
 Clock used for timeouts.
typedef RPC::ClientRPC::TimePoint TimePoint
 Type for absolute time values used for timeouts.
typedef Protocol::Client::OpCode OpCode
 RPC operation code.

Public Member Functions

 LeaderRPCBase ()
 Constructor.
virtual ~LeaderRPCBase ()
 Destructor.
virtual Status call (OpCode opCode, const google::protobuf::Message &request, google::protobuf::Message &response, TimePoint timeout)=0
 Execute an RPC on the cluster leader.
virtual std::unique_ptr< CallmakeCall ()=0
 Return a new Call object.
 LeaderRPCBase (const LeaderRPCBase &)
LeaderRPCBaseoperator= (const LeaderRPCBase &)

Friends

std::ostream & operator<< (std::ostream &os, const Status &server)
 Print out a Status for debugging purposes.

Detailed Description

This class is used to send RPCs from clients to the leader of the LogCabin cluster.

It automatically finds and connects to the leader and transparently rolls over to a new leader when necessary.

There are two implementations of this interface: LeaderRPC is probably the one you're interested in. LeaderRPCMock is used for unit testing only.

Definition at line 61 of file LeaderRPC.h.


Member Typedef Documentation

Clock used for timeouts.

Definition at line 64 of file LeaderRPC.h.

Type for absolute time values used for timeouts.

Definition at line 66 of file LeaderRPC.h.

typedef Protocol::Client::OpCode LogCabin::Client::LeaderRPCBase::OpCode

RPC operation code.

Definition at line 71 of file LeaderRPC.h.


Member Enumeration Documentation

Return type for LeaderRPCBase::call().

Enumerator:
OK 

The RPC completed scucessfully.

TIMEOUT 

The given timeout elapsed before the RPC completed.

INVALID_REQUEST 

The server rejected the request, probably because it doesn't support the opcode, or maybe the request arguments were invalid.

Definition at line 76 of file LeaderRPC.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 98 of file LeaderRPC.h.

virtual LogCabin::Client::LeaderRPCBase::~LeaderRPCBase ( ) [inline, virtual]

Destructor.

Definition at line 101 of file LeaderRPC.h.


Member Function Documentation

virtual Status LogCabin::Client::LeaderRPCBase::call ( OpCode  opCode,
const google::protobuf::Message &  request,
google::protobuf::Message &  response,
TimePoint  timeout 
) [pure virtual]

Execute an RPC on the cluster leader.

This class guarantees that the RPC will be executed at least once.

Parameters:
opCodeRPC operation code. The caller must guarantee that this is a valid opCode. (If the server rejects it, this will PANIC.)
requestThe parameters for the operation. The caller must guarantee that this is a well-formed request. (If the server rejects it, this will PANIC.)
timeoutAfter this time has elapsed, stop waiting and return TIMEOUT. In this case, response will be left unmodified.
[out]responseThe response to the operation will be filled in here.

Implemented in LogCabin::Client::LeaderRPC, LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC, and LogCabin::Client::LeaderRPCMock.

virtual std::unique_ptr<Call> LogCabin::Client::LeaderRPCBase::makeCall ( ) [pure virtual]
LeaderRPCBase& LogCabin::Client::LeaderRPCBase::operator= ( const LeaderRPCBase )

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Status server 
) [friend]

Print out a Status for debugging purposes.

Definition at line 33 of file LeaderRPC.cc.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines