Permalink
Browse files

Implement reinit() for DefaultStoreClient

  • Loading branch information...
1 parent 1c6f848 commit 060a5a50fd36f021b17dc761d9d47dccfd67d511 @readams readams committed Jun 16, 2009
@@ -58,7 +58,8 @@ class StoreClientFactory
/**
* Get a @ref StoreClient for the given store. Returns a newly
* allocated object which is owned by the caller and must be
- * freed.
+ * freed. Note that you must keep around the store client factory
+ * object until you're done with the store client.
*
* @param storeName the name of the store
* @param resolver a shared pointer to an @ref
@@ -33,8 +33,11 @@ using namespace std;
static const int METADATA_REFRESH_ATTEMPTS = 3;
DefaultStoreClient::DefaultStoreClient(shared_ptr<Store>& store,
- shared_ptr<ClientConfig>& config)
- : config_(config), store_(store), curValue_() {
+ shared_ptr<InconsistencyResolver>& resolver,
+ shared_ptr<ClientConfig>& config,
+ StoreClientFactory* factory)
+ : config_(config), resolver_(resolver),
+ store_(store), factory_(factory), curValue_() {
}
@@ -43,8 +46,9 @@ DefaultStoreClient::~DefaultStoreClient() {
}
void DefaultStoreClient::reinit() {
- /* XXX - TODO */
- throw VoldemortException("Not implemented");
+ shared_ptr<Store>
+ nstore(factory_->getRawStore(*(store_->getName()), resolver_));
+ store_ = nstore;
}
const std::string* DefaultStoreClient::getValue(const std::string* key) {
@@ -215,7 +215,9 @@ getStoreClient(const std::string& storeName,
shared_ptr<InconsistencyResolver>& resolver) {
shared_ptr<Store> store(getRawStore(storeName, resolver));
return new DefaultStoreClient(store,
- pimpl_->config);
+ resolver,
+ pimpl_->config,
+ this);
}
@@ -45,10 +45,14 @@ class DefaultStoreClient: public StoreClient
* Construct a default store client object
*
* @param store The underlying store object
+ * @param resolver The inconsistency resolver
* @param config the @ref ClientConfig object
+ * @param factory the store client factory that created us
*/
DefaultStoreClient(shared_ptr<Store>& store,
- shared_ptr<ClientConfig>& config);
+ shared_ptr<InconsistencyResolver>& resolver,
+ shared_ptr<ClientConfig>& config,
+ StoreClientFactory* factory);
virtual ~DefaultStoreClient();
/**
@@ -71,7 +75,9 @@ class DefaultStoreClient: public StoreClient
private:
shared_ptr<ClientConfig> config_;
+ shared_ptr<InconsistencyResolver> resolver_;
shared_ptr<Store> store_;
+ StoreClientFactory* factory_;
VersionedValue curValue_;
};
@@ -49,8 +49,10 @@ class stresser
void operator()() {
while (continueStress) {
try {
+ // Simple GET
client->get(&KEY);
#if 0
+ // This does an implicit GET followed by a PUT
stringstream str;
str << KEY << count << "_" << client;
string key(str.str());

0 comments on commit 060a5a5

Please sign in to comment.