Skip to content
Browse files

get node failover working at least minimally

  • Loading branch information...
1 parent ba9282e commit 5e523087f46f813695c2e04fc428e6e67ae7c19d @readams readams committed Jun 12, 2009
Showing with 23 additions and 10 deletions.
  1. +7 −5 bindings/cpp/src/RoutedStore.cpp
  2. +1 −1 bindings/cpp/src/include/RoutedStore.h
  3. +15 −4 bindings/cpp/utils/voldemortShell.cpp
View
12 bindings/cpp/src/RoutedStore.cpp
@@ -35,8 +35,8 @@ RoutedStore::RoutedStore(const std::string& storeName,
shared_ptr<std::map<int, shared_ptr<Store> > >& map,
shared_ptr<threadpool::pool>& pool,
shared_ptr<RoutingStrategy>& routingStrat)
- : name(storeName), cluster(clust), clusterMap(map), threadPool(pool),
- routingStrategy(routingStrat) {
+ : name(storeName), clientConfig(config), cluster(clust), clusterMap(map),
+ threadPool(pool), routingStrategy(routingStrat) {
}
@@ -54,6 +54,8 @@ static bool doGetFromStore(const std::string& key,
node->setAvailable(true);
return true;
} catch (UnreachableStoreException& e) {
+ /* XXX - TODO add real logging */
+ std::cerr << "WARNING: Could not read node: " << e.what() << std::endl;
node->setAvailable(false);
}
return false;
@@ -88,7 +90,7 @@ std::list<VersionedValue>* RoutedStore::get(const std::string& key) {
}
throw InsufficientOperationalNodesException("Could not reach any "
- "node for operation");
+ "node for get operation");
}
static bool doPutFromStore(const std::string& key,
@@ -133,7 +135,7 @@ void RoutedStore::put(const std::string& key, const VersionedValue& value) {
}
throw InsufficientOperationalNodesException("Could not reach any "
- "node for operation");
+ "node for put operation");
}
static bool doDeleteFromStore(const std::string& key,
@@ -180,7 +182,7 @@ bool RoutedStore::deleteKey(const std::string& key, const Version& version) {
}
throw InsufficientOperationalNodesException("Could not reach any "
- "node for operation");
+ "node for delete operation");
}
const std::string* RoutedStore::getName() {
View
2 bindings/cpp/src/include/RoutedStore.h
@@ -71,8 +71,8 @@ class RoutedStore: public Store
private:
std::string name;
- shared_ptr<Cluster> cluster;
shared_ptr<ClientConfig> clientConfig;
+ shared_ptr<Cluster> cluster;
shared_ptr<std::map<int, shared_ptr<Store> > > clusterMap;
shared_ptr<threadpool::pool> threadPool;
shared_ptr<RoutingStrategy> routingStrategy;
View
19 bindings/cpp/utils/voldemortShell.cpp
@@ -34,7 +34,9 @@ int main(int argc, char** argv) {
// cluster. You only need one to be able to use the cluster, but
// more will increase availability when initializing.
list<string> bootstrapUrls;
- bootstrapUrls.push_back(string("tcp://localhost:6666"));
+ for (int i = 1; i < argc; i++) {
+ bootstrapUrls.push_back(string(argv[i]));
+ }
// The store name is essentially a namespace on the Voldemort
// cluster
@@ -53,15 +55,24 @@ int main(int argc, char** argv) {
SocketStoreClientFactory factory(config);
auto_ptr<StoreClient> client(factory.getStoreClient(storeName));
+ if (!client.get()) {
+ cerr << "Error could not construct client object" << endl;
+ }
// Get a value
std::string key("hello");
- VersionedValue value(*client->get(&key));
- cout << "Value: " << *(value.getValue()) << endl;
+ const VersionedValue* result = client->get(&key);
+ VersionedValue value;
+ if (result) {
+ value = *result;
+ cout << "Value: " << *(value.getValue()) << endl;
+ } else {
+ cout << "Value not set" << endl;
+ }
// Modify the value
value.setValue(new string("world!"));
-
+
// update the value
client->put(&key, &value);

0 comments on commit 5e52308

Please sign in to comment.
Something went wrong with that request. Please try again.