Skip to content

Commit

Permalink
Merge pull request #183 from art-daq/rrivera/improvedAppStatusReporting
Browse files Browse the repository at this point in the history
Improved App Status reporting
  • Loading branch information
rrivera747 authored Jan 16, 2025
2 parents a67ae41 + 219b5a4 commit 8892d96
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 51 deletions.
69 changes: 41 additions & 28 deletions otsdaq/GatewaySupervisor/GatewaySupervisor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,15 @@ try
__COUTVS__(25,value);
remoteGatewayApp.appInfo.lastStatusTime = atoi(value.c_str());

value = StringMacros::extractXmlField(remoteStatusString, "url", 0, after);
__COUTVS__(25,value);
remoteGatewayApp.appInfo.parent_url = value;

value = StringMacros::extractXmlField(remoteStatusString, "id", 0, after);
__COUTVS__(25,value);
remoteGatewayApp.appInfo.id = atoi(value.c_str());


} //end found Remote Gateway status
else //found remote subapp
{
Expand All @@ -1352,6 +1361,13 @@ try
__COUTVS__(25,value);
remoteGatewayApp.subapps[name].lastStatusTime = atoi(value.c_str());

value = StringMacros::extractXmlField(remoteStatusString, "url", 0, after);
__COUTVS__(25,value);
remoteGatewayApp.subapps[name].parent_url = value;

value = StringMacros::extractXmlField(remoteStatusString, "id", 0, after);
__COUTVS__(25,value);
remoteGatewayApp.subapps[name].id = atoi(value.c_str());
}
} //end primary loop

Expand Down Expand Up @@ -5948,13 +5964,12 @@ try

xmlOut.addTextElementToData("name",
appInfo.getName()); // get application name
xmlOut.addTextElementToData("id", std::to_string(appInfo.getId())); // get application id
xmlOut.addNumberElementToData("id", appInfo.getId()); // get application id
xmlOut.addTextElementToData("status", appInfo.getStatus()); // get status
xmlOut.addTextElementToData(
"time", appInfo.getLastStatusTime() ? StringMacros::getTimestampString(appInfo.getLastStatusTime()) : "0"); // get time stamp
xmlOut.addTextElementToData("stale",
std::to_string(time(0) - appInfo.getLastStatusTime())); // time since update
xmlOut.addTextElementToData("progress", std::to_string(appInfo.getProgress())); // get progress
xmlOut.addNumberElementToData("stale", time(0) - appInfo.getLastStatusTime()); // time since update
xmlOut.addNumberElementToData("progress", appInfo.getProgress()); // get progress
xmlOut.addTextElementToData("detail", appInfo.getDetail()); // get detail
xmlOut.addTextElementToData("class",
appInfo.getClass()); // get application class
Expand All @@ -5970,10 +5985,11 @@ try
xmlOut.addTextElementToParent("subapp_time",
subappInfoPair.second.lastStatusTime ? StringMacros::getTimestampString(subappInfoPair.second.lastStatusTime) : "0",
subappElement); // get timestamp
xmlOut.addTextElementToParent("subapp_stale", std::to_string(time(0) - subappInfoPair.second.lastStatusTime), subappElement); // time since update
xmlOut.addTextElementToParent("subapp_progress", std::to_string(subappInfoPair.second.progress), subappElement); // get progress
xmlOut.addNumberElementToParent("subapp_stale", time(0) - subappInfoPair.second.lastStatusTime, subappElement); // time since update
xmlOut.addNumberElementToParent("subapp_progress", subappInfoPair.second.progress, subappElement); // get progress
xmlOut.addTextElementToParent("subapp_detail", subappInfoPair.second.detail, subappElement); // get detail
xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.url, subappElement); // get url
xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.url, subappElement); // get detail
xmlOut.addNumberElementToParent("subapp_id", subappInfoPair.second.id, subappElement); // get url
xmlOut.addTextElementToParent("subapp_class", subappInfoPair.second.class_name, subappElement); // get class

}
Expand All @@ -5995,32 +6011,31 @@ try

xmlOut.addTextElementToData("name",
appInfo.name); // get application name
xmlOut.addTextElementToData("id", std::to_string(-1)); // get application id
xmlOut.addNumberElementToData("id", appInfo.id); // get application id
xmlOut.addTextElementToData("status", appInfo.status); // get status
xmlOut.addTextElementToData(
"time", appInfo.lastStatusTime ? StringMacros::getTimestampString(appInfo.lastStatusTime) : "0"); // get timestamp
xmlOut.addTextElementToData("stale",
std::to_string(time(0) - appInfo.lastStatusTime)); // time since update
xmlOut.addTextElementToData("progress", std::to_string(appInfo.progress)); // get progress
xmlOut.addTextElementToData("detail", appInfo.detail); // get detail
xmlOut.addTextElementToData("class",
appInfo.class_name); // get application class
xmlOut.addTextElementToData("url",
appInfo.url); // get application url
xmlOut.addTextElementToData("context", "Remote-" +
appInfo.url); // get context
xmlOut.addTextElementToData("time", appInfo.lastStatusTime ?
StringMacros::getTimestampString(appInfo.lastStatusTime) : "0"); // get timestamp
xmlOut.addNumberElementToData("stale",
time(0) - appInfo.lastStatusTime); // time since update
xmlOut.addNumberElementToData("progress", appInfo.progress); // get progress
xmlOut.addTextElementToData("detail", appInfo.detail); // get detail
xmlOut.addTextElementToData("class", appInfo.class_name); // get application class
xmlOut.addTextElementToData("url", appInfo.parent_url); // get application url
xmlOut.addTextElementToData("context", appInfo.name + " at " + appInfo.url); // get context
auto subappElement = xmlOut.addTextElementToData("subapps", "");
for(auto& subappInfoPair : remoteApp.subapps)
{
xmlOut.addTextElementToParent("subapp_name", subappInfoPair.first, subappElement);
xmlOut.addTextElementToParent("subapp_status", subappInfoPair.second.status, subappElement); // get status
xmlOut.addTextElementToParent("subapp_time",
subappInfoPair.second.lastStatusTime ? StringMacros::getTimestampString(subappInfoPair.second.lastStatusTime) : "0",
subappInfoPair.second.lastStatusTime ?
StringMacros::getTimestampString(subappInfoPair.second.lastStatusTime) : "0",
subappElement); // get time stamp
xmlOut.addTextElementToParent("subapp_stale", std::to_string(time(0) - subappInfoPair.second.lastStatusTime), subappElement); // time since update
xmlOut.addTextElementToParent("subapp_progress", std::to_string(subappInfoPair.second.progress), subappElement); // get progress
xmlOut.addNumberElementToParent("subapp_stale", time(0) - subappInfoPair.second.lastStatusTime, subappElement); // time since update
xmlOut.addNumberElementToParent("subapp_progress", subappInfoPair.second.progress, subappElement); // get progress
xmlOut.addTextElementToParent("subapp_detail", subappInfoPair.second.detail, subappElement); // get detail
xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.url, subappElement); // get url
xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.parent_url, subappElement); // get detail
xmlOut.addNumberElementToParent("subapp_id", subappInfoPair.second.id, subappElement); // get url
xmlOut.addTextElementToParent("subapp_class", subappInfoPair.second.class_name, subappElement); // get class

}
Expand Down Expand Up @@ -6049,10 +6064,8 @@ try
}

for(const auto& remoteGatewayApp : remoteGatewayApps)
{
xmlOut.addTextElementToData("RemoteGateway", "Remote-" +
remoteGatewayApp.appInfo.url);
} //end remote subsystem loop
xmlOut.addTextElementToData("RemoteGateway",
remoteGatewayApp.appInfo.name + " at " + remoteGatewayApp.appInfo.url);
}
else if(requestType == "getSystemMessages")
{
Expand Down
4 changes: 2 additions & 2 deletions otsdaq/SupervisorInfo/SupervisorInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class SupervisorInfo
struct SubappInfo {
std::string name; // Also key in map
std::string status;
unsigned int progress;
unsigned int progress, id;
std::string detail;
time_t lastStatusTime;
std::string url;
std::string url, parent_url;
std::string class_name;
}; // end SubappInfo struct

Expand Down
2 changes: 2 additions & 0 deletions otsdaq/XmlUtilities/HttpXmlDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class HttpXmlDocument : public XmlDocument
template<class T>
xercesc::DOMElement* addNumberElementToData (const std::string & field , const T & value ) { return addTextElementToData(field,std::to_string(value)); }
xercesc::DOMElement* addBinaryStringToData (const std::string & field , const std::string & binary );
template<class T>
xercesc::DOMElement* addNumberElementToParent (const std::string & field , const T & value, xercesc::DOMElement* parent) { return addTextElementToParent(field,std::to_string(value),parent); }
void copyDataChildren ( HttpXmlDocument & document );
std::string getMatchingValue (const std::string & field , const unsigned int occurance = 0 );
void getAllMatchingValues (const std::string & field , std::vector<std::string> & retVec);
Expand Down
22 changes: 11 additions & 11 deletions otsdaq/XmlUtilities/XmlDocument.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
using namespace ots;

//==============================================================================
XmlDocument::XmlDocument(std::string rootName) : rootTagName_(rootName)
XmlDocument::XmlDocument(const std::string& rootName) : rootTagName_(rootName)
{
//__COUT__ << "in" << std::endl;
initDocument();
Expand Down Expand Up @@ -177,7 +177,7 @@ void XmlDocument::terminatePlatform(void)
// addTextElementToParent
// add to parent by pointer to parent
// returns pointer to element that is added
xercesc::DOMElement* XmlDocument::addTextElementToParent(std::string childName, std::string childText, xercesc::DOMElement* parent)
xercesc::DOMElement* XmlDocument::addTextElementToParent(const std::string& childName, const std::string& childText, xercesc::DOMElement* parent)
{
if(parent == 0)
{
Expand Down Expand Up @@ -217,7 +217,7 @@ xercesc::DOMElement* XmlDocument::addTextElementToParent(std::string childName,
// addTextElementToParent
// add to parent by instance number of parent name
// returns pointer to element that is added
xercesc::DOMElement* XmlDocument::addTextElementToParent(std::string childName, std::string childText, std::string parentName, unsigned int parentIndex)
xercesc::DOMElement* XmlDocument::addTextElementToParent(const std::string& childName, const std::string& childText, const std::string&parentName, unsigned int parentIndex)
{
xercesc::DOMNodeList* nodeList = theDocument_->getElementsByTagName(CONVERT_TO_XML(parentName));

Expand Down Expand Up @@ -449,7 +449,7 @@ void XmlDocument::setDocument(xercesc::DOMDocument* doc) { theDocument_ = doc; }
//==============================================================================
// XmlDocument::recursiveOutputXmlDocument
// recursively printout XML theDocument_ to std out and output stream if not null
void XmlDocument::recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut, std::string tabStr)
void XmlDocument::recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut, const std::string& tabStr)
{
// open field tag
if(dispStdOut)
Expand Down Expand Up @@ -597,7 +597,7 @@ void XmlDocument::recursiveRemoveChild(xercesc::DOMElement* childEl, xercesc::DO
// XmlDocument::saveXmlDocument
// wrapper for private outputXML
// Warning: filePath must be accessible or program will crash!
void XmlDocument::saveXmlDocument(std::string filePath)
void XmlDocument::saveXmlDocument(const std::string& filePath)
{
__COUT__ << "Saving theDocument_ to file: " << filePath << std::endl;
// Return the first registered theImplementation_ that has the desired features. In
Expand Down Expand Up @@ -700,7 +700,7 @@ void XmlDocument::saveXmlDocument(std::string filePath)
}

//==============================================================================
bool XmlDocument::loadXmlDocument(std::string filePath)
bool XmlDocument::loadXmlDocument(const std::string& filePath)
{
__COUT__ << "Loading theDocument_ from file: " << filePath << std::endl;

Expand Down Expand Up @@ -746,16 +746,16 @@ bool XmlDocument::loadXmlDocument(std::string filePath)
}
// clang-format off
//============================================================================
void XmlDocument::setAnchors(std::string fSystemPath,
std::string fRootPath)
void XmlDocument::setAnchors(const std::string& fSystemPath,
const std::string& fRootPath)
{
fSystemPath_ = fSystemPath;
fRootPath_ = fRootPath;
}

//============================================================================
void XmlDocument::makeDirectoryBinaryTree(std::string fSystemPath,
std::string fRootPath,
void XmlDocument::makeDirectoryBinaryTree(const std::string& fSystemPath,
const std::string& fRootPath,
int indent,
xercesc::DOMElement* anchorNode)
{
Expand Down Expand Up @@ -844,7 +844,7 @@ void XmlDocument::makeDirectoryBinaryTree(std::string fSystemPath,

//==========================================================================================
xercesc::DOMElement* XmlDocument::populateBinaryTreeNode(xercesc::DOMElement* anchorNode,
std::string name,
const std::string& name,
int indent,
bool isLeaf)
{
Expand Down
20 changes: 10 additions & 10 deletions otsdaq/XmlUtilities/XmlDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ class XmlDocument
{
//---------------------------------------------------------------------------------------------------------------
public:
XmlDocument(std::string rootName = "ROOT");
XmlDocument(const std::string& rootName = "ROOT");
XmlDocument(const XmlDocument& doc);
XmlDocument& operator=(const XmlDocument& doc);
~XmlDocument(void);

xercesc::DOMElement* addTextElementToParent(std::string childName, std::string childText, xercesc::DOMElement* parent);
xercesc::DOMElement* addTextElementToParent(std::string childName, std::string childText, std::string parentName, unsigned int parentIndex = 0);
void saveXmlDocument(std::string filePath);
xercesc::DOMElement* addTextElementToParent(const std::string& childName, const std::string& childText, xercesc::DOMElement* parent);
xercesc::DOMElement* addTextElementToParent(const std::string& childName, const std::string& childText, const std::string& parentName, unsigned int parentIndex = 0);
void saveXmlDocument(const std::string& filePath);
void recursiveRemoveChild(xercesc::DOMElement* childEl, xercesc::DOMElement* parentEl);
bool loadXmlDocument(std::string filePath);
bool loadXmlDocument(const std::string& filePath);
void outputXmlDocument(std::ostringstream* out, bool dispStdOut = false);
void makeDirectoryBinaryTree(std::string name, std::string rootPath, int indent, xercesc::DOMElement* anchorNode);
xercesc::DOMElement* populateBinaryTreeNode(xercesc::DOMElement* anchorNode, std::string name, int indent, bool isLeaf);
void setAnchors(std::string fSystemPath, std::string fRootPath);
void makeDirectoryBinaryTree(const std::string& name, const std::string& rootPath, int indent, xercesc::DOMElement* anchorNode);
xercesc::DOMElement* populateBinaryTreeNode(xercesc::DOMElement* anchorNode, const std::string& name, int indent, bool isLeaf);
void setAnchors(const std::string& fSystemPath, const std::string& fRootPath);
void setDocument(xercesc::DOMDocument* doc);
void setDarioStyle(bool darioStyle);
void setRootPath(std::string rootPath) { fRootPath_ = rootPath; }
void setRootPath(const std::string& rootPath) { fRootPath_ = rootPath; }
//---------------------------------------------------------------------------------------------------------------
protected:
void copyDocument(const xercesc::DOMDocument* toCopy, xercesc::DOMDocument* copy);
void recursiveElementCopy(const xercesc::DOMElement* toCopy, xercesc::DOMElement* copy);
void initDocument(void);
void initPlatform(void);
void terminatePlatform(void);
void recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut = false, std::string tabStr = "");
void recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut = false, const std::string& tabStr = "");

xercesc::DOMImplementation* theImplementation_;
xercesc::DOMDocument* theDocument_;
Expand Down

0 comments on commit 8892d96

Please sign in to comment.