Skip to content

Commit

Permalink
Debug output.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolau-manubens committed Jun 28, 2024
1 parent 0fa4c6b commit e2175fc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
56 changes: 28 additions & 28 deletions src/eckit/io/rados/RadosCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,77 +25,77 @@ class RadosIOCtx {
rados_ioctx_t io_;

RadosIOCtx(rados_t cluster, const std::string& pool, const std::string& nspace) {
std::cout << "RadosIOCtx => rados_ioctx_create(" << pool << ")" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosIOCtx => rados_ioctx_create(" << pool << ")" << std::endl;
RADOS_CALL(rados_ioctx_create(cluster, pool.c_str(), &io_));
std::cout << "RadosIOCtx <= rados_ioctx_create(" << pool << ")" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosIOCtx <= rados_ioctx_create(" << pool << ")" << std::endl;

std::string nspace_name = nspace;
if (nspace == "") nspace_name = "LIBRADOS_ALL_NSPACES";

std::cout << "RadosIOCtx => rados_ioctx_set_namespace(" << nspace_name << ")" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosIOCtx => rados_ioctx_set_namespace(" << nspace_name << ")" << std::endl;
if (nspace == "") {
rados_ioctx_set_namespace(io_, LIBRADOS_ALL_NSPACES);
} else {
rados_ioctx_set_namespace(io_, nspace.c_str());
}
std::cout << "RadosIOCtx <= rados_ioctx_set_namespace(" << nspace_name << ")" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosIOCtx <= rados_ioctx_set_namespace(" << nspace_name << ")" << std::endl;
}

~RadosIOCtx() {
std::cout << "~RadosIOCtx => rados_ioctx_destroy(io_ctx_)" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosIOCtx => rados_ioctx_destroy(io_ctx_)" << std::endl;
rados_ioctx_destroy(io_);
std::cout << "~RadosIOCtx <= rados_ioctx_destroy(io_ctx_)" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosIOCtx <= rados_ioctx_destroy(io_ctx_)" << std::endl;
}
};

//----------------------------------------------------------------------------------------------------------------------

RadosAIO::RadosAIO() {
std::cout << "RadosAIO => rados_aio_create_completion()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosAIO => rados_aio_create_completion()" << std::endl;
RADOS_CALL(rados_aio_create_completion(NULL, NULL, NULL, &comp_));
std::cout << "RadosAIO <= rados_aio_create_completion()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosAIO <= rados_aio_create_completion()" << std::endl;
}

RadosAIO::~RadosAIO() {
std::cout << "~RadosAIO => rados_aio_release()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosAIO => rados_aio_release()" << std::endl;
rados_aio_release(comp_);
std::cout << "~RadosAIO <= rados_aio_release()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosAIO <= rados_aio_release()" << std::endl;
}

//----------------------------------------------------------------------------------------------------------------------

RadosWriteOp::RadosWriteOp() {
std::cout << "RadosWriteOp => rados_create_write_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosWriteOp => rados_create_write_op()" << std::endl;
op_ = rados_create_write_op();
std::cout << "RadosWriteOp <= rados_create_write_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosWriteOp <= rados_create_write_op()" << std::endl;
}

RadosWriteOp::~RadosWriteOp() {
std::cout << "~RadosWriteOp => rados_release_write_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosWriteOp => rados_release_write_op()" << std::endl;
rados_release_write_op(op_);
std::cout << "~RadosWriteOp <= rados_release_write_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosWriteOp <= rados_release_write_op()" << std::endl;
}

//----------------------------------------------------------------------------------------------------------------------

RadosReadOp::RadosReadOp() {
std::cout << "RadosReadOp => rados_create_read_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosReadOp => rados_create_read_op()" << std::endl;
op_ = rados_create_read_op();
std::cout << "RadosReadOp <= rados_create_read_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosReadOp <= rados_create_read_op()" << std::endl;
}

RadosReadOp::~RadosReadOp() {
std::cout << "~RadosReadOp => rados_release_read_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosReadOp => rados_release_read_op()" << std::endl;
rados_release_read_op(op_);
std::cout << "~RadosReadOp <= rados_release_read_op()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosReadOp <= rados_release_read_op()" << std::endl;
}

//----------------------------------------------------------------------------------------------------------------------

RadosIter::~RadosIter() {
std::cout << "~RadosIter => rados_omap_get_end()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosIter => rados_omap_get_end()" << std::endl;
rados_omap_get_end(it_);
std::cout << "~RadosIter <= rados_omap_get_end()" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "~RadosIter <= rados_omap_get_end()" << std::endl;
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -132,7 +132,7 @@ RadosCluster::RadosCluster() :
RadosCluster::~RadosCluster() {


std::cout << "RadosCluster::~RadosCluster" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosCluster::~RadosCluster" << std::endl;

for (auto j = ctx_.begin(); j != ctx_.end(); ++j) {
for (auto k = (*j).second.begin(); k != (*j).second.end(); k++) {
Expand All @@ -143,10 +143,10 @@ RadosCluster::~RadosCluster() {

ctx_.clear();

std::cout << "RADOS_CALL => rados_shutdown(cluster_)" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RADOS_CALL => rados_shutdown(cluster_)" << std::endl;

rados_shutdown(cluster_);
std::cout << "RADOS_CALL <= rados_shutdown(cluster_)" << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RADOS_CALL <= rados_shutdown(cluster_)" << std::endl;
}

void RadosCluster::error(int code, const char* msg, const char* file, int line, const char* func) {
Expand Down Expand Up @@ -276,7 +276,7 @@ void RadosCluster::attributes(const RadosObject& object, const RadosAttributes&
auto a = attr.attrs();
for (auto j = a.begin(); j != a.end(); ++j) {

std::cout << "RadosCluster::attributes => [" << (*j).first << "] [" << (*j).second << "]";
LOG_DEBUG_LIB(LibEcKit) << "RadosCluster::attributes => [" << (*j).first << "] [" << (*j).second << "]";


RADOS_CALL(rados_setxattr(ioCtx(object), oid, (*j).first.c_str(), (*j).second.c_str(), (*j).second.size()));
Expand All @@ -303,16 +303,16 @@ RadosAttributes RadosCluster::attributes(const RadosObject& object) const {
break;
}

std::cout << "RadosCluster::attributes <= [" << name << "] [";
LOG_DEBUG_LIB(LibEcKit) << "RadosCluster::attributes <= [" << name << "] [";
for (size_t i = 0; i < len; i++) {
if (isprint(val[i])) {
std::cout << val[i];
LOG_DEBUG_LIB(LibEcKit) << val[i];
}
else {
std::cout << '.';
LOG_DEBUG_LIB(LibEcKit) << '.';
}
}
std::cout << ']' << std::endl;
LOG_DEBUG_LIB(LibEcKit) << ']' << std::endl;

attr.set(name, std::string(val, val + len));
}
Expand Down
5 changes: 3 additions & 2 deletions src/eckit/io/rados/RadosCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <rados/librados.h>

#include "eckit/config/LibEcKit.h"
#include "eckit/io/Length.h"

#include "eckit/io/rados/RadosException.h"
Expand Down Expand Up @@ -102,7 +103,7 @@ class RadosCluster {

static inline int rados_call(int code, const char* msg, const char* file, int line, const char* func) {

std::cout << "RADOS_CALL => " << msg << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RADOS_CALL => " << msg << std::endl;

if (code < 0) {
std::cout << "RADOS_FAIL !! " << msg << std::endl;
Expand All @@ -111,7 +112,7 @@ static inline int rados_call(int code, const char* msg, const char* file, int li
RadosCluster::error(code, msg, file, line, func);
}

std::cout << "RADOS_CALL <= " << msg << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RADOS_CALL <= " << msg << std::endl;

return code;
}
Expand Down
5 changes: 3 additions & 2 deletions src/eckit/io/rados/RadosMultiObjReadHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* does it submit to any jurisdiction.
*/

#include "eckit/config/LibEcKit.h"
#include "eckit/io/rados/RadosMultiObjReadHandle.h"
#include "eckit/exception/Exceptions.h"
#include "eckit/io/MultiHandle.h"
Expand Down Expand Up @@ -56,7 +57,7 @@ Length RadosMultiObjReadHandle::openForRead() {
ASSERT(!handle_);

RadosAttributes attr = RadosCluster::instance().attributes(object_);
std::cout << "Attributes for " << object_.str() << " ===> " << attr << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "Attributes for " << object_.str() << " ===> " << attr << std::endl;

ASSERT(attr.get("length", length_));
ASSERT(attr.get("parts", parts_));
Expand All @@ -68,7 +69,7 @@ Length RadosMultiObjReadHandle::openForRead() {

Length len = handle_->openForRead();

std::cout << "RadosMultiObjReadHandle::openForRead attr=" << length_ << ", open=" << len << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosMultiObjReadHandle::openForRead attr=" << length_ << ", open=" << len << std::endl;
ASSERT(len == length_);

return length_;
Expand Down
7 changes: 4 additions & 3 deletions src/eckit/io/rados/RadosMultiObjWriteHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <map>

#include "eckit/config/LibEcKit.h"
#include "eckit/exception/Exceptions.h"
#include "eckit/io/rados/RadosAttributes.h"
#include "eckit/io/rados/RadosCluster.h"
Expand Down Expand Up @@ -94,7 +95,7 @@ long RadosMultiObjWriteHandle::read(void* buffer, long length) {

long RadosMultiObjWriteHandle::write(const void* buffer, long length) {

std::cout << "RadosMultiObjWriteHandle::write " << length << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosMultiObjWriteHandle::write " << length << std::endl;
ASSERT(opened_);

if (length == 0) {
Expand Down Expand Up @@ -124,12 +125,12 @@ long RadosMultiObjWriteHandle::write(const void* buffer, long length) {
continue;
}

std::cout << "RadosMultiObjWriteHandle::write " << len << " - " << maxObjectSize_ << " - " << written_ << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosMultiObjWriteHandle::write " << len << " - " << maxObjectSize_ << " - " << written_ << std::endl;

if (!handles_.back().get()) {

RadosObject object(object_, part_++);
std::cout << "RadosMultiObjWriteHandle::write open " << object.str() << std::endl;
LOG_DEBUG_LIB(LibEcKit) << "RadosMultiObjWriteHandle::write open " << object.str() << std::endl;
if (async_) {
handles_.back().reset(new RadosAsyncHandle(object, maxAioBuffSize_));
} else {
Expand Down

0 comments on commit e2175fc

Please sign in to comment.