OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
etcd::etcdql::EtcdIf Class Reference

#include <eql_if.h>

Classes

struct  EtcdAsyncCall
 
struct  EtcdAsyncDeleteCall
 
struct  EtcdAsyncGetCall
 
struct  EtcdAsyncSetCall
 
struct  EtcdAsyncWatchCall
 

Public Types

typedef boost::function< void(const
EtcdResponse &Resp)> 
WatchCb
 

Public Member Functions

 EtcdIf (const std::vector< std::string > &etcd_hosts, const int port, bool useSsl)
 
virtual ~EtcdIf ()
 
virtual bool Connect ()
 
virtual EtcdResponse Get (const std::string &key, const std::string &range_end, int limit)
 
virtual void Set (const std::string &key, const std::string &value)
 
virtual void Delete (const std::string &key, const std::string &range_end)
 
virtual void Watch (const std::string &key, WatchCb cb)
 
virtual void StopWatch ()
 
int port () const
 
std::vector< Endpointendpoints () const
 
std::vector< std::string > hosts () const
 

Private Attributes

std::vector< Endpointendpoints_
 
std::vector< std::string > hosts_
 
int port_
 
bool useSsl_
 
std::unique_ptr< KV::Stub > kv_stub_
 
std::unique_ptr< Watch::Stub > watch_stub_
 
std::unique_ptr< EtcdAsyncGetCallget_call_
 
std::unique_ptr< EtcdAsyncSetCallset_call_
 
std::unique_ptr
< EtcdAsyncDeleteCall
delete_call_
 
std::unique_ptr
< EtcdAsyncWatchCall
watch_call_
 

Detailed Description

EtcdIf is the etcd client that is used to create and maintain connection to the etcd server. The methods of the client can be used to perform etcd operations. Control node is only interested in the reading data from or watching changes on a specific key or directory in etcd and hence only those operations are implemented here.

Definition at line 40 of file eql_if.h.

Member Typedef Documentation

typedef boost::function<void (const EtcdResponse& Resp)> etcd::etcdql::EtcdIf::WatchCb

Types

Definition at line 45 of file eql_if.h.

Constructor & Destructor Documentation

EtcdIf::EtcdIf ( const std::vector< std::string > &  etcd_hosts,
const int  port,
bool  useSsl 
)

Constructor that creates an etcd client object.

Parameters
etcd_hostsThe IP address(es)of the etcd server
portThe port to connect to

Definition at line 31 of file eql_if.cc.

Here is the call graph for this function:

EtcdIf::~EtcdIf ( )
virtual

Definition at line 51 of file eql_if.cc.

Member Function Documentation

bool EtcdIf::Connect ( )
virtual

Open a grpc connection to the etcd server.

Definition at line 54 of file eql_if.cc.

void EtcdIf::Delete ( const std::string &  key,
const std::string &  range_end 
)
virtual

ONLY FOR TEST PURPOSES. Sends a DELETE request to the etcd server to delete a key or set of keys

Parameters
keyThe key or directory to be deleted
range_endThe key range to fetch

Set up DELETE request.

Create a SET stream reader and invoke async set.

Parse the DELETE response.

Definition at line 243 of file eql_if.cc.

Here is the call graph for this function:

std::vector<Endpoint> etcd::etcdql::EtcdIf::endpoints ( ) const
inline

Definition at line 108 of file eql_if.h.

EtcdResponse EtcdIf::Get ( const std::string &  key,
const std::string &  range_end,
int  limit 
)
virtual

Sends a GET request to the etcd server to get data for key or directory rooted at key.

Parameters
keyThe key or directory to be read
range_endThe key range to fetch
limitThe number of keys to read

Set up GET request.

Create a GET stream reader and invoke async read.

Parse the GET response.

Definition at line 82 of file eql_if.cc.

Here is the call graph for this function:

std::vector<std::string> etcd::etcdql::EtcdIf::hosts ( ) const
inline

Definition at line 109 of file eql_if.h.

int etcd::etcdql::EtcdIf::port ( ) const
inline

Definition at line 107 of file eql_if.h.

void EtcdIf::Set ( const std::string &  key,
const std::string &  value 
)
virtual

ONLY FOR TEST PURPOSES. Sends a SET request to the etcd server to create or update a key-value pair.

Parameters
keyThe key to be created/updated
valueThe value corresponding to the key.

Set up SET request.

Create a SET stream reader and invoke async set.

Parse the SET response.

Definition at line 190 of file eql_if.cc.

Here is the call graph for this function:

void EtcdIf::StopWatch ( )
virtual

Stop the watch request if scheduled

Definition at line 453 of file eql_if.cc.

void EtcdIf::Watch ( const std::string &  key,
WatchCb  cb 
)
virtual

Watches for changes to a key or directory rooted at key. And invokes callback when an update is received.

Parameters
keyThe key or directory to be watched
callbackThe callback to be invoked when there is an update

Create and start the Async reader-writer stream.

When we start a stream, that is creating the reader/writer object with a tag, we need to use CompletionQueue::Next to wait for the tag to come back before calling Write. Write the watch request to the stream and set up the first read with the tag as the call object.

Definition at line 304 of file eql_if.cc.

Here is the call graph for this function:

Member Data Documentation

std::unique_ptr<EtcdAsyncDeleteCall> etcd::etcdql::EtcdIf::delete_call_
private

Definition at line 160 of file eql_if.h.

std::vector<Endpoint> etcd::etcdql::EtcdIf::endpoints_
private

Data

Definition at line 115 of file eql_if.h.

std::unique_ptr<EtcdAsyncGetCall> etcd::etcdql::EtcdIf::get_call_
private

Definition at line 140 of file eql_if.h.

std::vector<std::string> etcd::etcdql::EtcdIf::hosts_
private

Definition at line 116 of file eql_if.h.

std::unique_ptr<KV::Stub> etcd::etcdql::EtcdIf::kv_stub_
private

Definition at line 119 of file eql_if.h.

int etcd::etcdql::EtcdIf::port_
private

Definition at line 117 of file eql_if.h.

std::unique_ptr<EtcdAsyncSetCall> etcd::etcdql::EtcdIf::set_call_
private

Definition at line 150 of file eql_if.h.

bool etcd::etcdql::EtcdIf::useSsl_
private

Definition at line 118 of file eql_if.h.

std::unique_ptr<EtcdAsyncWatchCall> etcd::etcdql::EtcdIf::watch_call_
private

Definition at line 172 of file eql_if.h.

std::unique_ptr<Watch::Stub> etcd::etcdql::EtcdIf::watch_stub_
private

Definition at line 120 of file eql_if.h.


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