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

The implementation of the client library. More...

#include <ClientImpl.h>

Inheritance diagram for LogCabin::Client::ClientImpl:
LogCabin::Client::MockClientImpl

List of all members.

Classes

class  ExactlyOnceRPCHelper
 This class helps with providing exactly-once semantics for read-write RPCs. More...

Public Types

typedef LeaderRPC::Clock Clock
 Clock used for timeouts.
typedef LeaderRPC::TimePoint TimePoint
 Type for absolute time values used for timeouts.

Public Member Functions

 ClientImpl (const std::map< std::string, std::string > &options=std::map< std::string, std::string >())
 Constructor.
virtual ~ClientImpl ()
 Destructor.
void init (const std::string &hosts)
 Initialize this object.
virtual void initDerived ()
 Called by init() to do any necessary initialization of the derived class.
GetConfigurationResult getConfiguration (TimePoint timeout)
ConfigurationResult setConfiguration (uint64_t oldId, const Configuration &newConfiguration, TimePoint timeout)
Result getServerInfo (const std::string &host, TimePoint timeout, Server &info)
 See Cluster::getServerInfo.
Result canonicalize (const std::string &path, const std::string &workingDirectory, std::string &canonical)
 Return the canonicalized path name resulting from accessing path relative to workingDirectory.
Result makeDirectory (const std::string &path, const std::string &workingDirectory, const Condition &condition, TimePoint timeout)
 See Tree::makeDirectory.
Result listDirectory (const std::string &path, const std::string &workingDirectory, const Condition &condition, TimePoint timeout, std::vector< std::string > &children)
 See Tree::listDirectory.
Result removeDirectory (const std::string &path, const std::string &workingDirectory, const Condition &condition, TimePoint timeout)
 See Tree::removeDirectory.
Result write (const std::string &path, const std::string &workingDirectory, const std::string &contents, const Condition &condition, TimePoint timeout)
 See Tree::write.
Result read (const std::string &path, const std::string &workingDirectory, const Condition &condition, TimePoint timeout, std::string &contents)
 See Tree::read.
Result removeFile (const std::string &path, const std::string &workingDirectory, const Condition &condition, TimePoint timeout)
 See Tree::removeFile.
Result serverControl (const std::string &host, TimePoint timeout, Protocol::ServerControl::OpCode opCode, const google::protobuf::Message &request, google::protobuf::Message &response)
 Low-level interface to ServerControl service used by Client/ServerControl.cc.

Static Public Member Functions

static TimePoint absTimeout (uint64_t relTimeoutNanos)
 Return the absolute time when the calling operation should timeout.

Protected Member Functions

 ClientImpl (const ClientImpl &)
ClientImploperator= (const ClientImpl &)

Protected Attributes

const Core::Config config
 Options/settings.
Event::Loop eventLoop
 The Event::Loop used to drive the underlying RPC mechanism.
SessionManager::ClusterUUID clusterUUID
 A unique ID for the cluster that this client may connect to.
SessionManager sessionManager
 Used to create new sessions.
Backoff sessionCreationBackoff
 Used to rate-limit the creation of ClientSession objects (TCP connections).
std::string hosts
 Describes the hosts in the cluster.
std::unique_ptr< LeaderRPCBaseleaderRPC
 Used to send RPCs to the leader of the LogCabin cluster.
class
LogCabin::Client::ClientImpl::ExactlyOnceRPCHelper 
exactlyOnceRPCHelper
std::thread eventLoopThread
 A thread that runs the Event::Loop.

Detailed Description

The implementation of the client library.

This is wrapped by Client::Cluster and Client::Log for usability.

Definition at line 52 of file ClientImpl.h.


Member Typedef Documentation

Clock used for timeouts.

Definition at line 55 of file ClientImpl.h.

Type for absolute time values used for timeouts.

Definition at line 57 of file ClientImpl.h.


Constructor & Destructor Documentation

LogCabin::Client::ClientImpl::ClientImpl ( const std::map< std::string, std::string > &  options = std::map<std::string, std::string>()) [explicit]

Constructor.

Definition at line 439 of file ClientImpl.cc.

Destructor.

Definition at line 461 of file ClientImpl.cc.


Member Function Documentation

ClientImpl::TimePoint LogCabin::Client::ClientImpl::absTimeout ( uint64_t  relTimeoutNanos) [static]

Return the absolute time when the calling operation should timeout.

Parameters:
relTimeoutNanosThe number of nanoseconds from now to time out, or 0 for no timeout.

Definition at line 426 of file ClientImpl.cc.

void LogCabin::Client::ClientImpl::init ( const std::string &  hosts)

Initialize this object.

This must be called directly after the constructor.

Parameters:
hostsA string describing the hosts in the cluster. This should be of the form host:port, where host is usually a DNS name that resolves to multiple IP addresses, or a comma-delimited list.

Definition at line 470 of file ClientImpl.cc.

Called by init() to do any necessary initialization of the derived class.

Reimplemented in LogCabin::Client::MockClientImpl.

Definition at line 478 of file ClientImpl.cc.

Definition at line 491 of file ClientImpl.cc.

ConfigurationResult LogCabin::Client::ClientImpl::setConfiguration ( uint64_t  oldId,
const Configuration newConfiguration,
TimePoint  timeout 
)

Definition at line 519 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::getServerInfo ( const std::string &  host,
TimePoint  timeout,
Server info 
)

See Cluster::getServerInfo.

Definition at line 567 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::canonicalize ( const std::string &  path,
const std::string &  workingDirectory,
std::string &  canonical 
)

Return the canonicalized path name resulting from accessing path relative to workingDirectory.

Returns:
Status and error message. Possible errors are:
  • INVALID_ARGUMENT if path is relative and workingDirectory is not an absolute path.
  • INVALID_ARGUMENT if path attempts to access above the root directory.

Definition at line 631 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::makeDirectory ( const std::string &  path,
const std::string &  workingDirectory,
const Condition condition,
TimePoint  timeout 
)

See Tree::makeDirectory.

Definition at line 687 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::listDirectory ( const std::string &  path,
const std::string &  workingDirectory,
const Condition condition,
TimePoint  timeout,
std::vector< std::string > &  children 
)

See Tree::listDirectory.

Definition at line 711 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::removeDirectory ( const std::string &  path,
const std::string &  workingDirectory,
const Condition condition,
TimePoint  timeout 
)

See Tree::removeDirectory.

Definition at line 737 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::write ( const std::string &  path,
const std::string &  workingDirectory,
const std::string &  contents,
const Condition condition,
TimePoint  timeout 
)

See Tree::write.

Definition at line 761 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::read ( const std::string &  path,
const std::string &  workingDirectory,
const Condition condition,
TimePoint  timeout,
std::string &  contents 
)

See Tree::read.

Definition at line 787 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::removeFile ( const std::string &  path,
const std::string &  workingDirectory,
const Condition condition,
TimePoint  timeout 
)

See Tree::removeFile.

Definition at line 811 of file ClientImpl.cc.

Result LogCabin::Client::ClientImpl::serverControl ( const std::string &  host,
TimePoint  timeout,
Protocol::ServerControl::OpCode  opCode,
const google::protobuf::Message &  request,
google::protobuf::Message &  response 
)

Low-level interface to ServerControl service used by Client/ServerControl.cc.

Definition at line 835 of file ClientImpl.cc.

ClientImpl& LogCabin::Client::ClientImpl::operator= ( const ClientImpl ) [protected]

Member Data Documentation

Options/settings.

Definition at line 168 of file ClientImpl.h.

The Event::Loop used to drive the underlying RPC mechanism.

Definition at line 173 of file ClientImpl.h.

A unique ID for the cluster that this client may connect to.

This is initialized to a value from the options map passed to the Client::Cluster constructor. If it's not set then, it may be set later as a result of learning a UUID from some server.

Definition at line 181 of file ClientImpl.h.

Used to create new sessions.

Definition at line 186 of file ClientImpl.h.

Used to rate-limit the creation of ClientSession objects (TCP connections).

Definition at line 192 of file ClientImpl.h.

std::string LogCabin::Client::ClientImpl::hosts [protected]

Describes the hosts in the cluster.

Definition at line 197 of file ClientImpl.h.

Used to send RPCs to the leader of the LogCabin cluster.

Definition at line 202 of file ClientImpl.h.

A thread that runs the Event::Loop.

Definition at line 334 of file ClientImpl.h.


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