LogCabin
|
This class is used to send RPCs from clients to the leader of the LogCabin cluster. More...
#include <LeaderRPC.h>
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< Call > | makeCall ()=0 |
Return a new Call object. | |
LeaderRPCBase (const LeaderRPCBase &) | |
LeaderRPCBase & | operator= (const LeaderRPCBase &) |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Status &server) |
Print out a Status for debugging purposes. |
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.
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.
Return type for LeaderRPCBase::call().
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.
LogCabin::Client::LeaderRPCBase::LeaderRPCBase | ( | ) | [inline] |
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.
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.
opCode | RPC operation code. The caller must guarantee that this is a valid opCode. (If the server rejects it, this will PANIC.) | |
request | The parameters for the operation. The caller must guarantee that this is a well-formed request. (If the server rejects it, this will PANIC.) | |
timeout | After this time has elapsed, stop waiting and return TIMEOUT. In this case, response will be left unmodified. | |
[out] | response | The 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] |
Return a new Call object.
Implemented in LogCabin::Client::LeaderRPC, LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC, and LogCabin::Client::LeaderRPCMock.
LeaderRPCBase& LogCabin::Client::LeaderRPCBase::operator= | ( | const LeaderRPCBase & | ) |
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.