LogCabin
|
A handle to the LogCabin cluster. More...
#include <Client.h>
Public Types | |
typedef std::map< std::string, std::string > | Options |
Settings for the client library. | |
Public Member Functions | |
Cluster (std::shared_ptr< TestingCallbacks > testingCallbacks, const Options &options=Options()) | |
Construct a Cluster object for testing purposes only. | |
Cluster (const std::string &hosts, const Options &options=Options()) | |
Constructor. | |
~Cluster () | |
Destructor. | |
std::pair< uint64_t, Configuration > | getConfiguration () const |
Get the current, stable cluster configuration. | |
GetConfigurationResult | getConfiguration2 (uint64_t timeoutNanoseconds) const |
Get the current, stable cluster configuration. | |
GetConfigurationResult | getConfiguration2Ex (uint64_t timeoutNanoseconds) const |
Like getConfiguration2 but throws exceptions upon errors. | |
ConfigurationResult | setConfiguration (uint64_t oldId, const Configuration &newConfiguration) |
Change the cluster's configuration. | |
ConfigurationResult | setConfiguration2 (uint64_t oldId, const Configuration &newConfiguration, uint64_t timeoutNanoseconds) |
Like setConfiguration but allows a timeout. | |
ConfigurationResult | setConfiguration2Ex (uint64_t oldId, const Configuration &newConfiguration, uint64_t timeoutNanoseconds) |
Like setConfiguration2 but throws exceptions upon errors. | |
Result | getServerInfo (const std::string &host, uint64_t timeoutNanoseconds, Server &info) |
Retrieve basic information from the given server, like its ID and the addresses on which it is listening. | |
Server | getServerInfoEx (const std::string &host, uint64_t timeoutNanoseconds) |
Like getServerInfo but throws exceptions upon errors. | |
Result | getServerStats (const std::string &host, uint64_t timeoutNanoseconds, Protocol::ServerStats &stats) |
Retrieve statistics from the given server, which are useful for diagnostics. | |
Protocol::ServerStats | getServerStatsEx (const std::string &host, uint64_t timeoutNanoseconds) |
Like getServerStats but throws exceptions upon errors. | |
Tree | getTree () |
Return an object to access the hierarchical key-value store. | |
Private Attributes | |
std::shared_ptr< ClientImpl > | clientImpl |
A handle to the LogCabin cluster.
If the client requests changes to the cluster's replicated state machine (for example, by writing a value), the client library will first open a session with the cluster. It will thereafter periodically send keep-alive requests to the cluster during periods of inactivity to maintain this session. If communication to the LogCabin cluster is lost for an extended period of time, the client's session will expire, and this library will force the client to crash.
typedef std::map<std::string, std::string> LogCabin::Client::Cluster::Options |
Settings for the client library.
These are all optional. Currently supported options:
LogCabin::Client::Cluster::Cluster | ( | std::shared_ptr< TestingCallbacks > | testingCallbacks, |
const Options & | options = Options() |
||
) | [explicit] |
Construct a Cluster object for testing purposes only.
Instead of connecting to a LogCabin cluster, it will keep all state locally in memory.
This is experimental and is not part of LogCabin's public API.
testingCallbacks | These allow the application to interpose on requests. A default-constructed TestingCallbacks will execute requests against an in-memory structure. Applications can pass in classes derived from TestingCallbacks to model failures and more dynamic scenarios. |
options | Settings for the client library (see Options). |
LogCabin::Client::Cluster::Cluster | ( | const std::string & | hosts, |
const Options & | options = Options() |
||
) | [explicit] |
Constructor.
hosts | A 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. Alternatively, you can pass a list of hosts as host1:port1,host2:port2,host3:port3. |
options | Settings for the client library (see Options). |
std::pair< uint64_t, Configuration > LogCabin::Client::Cluster::getConfiguration | ( | ) | const |
GetConfigurationResult LogCabin::Client::Cluster::getConfiguration2 | ( | uint64_t | timeoutNanoseconds | ) | const |
Get the current, stable cluster configuration.
timeoutNanoseconds | Amount of time to wait for getConfiguration to complete. Passing 0 indicates that no timeout is desired. |
GetConfigurationResult LogCabin::Client::Cluster::getConfiguration2Ex | ( | uint64_t | timeoutNanoseconds | ) | const |
ConfigurationResult LogCabin::Client::Cluster::setConfiguration | ( | uint64_t | oldId, |
const Configuration & | newConfiguration | ||
) |
ConfigurationResult LogCabin::Client::Cluster::setConfiguration2 | ( | uint64_t | oldId, |
const Configuration & | newConfiguration, | ||
uint64_t | timeoutNanoseconds | ||
) |
Like setConfiguration but allows a timeout.
oldId | The ID of the cluster's current configuration. |
newConfiguration | The list of servers in the new configuration. |
timeoutNanoseconds | Amount of time to wait for the call to complete. 0=wait forever |
ConfigurationResult LogCabin::Client::Cluster::setConfiguration2Ex | ( | uint64_t | oldId, |
const Configuration & | newConfiguration, | ||
uint64_t | timeoutNanoseconds | ||
) |
Result LogCabin::Client::Cluster::getServerInfo | ( | const std::string & | host, |
uint64_t | timeoutNanoseconds, | ||
Server & | info | ||
) |
Retrieve basic information from the given server, like its ID and the addresses on which it is listening.
host | The hostname or IP address of the server to retrieve stats from. It is recommended that you do not use a DNS name that resolves to multiple hosts here. |
timeoutNanoseconds | Abort the operation if it has not completed within the specified period of time. Time is specified in nanoseconds, and the special value of 0 indicates no timeout. |
[out] | info | Protocol buffer of Stats as retrieved from the server. |
Server LogCabin::Client::Cluster::getServerInfoEx | ( | const std::string & | host, |
uint64_t | timeoutNanoseconds | ||
) |
Result LogCabin::Client::Cluster::getServerStats | ( | const std::string & | host, |
uint64_t | timeoutNanoseconds, | ||
Protocol::ServerStats & | stats | ||
) |
Retrieve statistics from the given server, which are useful for diagnostics.
host | The hostname or IP address of the server to retrieve stats from. It is recommended that you do not use a DNS name that resolves to multiple hosts here. |
timeoutNanoseconds | Abort the operation if it has not completed within the specified period of time. Time is specified in nanoseconds, and the special value of 0 indicates no timeout. |
[out] | stats | Protocol buffer of Stats as retrieved from the server. |
Protocol::ServerStats LogCabin::Client::Cluster::getServerStatsEx | ( | const std::string & | host, |
uint64_t | timeoutNanoseconds | ||
) |
std::shared_ptr<ClientImpl> LogCabin::Client::Cluster::clientImpl [private] |