Skip to content
Snippets Groups Projects
Commit 68700b94 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

CReating dump methods for objectstore objects

parent 15a74aec
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
#include "RootEntry.hpp"
#include "common/DriveState.hpp"
#include <set>
#include <json/json.h>
cta::objectstore::DriveRegister::DriveRegister(const std::string & address, Backend & os):
ObjectOps<serializers::DriveRegister>(os, address) { }
......@@ -34,6 +35,56 @@ cta::objectstore::DriveRegister::DriveRegister(GenericObject& go):
getPayloadFromHeader();
}
std::string cta::objectstore::DriveRegister::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "DriveRegister" << std::endl;
struct json_object * jo = json_object_new_object();
json_object * array = json_object_new_array();
for (auto i = m_payload.drives().begin(); i!=m_payload.drives().end(); i++) {
json_object * jot = json_object_new_object();
json_object_object_add(jot, "drivename", json_object_new_string(i->drivename().c_str()));
json_object_object_add(jot, "logicallibrary", json_object_new_string(i->logicallibrary().c_str()));
json_object_object_add(jot, "sessionid", json_object_new_int64(i->sessionid()));
json_object_object_add(jot, "bytestransferedinsession", json_object_new_int64(i->bytestransferedinsession()));
json_object_object_add(jot, "filestransferedinsession", json_object_new_int64(i->filestransferedinsession()));
json_object_object_add(jot, "latestbandwidth", json_object_new_double(i->latestbandwidth()));
json_object_object_add(jot, "sessionstarttime", json_object_new_int64(i->sessionstarttime()));
json_object_object_add(jot, "mountstarttime", json_object_new_int64(i->mountstarttime()));
json_object_object_add(jot, "transferstarttime", json_object_new_int64(i->transferstarttime()));
json_object_object_add(jot, "unloadstarttime", json_object_new_int64(i->unloadstarttime()));
json_object_object_add(jot, "unmountstarttime", json_object_new_int64(i->unmountstarttime()));
json_object_object_add(jot, "drainingstarttime", json_object_new_int64(i->drainingstarttime()));
json_object_object_add(jot, "downorupstarttime", json_object_new_int64(i->downorupstarttime()));
json_object_object_add(jot, "cleanupstarttime", json_object_new_int64(i->cleanupstarttime()));
json_object_object_add(jot, "lastupdatetime", json_object_new_int64(i->lastupdatetime()));
json_object_object_add(jot, "currentvid", json_object_new_string(i->currentvid().c_str()));
json_object_object_add(jot, "currenttapepool", json_object_new_string(i->currenttapepool().c_str()));
json_object * creationlog_jot = json_object_new_object();
json_object_object_add(creationlog_jot, "host", json_object_new_string(i->creationlog().host().c_str()));
json_object_object_add(creationlog_jot, "time", json_object_new_int64(i->creationlog().time()));
json_object_object_add(creationlog_jot, "comment", json_object_new_string(i->creationlog().comment().c_str()));
json_object_object_add(jot, "creationlog", creationlog_jot);
json_object * mounttype_jot = json_object_new_object();
json_object_object_add(mounttype_jot, "type", json_object_new_int(i->mounttype()));
json_object_object_add(jot, "mounttype", mounttype_jot);
json_object * drivestatus_jot = json_object_new_object();
json_object_object_add(drivestatus_jot, "status", json_object_new_int(i->drivestatus()));
json_object_object_add(jot, "drivestatus", drivestatus_jot);
json_object_array_add(array, jot);
}
json_object_object_add(jo, "drives", array);
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
return ret.str();
}
void cta::objectstore::DriveRegister::initialize() {
// Setup underlying object
ObjectOps<serializers::DriveRegister>::initialize();
......
......@@ -19,6 +19,7 @@
#include "SchedulerGlobalLock.hpp"
#include "GenericObject.hpp"
#include "RootEntry.hpp"
#include <json/json.h>
namespace cta { namespace objectstore {
......@@ -88,5 +89,17 @@ bool SchedulerGlobalLock::isEmpty() {
// There is no content in the global lock.
return true;
}
std::string SchedulerGlobalLock::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "SchedulerGlobalLock" << std::endl;
struct json_object * jo = json_object_new_object();
json_object_object_add(jo, "nextmountid", json_object_new_int64(m_payload.nextmountid()));
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
return ret.str();
}
}}
\ No newline at end of file
......@@ -22,6 +22,7 @@
#include "CreationLog.hpp"
#include "Tape.hpp"
#include "RootEntry.hpp"
#include <json/json.h>
cta::objectstore::TapePool::TapePool(const std::string& address, Backend& os):
ObjectOps<serializers::TapePool>(os, address) { }
......@@ -34,6 +35,74 @@ cta::objectstore::TapePool::TapePool(GenericObject& go):
getPayloadFromHeader();
}
std::string cta::objectstore::TapePool::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "TapePool" << std::endl;
struct json_object * jo = json_object_new_object();
json_object_object_add(jo, "name", json_object_new_string(m_payload.name().c_str()));
json_object_object_add(jo, "ArchiveJobsTotalSize", json_object_new_int64(m_payload.archivejobstotalsize()));
json_object_object_add(jo, "oldestJobCreationTime", json_object_new_int64(m_payload.oldestjobcreationtime()));
json_object_object_add(jo, "archivemountcriteria - maxFilesBeforeMount", json_object_new_int64(m_payload.archivemountcriteria().maxfilesbeforemount()));
json_object_object_add(jo, "archivemountcriteria - maxBytesBeforeMount", json_object_new_int64(m_payload.archivemountcriteria().maxbytesbeforemount()));
json_object_object_add(jo, "archivemountcriteria - maxSecondsBeforeMount", json_object_new_int64(m_payload.archivemountcriteria().maxsecondsbeforemount()));
json_object_object_add(jo, "archivemountcriteria - quota", json_object_new_int(m_payload.archivemountcriteria().quota()));
json_object_object_add(jo, "retievemountcriteria - maxFilesBeforeMount", json_object_new_int64(m_payload.retievemountcriteria().maxfilesbeforemount()));
json_object_object_add(jo, "retievemountcriteria - maxBytesBeforeMount", json_object_new_int64(m_payload.retievemountcriteria().maxbytesbeforemount()));
json_object_object_add(jo, "retievemountcriteria - maxSecondsBeforeMount", json_object_new_int64(m_payload.retievemountcriteria().maxsecondsbeforemount()));
json_object_object_add(jo, "retievemountcriteria - quota", json_object_new_int(m_payload.retievemountcriteria().quota()));
json_object_object_add(jo, "priority", json_object_new_int64(m_payload.priority()));
json_object_object_add(jo, "maxretriespermount", json_object_new_int(m_payload.maxretriespermount()));
json_object_object_add(jo, "maxtotalretries", json_object_new_int(m_payload.maxtotalretries()));
json_object * array = json_object_new_array();
for (auto i = m_payload.tapes().begin(); i!=m_payload.tapes().end(); i++) {
json_object * jot = json_object_new_object();
json_object_object_add(jot, "vid", json_object_new_string(i->vid().c_str()));
json_object_object_add(jot, "address", json_object_new_string(i->address().c_str()));
json_object_object_add(jot, "capacity", json_object_new_int64(i->capacity()));
json_object_object_add(jot, "library", json_object_new_string(i->library().c_str()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "tapes", array);
array = json_object_new_array();
for (auto i = m_payload.pendingarchivejobs().begin(); i!=m_payload.pendingarchivejobs().end(); i++) {
json_object * jot = json_object_new_object();
json_object_object_add(jot, "address", json_object_new_string(i->address().c_str()));
json_object_object_add(jot, "copynb", json_object_new_int(i->copynb()));
json_object_object_add(jot, "path", json_object_new_string(i->path().c_str()));
json_object_object_add(jot, "size", json_object_new_int64(i->size()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "pendingarchivejobs", array);
array = json_object_new_array();
for (auto i = m_payload.orphanedarchivejobsnscreation().begin(); i!=m_payload.orphanedarchivejobsnscreation().end(); i++) {
json_object * jot = json_object_new_object();
json_object_object_add(jot, "address", json_object_new_string(i->address().c_str()));
json_object_object_add(jot, "copynb", json_object_new_int(i->copynb()));
json_object_object_add(jot, "path", json_object_new_string(i->path().c_str()));
json_object_object_add(jot, "size", json_object_new_int64(i->size()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "orphanedarchivejobsnscreation", array);
array = json_object_new_array();
for (auto i = m_payload.orphanedarchivejobsnsdeletion().begin(); i!=m_payload.orphanedarchivejobsnsdeletion().end(); i++) {
json_object * jot = json_object_new_object();
json_object_object_add(jot, "address", json_object_new_string(i->address().c_str()));
json_object_object_add(jot, "copynb", json_object_new_int(i->copynb()));
json_object_object_add(jot, "path", json_object_new_string(i->path().c_str()));
json_object_object_add(jot, "size", json_object_new_int64(i->size()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "orphanedarchivejobsnsdeletion", array);
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
return ret.str();
}
void cta::objectstore::TapePool::initialize(const std::string& name) {
// Setup underlying object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment