like d4n filter, policy, cache backend, aio and process_env.
d4n/filter: Remove unnecessary erasure of attrs in read op's `prepare`
method
d4n: Remove `dout` definitions from header files
rgw: Remove unnecessary includes in `rgw_process_env.h`
rgw: Remove `cache_read_op` from `rgw_aio.h`
rgw: Return POSIX error codes and perform minor cleanup for D4N and
Redis files
Signed-off-by: Samarah <samarah.uriarte@ibm.com>
#include <boost/asio/consign.hpp>
#include "common/async/blocked_completion.h"
+#include "common/dout.h"
#include "d4n_directory.h"
namespace rgw { namespace d4n {
}
}
-std::string ObjectDirectory::build_index(CacheObj* object) {
+std::string ObjectDirectory::build_index(CacheObj* object)
+{
return object->bucketName + "_" + object->objName;
}
-int ObjectDirectory::exist_key(CacheObj* object, optional_yield y) {
+int ObjectDirectory::exist_key(CacheObj* object, optional_yield y)
+{
std::string key = build_index(object);
response<int> resp;
if ((bool)ec)
return false;
- } catch(std::exception &e) {}
+ } catch (std::exception &e) {}
return std::get<0>(resp).value();
}
boost::asio::dispatch(conn->get_executor(), [c = conn] { c->cancel(); });
}
-int ObjectDirectory::set(CacheObj* object, optional_yield y) {
+int ObjectDirectory::set(CacheObj* object, optional_yield y)
+{
std::string key = build_index(object);
/* Every set will be treated as new */
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value() != "OK" || (bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
return 0;
}
-int ObjectDirectory::get(CacheObj* object, optional_yield y) {
+int ObjectDirectory::get(CacheObj* object, optional_yield y)
+{
std::string key = build_index(object);
if (exist_key(object, y)) {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value().size() || (bool)ec) {
- return -1;
+ if (std::get<0>(resp).value().empty()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
}
object->objName = std::get<0>(resp).value()[0];
object->hostsList.push_back(host);
}
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
return 0;
}
-int ObjectDirectory::copy(CacheObj* object, std::string copyName, std::string copyBucketName, optional_yield y) {
+int ObjectDirectory::copy(CacheObj* object, std::string copyName, std::string copyBucketName, optional_yield y)
+{
std::string key = build_index(object);
auto copyObj = CacheObj{ .objName = copyName, .bucketName = copyBucketName };
std::string copyKey = build_index(©Obj);
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
}
redis_exec(conn, ec, req, res, y);
- if (std::get<0>(res).value() != "OK" || (bool)ec) {
- return -1;
- }
+ if (ec) {
+ return -ec.value();
+ }
}
return std::get<0>(resp).value() - 1;
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
}
-int ObjectDirectory::del(CacheObj* object, optional_yield y) {
+int ObjectDirectory::del(CacheObj* object, optional_yield y)
+{
std::string key = build_index(object);
if (exist_key(object, y)) {
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
return std::get<0>(resp).value() - 1;
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
return 0; /* No delete was necessary */
}
}
-int ObjectDirectory::update_field(CacheObj* object, std::string field, std::string value, optional_yield y) {
+int ObjectDirectory::update_field(CacheObj* object, std::string field, std::string value, optional_yield y)
+{
std::string key = build_index(object);
if (exist_key(object, y)) {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value() || (bool)ec)
- return -1;
+ if (!std::get<0>(resp).value()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
}
if (field == "objHosts") {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value().size() || (bool)ec)
- return -1;
+ if (std::get<0>(resp).value().empty()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
std::get<0>(resp).value() += "_";
std::get<0>(resp).value() += value;
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
return std::get<0>(resp).value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
}
-std::string BlockDirectory::build_index(CacheBlock* block) {
+std::string BlockDirectory::build_index(CacheBlock* block)
+{
return block->cacheObj.bucketName + "_" + block->cacheObj.objName + "_" + std::to_string(block->blockID) + "_" + std::to_string(block->size);
}
-int BlockDirectory::exist_key(CacheBlock* block, optional_yield y) {
+int BlockDirectory::exist_key(CacheBlock* block, optional_yield y)
+{
std::string key = build_index(block);
response<int> resp;
if ((bool)ec)
return false;
- } catch(std::exception &e) {}
+ } catch (std::exception &e) {}
return std::get<0>(resp).value();
}
boost::asio::dispatch(conn->get_executor(), [c = conn] { c->cancel(); });
}
-int BlockDirectory::set(CacheBlock* block, optional_yield y) {
+int BlockDirectory::set(CacheBlock* block, optional_yield y)
+{
std::string key = build_index(block);
/* Every set will be treated as new */
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value() != "OK" || (bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
return 0;
}
-int BlockDirectory::get(CacheBlock* block, optional_yield y) {
+int BlockDirectory::get(CacheBlock* block, optional_yield y)
+{
std::string key = build_index(block);
if (exist_key(block, y)) {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value().size() || (bool)ec) {
- return -1;
+ if (std::get<0>(resp).value().empty()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
}
block->blockID = boost::lexical_cast<uint64_t>(std::get<0>(resp).value()[0]);
block->cacheObj.hostsList.push_back(host);
}
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
return 0;
}
-int BlockDirectory::copy(CacheBlock* block, std::string copyName, std::string copyBucketName, optional_yield y) {
+int BlockDirectory::copy(CacheBlock* block, std::string copyName, std::string copyBucketName, optional_yield y)
+{
std::string key = build_index(block);
auto copyBlock = CacheBlock{ .cacheObj = { .objName = copyName, .bucketName = copyBucketName }, .blockID = 0 };
std::string copyKey = build_index(©Block);
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
}
redis_exec(conn, ec, req, res, y);
- if (std::get<0>(res).value() != "OK" || (bool)ec) {
- return -1;
- }
+ if (ec) {
+ return -ec.value();
+ }
}
return std::get<0>(resp).value() - 1;
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
}
-int BlockDirectory::del(CacheBlock* block, optional_yield y) {
+int BlockDirectory::del(CacheBlock* block, optional_yield y)
+{
std::string key = build_index(block);
if (exist_key(block, y)) {
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
return std::get<0>(resp).value() - 1;
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
return 0; /* No delete was necessary */
}
}
-int BlockDirectory::update_field(CacheBlock* block, std::string field, std::string value, optional_yield y) {
+int BlockDirectory::update_field(CacheBlock* block, std::string field, std::string value, optional_yield y)
+{
std::string key = build_index(block);
if (exist_key(block, y)) {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value() || (bool)ec)
- return -1;
+ if (!std::get<0>(resp).value()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
}
if (field == "blockHosts") {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value().size() || (bool)ec)
- return -1;
+ if (std::get<0>(resp).value().empty()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
std::get<0>(resp).value() += "_";
std::get<0>(resp).value() += value;
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
return std::get<0>(resp).value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
}
-int BlockDirectory::remove_host(CacheBlock* block, std::string delValue, optional_yield y) {
+int BlockDirectory::remove_host(CacheBlock* block, std::string delValue, optional_yield y)
+{
std::string key = build_index(block);
if (exist_key(block, y)) {
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value() || (bool)ec)
- return -1;
+ if (!std::get<0>(resp).value()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
}
{
redis_exec(conn, ec, req, resp, y);
- if (!std::get<0>(resp).value().size() || (bool)ec)
- return -1;
+ if (std::get<0>(resp).value().empty()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
if (std::get<0>(resp).value().find("_") == std::string::npos) /* Last host, delete entirely */
return del(block, y);
if (it != std::string::npos)
result.erase(result.begin() + it, result.begin() + it + delValue.size());
else
- return -1;
+ return -ENOENT;
if (result[0] == '_')
result.erase(0, 1);
redis_exec(conn, ec, req, resp, y);
- if ((bool)ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
return std::get<0>(resp).value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
} else {
- return -2;
+ return -ENOENT;
}
}
#include <boost/asio/detached.hpp>
#include <boost/redis/connection.hpp>
-#define dout_subsys ceph_subsys_rgw
-
namespace rgw { namespace d4n {
namespace net = boost::asio;
#include <boost/lexical_cast.hpp>
#include "../../../common/async/yield_context.h"
#include "common/async/blocked_completion.h"
+#include "common/dout.h"
namespace rgw { namespace d4n {
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return {};
+ if (ec) {
+ return -ec.value();
+ }
return std::get<0>(resp).value(); /* Returns number of fields set */
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
}
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ return -EINVAL;
}
if (!std::get<0>(resp).value()) {
if (set_age(1, y)) /* Initialize age */
return 1;
else
- return -1;
+ return -ENOENT;
}
try {
redis_exec(conn, ec, req, value, y);
- if (ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
return std::stoi(std::get<0>(value).value());
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
}
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
return std::get<0>(resp).value(); /* Returns number of fields set */
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
}
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ return -EINVAL;
}
if (!std::get<0>(resp).value()) {
for (auto& entry : entries_map)
sum += entry.second->localWeight;
- if (set_local_weight_sum(sum, y) < 0) { /* Initialize */
- return -1;
+ if (int ret = set_local_weight_sum(sum, y) < 0) { /* Initialize */
+ return ret;
} else {
return sum;
}
redis_exec(conn, ec, req, value, y);
- if (ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
return std::stoi(std::get<0>(value).value());
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ return -EINVAL;
}
}
if (victim == nullptr) {
ldpp_dout(dpp, 10) << "LFUDAPolicy::" << __func__ << "(): Could not retrieve victim block." << dendl;
delete victim;
- return -1;
+ return -ENOENT;
}
const std::lock_guard l(lfuda_lock);
auto it = entries_map.find(key);
if (it == entries_map.end()) {
delete victim;
- return -1;
+ return -ENOENT;
}
- int avgWeight = (get_local_weight_sum(y) / entries_map.size());
+ int avgWeight = get_local_weight_sum(y);
if (avgWeight < 0) {
delete victim;
- return -1;
+ return avgWeight;
}
+ avgWeight /= entries_map.size();
+
if (victim->hostsList.size() == 1 && victim->hostsList[0] == dir->cct->_conf->rgw_local_cache_address) { /* Last copy */
if (victim->globalWeight) {
it->second->localWeight += victim->globalWeight;
(*it->second->handle)->localWeight = it->second->localWeight;
entries_heap.increase(it->second->handle);
- if (cacheDriver->set_attr(dpp, key, "user.rgw.localWeight", std::to_string(it->second->localWeight), y) < 0)
- return -1;
+ if (int ret = cacheDriver->set_attr(dpp, key, "user.rgw.localWeight", std::to_string(it->second->localWeight), y) < 0) {
+ delete victim;
+ return ret;
+ }
victim->globalWeight = 0;
- if (dir->update_field(victim, "globalWeight", std::to_string(victim->globalWeight), y) < 0) {
+ if (int ret = dir->update_field(victim, "globalWeight", std::to_string(victim->globalWeight), y) < 0) {
delete victim;
- return -1;
+ return ret;
}
}
}
victim->globalWeight += it->second->localWeight;
- if (dir->update_field(victim, "globalWeight", std::to_string(victim->globalWeight), y) < 0) {
+ if (int ret = dir->update_field(victim, "globalWeight", std::to_string(victim->globalWeight), y) < 0) {
delete victim;
- return -1;
+ return ret;
}
- if (dir->remove_host(victim, dir->cct->_conf->rgw_local_cache_address, y) < 0) {
+ if (int ret = dir->remove_host(victim, dir->cct->_conf->rgw_local_cache_address, y) < 0) {
delete victim;
- return -1;
+ return ret;
}
delete victim;
- if (cacheDriver->del(dpp, key, y) < 0)
- return -1;
+ if (int ret = cacheDriver->del(dpp, key, y) < 0)
+ return ret;
ldpp_dout(dpp, 10) << "LFUDAPolicy::" << __func__ << "(): Block " << key << " has been evicted." << dendl;
int weight = (avgWeight * entries_map.size()) - it->second->localWeight;
- if (set_local_weight_sum((weight > 0) ? weight : 0, y) < 0)
- return -1;
+ if (int ret = set_local_weight_sum((weight > 0) ? weight : 0, y) < 0)
+ return ret;
int age = get_age(y);
age = std::max(it->second->localWeight, age);
- if (set_age(age, y) < 0)
- return -1;
+ if (int ret = set_age(age, y) < 0)
+ return ret;
erase(dpp, key, y);
freeSpace = cacheDriver->get_free_space(dpp);
#include "rgw_sal_d4n.h"
#include "rgw_cache_driver.h"
-#define dout_subsys ceph_subsys_rgw
-
namespace rgw::sal {
class D4NFilterObject;
}
attrs.erase(attr.first);
} else {
ldpp_dout(dpp, 20) << "D4NFilterObject::D4NFilterReadOp::" << __func__ << "(): Unexpected attribute; not locally set." << dendl;
- attrs.erase(attr.first);
}
}
user->set_info(quota_info);
optional_yield y, jspan_context *trace_ctx = nullptr);
static OpFunc d3n_cache_op(const DoutPrefixProvider *dpp, optional_yield y,
off_t read_ofs, off_t read_len, std::string& location);
-
- static OpFunc cache_read_op(const DoutPrefixProvider *dpp, optional_yield y, rgw::cache::CacheDriver* cache_driver,
- off_t read_ofs, off_t read_len, const std::string& key);
};
} // namespace rgw
#pragma once
#include <memory>
-#include "rgw_sal.h"
-#include "rgw_auth.h"
class ActiveRateLimiter;
class OpsLogSink;
#include <boost/redis/src.hpp>
#include <boost/asio/detached.hpp>
-#include "rgw_redis_driver.h"
+#include "common/dout.h"
#include "common/async/blocked_completion.h"
+#include "rgw_redis_driver.h"
namespace rgw { namespace cache {
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value() != "OK" || ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
this->free_space -= bl.length();
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
for (auto const& it : std::get<0>(resp).value()) {
if (it.first == "data") {
bl_value.clear();
}
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
return 0;
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
if (std::get<0>(resp).value()) {
redis_exec(conn, ec, req, data, y);
- if (ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
try {
redis_exec(conn, ec, req, ret, y);
- if (!std::get<0>(ret).value() || ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (!std::get<0>(ret).value()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
this->free_space += std::get<0>(data).value().length();
redis_exec(conn, ec, req, exists, y);
- if (ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
if (!std::get<0>(exists).value()) {
ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): Data field was not found." << dendl;
- return -1;
+ return -ENOENT;
}
try {
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
value = std::get<0>(resp).value();
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
try {
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value() != "OK" || ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
this->free_space -= bl_data.length();
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
if (std::get<0>(resp).value()) {
redis_exec(conn, ec, req, data, y);
if (ec) {
- return -1;
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
try {
redis_exec(conn, ec, req, ret, y);
- if (!std::get<0>(ret).value() || ec) {
- return -1;
+ if (!std::get<0>(ret).value()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
this->free_space += std::get<0>(data).value().length();
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value().empty() || ec)
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
for (auto const& it : std::get<0>(resp).value()) {
if (it.first != "data") {
bl_value.clear();
}
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
return 0;
int RedisDriver::set_attrs(const DoutPrefixProvider* dpp, const std::string& key, const rgw::sal::Attrs& attrs, optional_yield y)
{
if (attrs.empty())
- return -1;
+ return -EINVAL;
std::string entry = partition_info.location + key;
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value() != "OK" || ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
return 0;
redis_exec(conn, ec, req, resp, y);
- if (std::get<0>(resp).value() != "OK" || ec) {
- return -1;
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
return 0;
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return -1;
+ if (!std::get<0>(resp).value()) {
+ return -ENOENT;
+ } else if (ec) {
+ return -ec.value();
+ }
return std::get<0>(resp).value();
- } catch(std::exception &e) {
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
}
std::string entry = partition_info.location + key;
response<std::string> value;
response<int> resp;
+ attr_val = "";
/* Ensure field was set */
try {
redis_exec(conn, ec, req, resp, y);
if (ec) {
- attr_val = "";
- return -1;
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
+ }
+
+ if (!std::get<0>(resp).value()) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): Attribute was not found." << dendl;
+ return -ENOENT;
+ }
+
+ /* Retrieve existing value from cache */
+ try {
+ boost::system::error_code ec;
+ request req;
+ req.push("HGET", entry, attr_name);
+
+ redis_exec(conn, ec, req, value, y);
+
+ if (ec) {
+ return -ec.value();
}
- } catch(std::exception &e) {
- attr_val = "";
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
if (!std::get<0>(resp).value()) {
ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): Attribute was not found." << dendl;
- attr_val = "";
- return -1;
+ return -ENOENT;
}
/* Retrieve existing value from cache */
redis_exec(conn, ec, req, value, y);
if (ec) {
- attr_val = "";
- return -1;
+ return -ec.value();
}
- } catch(std::exception &e) {
- attr_val = "";
- return -1;
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
attr_val = std::get<0>(value).value();
redis_exec(conn, ec, req, resp, y);
- if (ec)
- return {};
- } catch(std::exception &e) {
- return -1;
+ if (ec) {
+ return -ec.value();
+ }
+ } catch (std::exception &e) {
+ ldpp_dout(dpp, 10) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
+ return -EINVAL;
}
return std::get<0>(resp).value();
#include "rgw_common.h"
#include "rgw_cache_driver.h"
-#define dout_subsys ceph_subsys_rgw
-#define dout_context g_ceph_context
-
-namespace rgw { namespace cache {
+namespace rgw { namespace cache {
namespace net = boost::asio;
using boost::redis::config;
#include "rgw_auth_registry.h"
#include "driver/d4n/d4n_directory.h"
+#define dout_subsys ceph_subsys_rgw
+
namespace net = boost::asio;
using boost::redis::config;
using boost::redis::connection;
#include "rgw_auth_registry.h"
#include "driver/d4n/d4n_policy.h"
+#define dout_subsys ceph_subsys_rgw
+
namespace net = boost::asio;
using boost::redis::config;
using boost::redis::connection;
#include "rgw_aio_throttle.h"
#include "rgw_redis_driver.h"
+#define dout_subsys ceph_subsys_rgw
+
namespace net = boost::asio;
using boost::redis::config;
using boost::redis::connection;