namespace rgw { namespace d4n {
-int CachePolicy::find_client(const DoutPrefixProvider* dpp) {
- if (client.is_connected())
+int CachePolicy::find_client(const DoutPrefixProvider* dpp, cpp_redis::client* client) {
+ if (client->is_connected())
return 0;
if (get_addr().host == "" || get_addr().port == 0) {
return EDESTADDRREQ;
}
- client.connect(get_addr().host, get_addr().port, nullptr);
+ client->connect(get_addr().host, get_addr().port, nullptr);
- if (!client.is_connected())
+ if (!client->is_connected())
return ECONNREFUSED;
return 0;
}
int LFUDAPolicy::get_block(const DoutPrefixProvider* dpp, CacheBlock* block, rgw::cache::CacheDriver* cacheNode) {
- std::string key = "rgw-object:" + block->cacheObj.objName + ":directory";
+/* std::string key = "rgw-object:" + block->cacheObj.objName + ":directory";
std::string localWeightStr = cacheNode->get_attr(dpp, block->cacheObj.objName, "localWeight"); // change to block name eventually -Sam
int localWeight = -1;
if (!client.is_connected())
- find_client(dpp);
+ find_client(dpp, &client);
if (localWeightStr.empty()) { // figure out where to set local weight -Sam
- /* Local weight hasn't been set */
int ret = cacheNode->set_attr(dpp, block->cacheObj.objName, "localWeight", std::to_string(get_age()));
- localWeight = 0;
+ localWeight = get_age();
if (ret < 0)
return -1;
int age = get_age();
- if (cacheNode->key_exists(dpp, block->cacheObj.objName)) { /* Local copy */
+ if (cacheNode->key_exists(dpp, block->cacheObj.objName)) {
localWeight += age;
} else {
std::string hosts;
}
// should not hold local cache IP if in this else statement -Sam
- if (hosts.length() > 0) { /* Remote copy */
+ if (hosts.length() > 0) {
int globalWeight = get_global_weight(key);
globalWeight += age;
if (set_global_weight(key, globalWeight))
return -1;
- } else { /* No remote copy */
+ } else {
// do I need to add the block to the local cache here? -Sam
// update hosts list for block as well? check read workflow -Sam
localWeight += age;
return cacheNode->set_attr(dpp, block->cacheObj.objName, "localWeight", std::to_string(localWeight));
}
- }
- return 0;
+ }*/
}
uint64_t LFUDAPolicy::eviction(const DoutPrefixProvider* dpp, rgw::cache::CacheDriver* cacheNode) {
addr.host = cct->_conf->rgw_d4n_host;
addr.port = cct->_conf->rgw_d4n_port;
}
- virtual int find_client(const DoutPrefixProvider* dpp) = 0;
+ virtual int find_client(const DoutPrefixProvider* dpp, cpp_redis::client* client) = 0;
virtual int exist_key(std::string key) = 0;
virtual Address get_addr() { return addr; }
virtual int get_block(const DoutPrefixProvider* dpp, CacheBlock* block, rgw::cache::CacheDriver* cacheNode) = 0;
int get_min_avg_weight();
CacheBlock find_victim(const DoutPrefixProvider* dpp, rgw::cache::CacheDriver* cacheNode);
- virtual int find_client(const DoutPrefixProvider* dpp) override { return CachePolicy::find_client(dpp); }
+ virtual int find_client(const DoutPrefixProvider* dpp, cpp_redis::client* client) override { return CachePolicy::find_client(dpp, client); }
virtual int exist_key(std::string key) override { return CachePolicy::exist_key(key); }
virtual int get_block(const DoutPrefixProvider* dpp, CacheBlock* block, rgw::cache::CacheDriver* cacheNode) override;
virtual uint64_t eviction(const DoutPrefixProvider* dpp, rgw::cache::CacheDriver* cacheNode) override;
/* Local cache check */
if (source->driver->get_policy_driver()->cacheDriver->key_exists(dpp, oid)) { // Entire object for now -Sam
ret = source->driver->get_policy_driver()->cacheDriver->get(dpp, source->get_key().get_oid(), ofs, len, bl, source->get_attrs());
+ dout(0) << "Sam: correct" << dendl;
cb->handle_data(bl, ofs, len);
} else {
/* Block directory check */