hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Voldemort.cpp
Go to the documentation of this file.
1 
15 #ifdef _USE_VOLDEMORT_DB_
16 
17 
21 #include "Voldemort.hpp"
22 
26 #include "voldemort/VersionedValue.h"
27 
31 #include <list>
32 #include <string>
33 
34 namespace HCE
35 {
36 
37 
39  _config.setBootstrapUrls(&_bootstrapUrls);
40  _factory = Poco::SharedPtr<Voldemort::SocketStoreClientFactory>(new Voldemort::SocketStoreClientFactory(_config)) ;
41  }
42 
43 
45 
46 
47  void VoldemortDB::setDatabaseName(const std::string& dbName) {
48  _dbName = dbName;
49  _client = Poco::SharedPtr<Voldemort::StoreClient>( _factory->getStoreClient(_dbName) );
50  }
51 
52 
53  void VoldemortDB::put(const std::string& key, const std::string& value) {
55  try {
56  _client->put(&key, &value);
57  } catch(Voldemort::VoldemortException& e) {
59  }
60  }
61 
62 
63  std::string VoldemortDB::get(const std::string& key) {
65  std::string str;
66  const Voldemort::VersionedValue* value;
67  try {
68  value = _client->get(&key);
69  } catch(...) {
70 #ifdef _D_DEBUG_
71  std::cout << "Voldemort::VersionedValue Exception" << std::endl;
72 #endif
73  }
74  if(value) {
76  str = *((value)->getValue());
77  }
78  return str;
79  }
80 
81 
82  std::vector<std::string> VoldemortDB::get_all() {
83 
84  }
85 
86 
87  void VoldemortDB::del(const std::string& key) {
88  bool status = _client->deleteKey(&key);
90  }
91 
92 
93 }
94 
95 
96 #endif