Commit 2e2aabf5 authored by Eric Cano's avatar Eric Cano
Browse files

Reimplemented objects store object dumps.

We now use protobuf's introspection to dump objects into JSON instead of ad-hoc code
using json-c.
parent 045863aa
......@@ -26,7 +26,7 @@
#include <sstream>
#include <ctime>
#include <cxxabi.h>
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
cta::objectstore::Agent::Agent(GenericObject& go):
ObjectOps<serializers::Agent, serializers::Agent_t>(go.objectStore()) {
......@@ -202,22 +202,12 @@ void cta::objectstore::Agent::setTimeout_us(uint64_t timeout) {
std::string cta::objectstore::Agent::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "Agent" << std::endl;
struct json_object * jo = json_object_new_object();
// Array for owned objects
json_object * joo = json_object_new_array();
auto & ool = m_payload.ownedobjects();
for (auto oo = ool.begin(); oo!=ool.end(); oo++) {
json_object_array_add(joo, json_object_new_string(oo->c_str()));
}
json_object_object_add(jo, "ownedObjects", joo);
json_object_object_add(jo, "description", json_object_new_string(m_payload.description().c_str()));
json_object_object_add(jo, "heartbeat", json_object_new_int64(m_payload.heartbeat()));
json_object_object_add(jo, "timeout_us", json_object_new_int64(m_payload.timeout_us()));
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
......@@ -19,7 +19,7 @@
#include "AgentRegister.hpp"
#include "ProtocolBuffersAlgorithms.hpp"
#include "GenericObject.hpp"
#include <json-c/json_object.h>
#include <google/protobuf/util/json_util.h>
cta::objectstore::AgentRegister::AgentRegister(Backend & os):
ObjectOps<serializers::AgentRegister, serializers::AgentRegister_t>(os) {}
......@@ -113,21 +113,10 @@ std::list<std::string> cta::objectstore::AgentRegister::getUntrackedAgents() {
std::string cta::objectstore::AgentRegister::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "AgentRegister" << std::endl;
struct json_object * jo;
jo = json_object_new_object();
json_object * jal = json_object_new_array();
for (int i=0; i<m_payload.agents_size(); i++) {
json_object_array_add(jal, json_object_new_string(m_payload.agents(i).c_str()));
}
json_object_object_add(jo, "agents", jal);
json_object * jual = json_object_new_array();
for (int i=0; i<m_payload.untrackedagents_size(); i++) {
json_object_array_add(jual, json_object_new_string(m_payload.untrackedagents(i).c_str()));
}
json_object_object_add(jo, "untrackedAgents", jual);
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
......@@ -22,7 +22,7 @@
#include "EntryLogSerDeser.hpp"
#include "RootEntry.hpp"
#include "ValueCountMap.hpp"
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
namespace cta { namespace objectstore {
......@@ -42,52 +42,12 @@ ArchiveQueue::ArchiveQueue(GenericObject& go):
std::string ArchiveQueue::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "ArchiveQueue" << std::endl;
struct json_object * jo = json_object_new_object();
json_object_object_add(jo, "name", json_object_new_string(m_payload.tapepool().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 * 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, "fileid", json_object_new_int64(i->fileid()));
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, "size", json_object_new_int64(i->size()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "pendingarchivejobs", array);
}
{
json_object * 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, "fileid", json_object_new_int64(i->fileid()));
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, "size", json_object_new_int64(i->size()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "orphanedarchivejobsnscreation", array);
}
{
json_object * 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, "fileid", json_object_new_int64(i->fileid()));
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, "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;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
void ArchiveQueue::initialize(const std::string& name) {
......
......@@ -23,7 +23,7 @@
#include "MountPolicySerDeser.hpp"
#include <algorithm>
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
namespace cta { namespace objectstore {
......@@ -465,57 +465,12 @@ bool ArchiveRequest::finishIfNecessary() {
std::string ArchiveRequest::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "ArchiveRequest" << std::endl;
struct json_object * jo = json_object_new_object();
json_object_object_add(jo, "checksumtype", json_object_new_string(m_payload.checksumtype().c_str()));
json_object_object_add(jo, "checksumvalue", json_object_new_string(m_payload.checksumvalue().c_str()));
json_object_object_add(jo, "diskfileid", json_object_new_string(m_payload.diskfileid().c_str()));
json_object_object_add(jo, "diskinstance", json_object_new_string(m_payload.diskinstance().c_str()));
json_object_object_add(jo, "archivereporturl", json_object_new_string(m_payload.archivereporturl().c_str()));
json_object_object_add(jo, "filesize", json_object_new_int64(m_payload.filesize()));
json_object_object_add(jo, "srcurl", json_object_new_string(m_payload.srcurl().c_str()));
json_object_object_add(jo, "storageclass", json_object_new_string(m_payload.storageclass().c_str()));
// Object for creation log
json_object * jaf = json_object_new_object();
json_object_object_add(jaf, "host", json_object_new_string(m_payload.creationlog().host().c_str()));
json_object_object_add(jaf, "time", json_object_new_int64(m_payload.creationlog().time()));
json_object_object_add(jaf, "username", json_object_new_string(m_payload.creationlog().username().c_str()));
json_object_object_add(jo, "creationlog", jaf);
// Array for jobs
json_object * jja = json_object_new_array();
auto & jl = m_payload.jobs();
for (auto j=jl.begin(); j!=jl.end(); j++) {
// Object for job
json_object * jj = json_object_new_object();
json_object_object_add(jj, "copynb", json_object_new_int64(j->copynb()));
json_object_object_add(jj, "lastmountwithfailure", json_object_new_int64(j->lastmountwithfailure()));
json_object_object_add(jj, "maxretrieswithinmount", json_object_new_int64(j->maxretrieswithinmount()));
json_object_object_add(jj, "maxtotalretries", json_object_new_int64(j->maxtotalretries()));
json_object_object_add(jj, "owner", json_object_new_string(j->owner().c_str()));
json_object_object_add(jj, "retrieswithinmount", json_object_new_int64(j->retrieswithinmount()));
json_object_object_add(jj, "status", json_object_new_int64(j->status()));
json_object_object_add(jj, "tapepool", json_object_new_string(j->tapepool().c_str()));
json_object_object_add(jj, "tapepoolAddress", json_object_new_string(j->archivequeueaddress().c_str()));
json_object_object_add(jj, "totalRetries", json_object_new_int64(j->totalretries()));
json_object_array_add(jja, jj);
}
json_object_object_add(jo, "jobs", jja);
// Object for diskfileinfo
json_object * jlog = json_object_new_object();
json_object_object_add(jlog, "recoveryblob", json_object_new_string(m_payload.diskfileinfo().recoveryblob().c_str()));
json_object_object_add(jlog, "group", json_object_new_string(m_payload.diskfileinfo().group().c_str()));
json_object_object_add(jlog, "owner", json_object_new_string(m_payload.diskfileinfo().owner().c_str()));
json_object_object_add(jlog, "path", json_object_new_string(m_payload.diskfileinfo().path().c_str()));
json_object_object_add(jo, "diskfileinfo", jlog);
// Object for requester
json_object * jrf = json_object_new_object();
json_object_object_add(jrf, "name", json_object_new_string(m_payload.requester().name().c_str()));
json_object_object_add(jrf, "group", json_object_new_string(m_payload.requester().group().c_str()));
json_object_object_add(jo, "requester", jrf);
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
}} // namespace cta::objectstore
......
......@@ -23,7 +23,7 @@
#include "common/dataStructures/DriveState.hpp"
#include "common/dataStructures/MountType.hpp"
#include <set>
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
#include <iostream>
namespace cta { namespace objectstore {
......@@ -49,54 +49,13 @@ DriveRegister::DriveRegister(GenericObject& go):
// DriveRegister::dump())
//------------------------------------------------------------------------------
std::string DriveRegister::dump() {
// TODO: update following structure changes.
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()));
// TODO: Creation log should be fully supported or dropped.
// 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(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();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
//------------------------------------------------------------------------------
......
......@@ -27,6 +27,7 @@
#include "RetrieveQueue.hpp"
#include "DriveRegister.hpp"
#include <stdexcept>
#include <google/protobuf/util/json_util.h>
namespace cta { namespace objectstore {
......@@ -144,30 +145,46 @@ namespace {
std::string GenericObject::dump(ScopedSharedLock& lock) {
checkHeaderReadable();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
std::string bodyDump;
google::protobuf::util::MessageToJsonString(m_header, &headerDump, options);
switch(m_header.type()) {
case serializers::RootEntry_t:
return dumpWithType<RootEntry>(this, lock);
bodyDump = dumpWithType<RootEntry>(this, lock);
break;
case serializers::AgentRegister_t:
return dumpWithType<AgentRegister>(this, lock);
bodyDump = dumpWithType<AgentRegister>(this, lock);
break;
case serializers::Agent_t:
return dumpWithType<Agent>(this, lock);
bodyDump = dumpWithType<Agent>(this, lock);
break;
case serializers::DriveRegister_t:
return dumpWithType<DriveRegister>(this, lock);
bodyDump = dumpWithType<DriveRegister>(this, lock);
break;
case serializers::ArchiveQueue_t:
return dumpWithType<cta::objectstore::ArchiveQueue>(this, lock);
bodyDump = dumpWithType<cta::objectstore::ArchiveQueue>(this, lock);
break;
case serializers::RetrieveQueue_t:
return dumpWithType<cta::objectstore::RetrieveQueue>(this, lock);
bodyDump = dumpWithType<cta::objectstore::RetrieveQueue>(this, lock);
break;
case serializers::ArchiveRequest_t:
return dumpWithType<ArchiveRequest>(this, lock);
bodyDump = dumpWithType<ArchiveRequest>(this, lock);
break;
case serializers::RetrieveRequest_t:
return dumpWithType<RetrieveRequest>(this, lock);
bodyDump = dumpWithType<RetrieveRequest>(this, lock);
break;
case serializers::SchedulerGlobalLock_t:
return dumpWithType<SchedulerGlobalLock>(this, lock);
bodyDump = dumpWithType<SchedulerGlobalLock>(this, lock);
break;
default:
std::stringstream err;
err << "Unsupported type: " << m_header.type();
throw std::runtime_error(err.str());
}
return std::string ("Header dump:\n") + headerDump + "Body dump:\n" + bodyDump;
}
}}
......@@ -20,7 +20,7 @@
#include "GenericObject.hpp"
#include "EntryLogSerDeser.hpp"
#include "ValueCountMap.hpp"
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
cta::objectstore::RetrieveQueue::RetrieveQueue(const std::string& address, Backend& os):
ObjectOps<serializers::RetrieveQueue, serializers::RetrieveQueue_t>(os, address) { }
......@@ -62,29 +62,12 @@ std::string cta::objectstore::RetrieveQueue::getVid() {
std::string cta::objectstore::RetrieveQueue::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "TapePool" << std::endl;
struct json_object * jo = json_object_new_object();
json_object_object_add(jo, "vid", json_object_new_string(m_payload.vid().c_str()));
json_object_object_add(jo, "retrievejobstotalsize", json_object_new_int64(m_payload.retrievejobstotalsize()));
json_object_object_add(jo, "oldestjobcreationtime", json_object_new_int64(m_payload.oldestjobcreationtime()));
{
json_object * array = json_object_new_array();
for (auto i = m_payload.retrievejobs().begin(); i!=m_payload.retrievejobs().end(); i++) {
json_object * rjobs = json_object_new_object();
json_object_object_add(rjobs, "size", json_object_new_int64(i->size()));
json_object_object_add(rjobs, "address", json_object_new_string(i->address().c_str()));
json_object_object_add(rjobs, "copynb", json_object_new_int(i->copynb()));
json_object_array_add(array, rjobs);
}
json_object_object_add(jo, "retrievejobs", array);
}
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
void cta::objectstore::RetrieveQueue::addJob(uint64_t copyNb,
......
......@@ -23,7 +23,7 @@
#include "DiskFileInfoSerDeser.hpp"
#include "ArchiveFileSerDeser.hpp"
#include "objectstore/cta.pb.h"
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
namespace cta { namespace objectstore {
......@@ -225,59 +225,12 @@ cta::common::dataStructures::EntryLog RetrieveRequest::getEntryLog() {
std::string RetrieveRequest::dump() {
checkPayloadReadable();
std::stringstream ret;
ret << "RetrieveRequest" << std::endl;
struct json_object * jo = json_object_new_object();
// struct json_object * jaf = json_object_new_object();
// TODO: fill up again
// json_object_object_add(jaf, "fileid", json_object_new_int64(m_payload.archivefile().fileid()));
// json_object_object_add(jaf, "fileid", json_object_new_int64(m_payload.archivefile().creationtime()));
// json_object_object_add(jaf, "fileid", json_object_new_string(m_payload.archivefile().checksumtype().c_str()));
// json_object_object_add(jaf, "fileid", json_object_new_string(m_payload.archivefile().checksumvalue().c_str()));
// json_object_object_add(jaf, "fileid", json_object_new_int64(m_payload.archivefile().size()));
// json_object_object_add(jo, "creationlog", jaf);
// json_object_object_add(jo, "dsturl", json_object_new_string(m_payload.dsturl().c_str()));
// // Object for creation log
// json_object * jcl = json_object_new_object();
// json_object_object_add(jcl, "host", json_object_new_string(m_payload.creationlog().host().c_str()));
// json_object_object_add(jcl, "time", json_object_new_int64(m_payload.creationlog().time()));
// json_object_object_add(jcl, "username", json_object_new_string(m_payload.creationlog().username().c_str()));
// json_object_object_add(jo, "creationlog", jcl);
// Array for jobs
json_object * jja = json_object_new_array();
auto & jl = m_payload.jobs();
for (auto j=jl.begin(); j!=jl.end(); j++) {
// Object for job
json_object * jj = json_object_new_object();
// TODO: fix
//json_object_object_add(jj, "copynb", json_object_new_int(j->copynb()));
json_object_object_add(jj, "retrieswithinmount", json_object_new_int(j->retrieswithinmount()));
json_object_object_add(jj, "totalretries", json_object_new_int(j->totalretries()));
json_object_object_add(jj, "status", json_object_new_int64(j->status()));
//json_object_object_add(jj, "fseq", json_object_new_int64(j->fseq()));
//json_object_object_add(jj, "blockid", json_object_new_int64(j->blockid()));
//json_object_object_add(jj, "tape", json_object_new_string(j->tape().c_str()));
//json_object_object_add(jj, "tapeAddress", json_object_new_string(j->tapeaddress().c_str()));
json_object_array_add(jja, jj);
}
json_object_object_add(jo, "jobs", jja);
// Object for diskfileinfo
// json_object * jlog = json_object_new_object();
// TODO: fill up again
// json_object_object_add(jlog, "recoveryblob", json_object_new_string(m_payload.diskfileinfo().recoveryblob().c_str()));
// json_object_object_add(jlog, "group", json_object_new_string(m_payload.diskfileinfo().group().c_str()));
// json_object_object_add(jlog, "owner", json_object_new_string(m_payload.diskfileinfo().owner().c_str()));
// json_object_object_add(jlog, "path", json_object_new_string(m_payload.diskfileinfo().path().c_str()));
// json_object_object_add(jo, "diskfileinfo", jlog);
// // Object for requester
// json_object * jrf = json_object_new_object();
// json_object_object_add(jrf, "name", json_object_new_string(m_payload.requester().name().c_str()));
// json_object_object_add(jrf, "group", json_object_new_string(m_payload.requester().group().c_str()));
// json_object_object_add(jo, "requester", jrf);
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
}} // namespace cta::objectstore
......
......@@ -27,7 +27,7 @@
#include "SchedulerGlobalLock.hpp"
#include <cxxabi.h>
#include "ProtocolBuffersAlgorithms.hpp"
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
namespace cta { namespace objectstore {
......@@ -586,66 +586,14 @@ void RootEntry::removeSchedulerGlobalLockAndCommit() {
// Dump the root entry
std::string RootEntry::dump () {
std::string RootEntry::dump () {
checkPayloadReadable();
std::stringstream ret;
ret << "RootEntry" << std::endl;
struct json_object * jo = json_object_new_object();
json_object_object_add(jo, "agentregisterintent", json_object_new_string(m_payload.agentregisterintent().c_str()));
{
json_object * pointer = json_object_new_object();
json_object_object_add(pointer, "address", json_object_new_string(m_payload.driveregisterpointer().address().c_str()));
json_object * jlog = json_object_new_object();
json_object_object_add(jlog, "host", json_object_new_string(m_payload.driveregisterpointer().log().host().c_str()));
json_object_object_add(jlog, "time", json_object_new_int64(m_payload.driveregisterpointer().log().time()));
json_object * id = json_object_new_object();
json_object_object_add(id, "name", json_object_new_string(m_payload.driveregisterpointer().log().username().c_str()));
json_object_object_add(jlog, "user", id);
json_object_object_add(pointer, "log", jlog);
json_object_object_add(jo, "driveregisterpointer", pointer);
}
{
json_object * pointer = json_object_new_object();
json_object_object_add(pointer, "address", json_object_new_string(m_payload.agentregisterpointer().address().c_str()));
json_object * jlog = json_object_new_object();
json_object_object_add(jlog, "host", json_object_new_string(m_payload.agentregisterpointer().log().host().c_str()));
json_object_object_add(jlog, "time", json_object_new_int64(m_payload.agentregisterpointer().log().time()));
json_object * id = json_object_new_object();
json_object_object_add(id, "name", json_object_new_string(m_payload.driveregisterpointer().log().username().c_str()));
json_object_object_add(jlog, "user", id);
json_object_object_add(pointer, "log", jlog);
json_object_object_add(jo, "agentregisterpointer", pointer);
}
{
json_object * pointer = json_object_new_object();
json_object_object_add(pointer, "address", json_object_new_string(m_payload.schedulerlockpointer().address().c_str()));
json_object * jlog = json_object_new_object();
json_object_object_add(jlog, "host", json_object_new_string(m_payload.schedulerlockpointer().log().host().c_str()));
json_object_object_add(jlog, "time", json_object_new_int64(m_payload.schedulerlockpointer().log().time()));
json_object * id = json_object_new_object();
json_object_object_add(id, "name", json_object_new_string(m_payload.driveregisterpointer().log().username().c_str()));
json_object_object_add(jlog, "user", id);
json_object_object_add(pointer, "log", jlog);
json_object_object_add(jo, "schedulerlockpointer", pointer);
}
{
json_object * array = json_object_new_array();
for (auto & i :m_payload.archivequeuepointers()) {
json_object * jot = json_object_new_object();
json_object_object_add(jot, "name", json_object_new_string(i.name().c_str()));
json_object_object_add(jot, "address", json_object_new_string(i.address().c_str()));
json_object_array_add(array, jot);
}
json_object_object_add(jo, "archivequeuepointers", array);
}
ret << json_object_to_json_string_ext(jo, JSON_C_TO_STRING_PRETTY) << std::endl;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
}} // namespace cta::objectstore
......@@ -19,7 +19,7 @@
#include "SchedulerGlobalLock.hpp"
#include "GenericObject.hpp"
#include "RootEntry.hpp"
#include <json-c/json.h>
#include <google/protobuf/util/json_util.h>
namespace cta { namespace objectstore {
......@@ -92,15 +92,12 @@ bool SchedulerGlobalLock::isEmpty() {
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;
json_object_put(jo);
return ret.str();
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
options.always_print_primitive_fields = true;
std::string headerDump;
google::protobuf::util::MessageToJsonString(m_payload, &headerDump, options);
return headerDump;
}
}}
Supports Markdown
0% or .