Skip to content

Commit

Permalink
HPCC-30184 Expose WU "Process" meta info in WsWorkunits.WUInfo
Browse files Browse the repository at this point in the history
Revise based on review:
1. rename the getAllProcesses() to getProcessTypes().
2. revise the code for querying process data from IPropertyTree.
3. set default values from ecm file.

Signed-off-by: wangkx <[email protected]>
  • Loading branch information
wangkx committed Nov 16, 2023
1 parent f60821d commit e0da31b
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 1 deletion.
9 changes: 9 additions & 0 deletions common/workunit/workunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4423,6 +4423,8 @@ class CLockedWorkUnit : implements ILocalWorkUnit, implements IExtendedWUInterfa
{ return c->getHash(); }
virtual IStringIterator *getLogs(const char *type, const char *instance) const
{ return c->getLogs(type, instance); }
virtual IPropertyTreeIterator *getProcessTypes() const
{ return c->getProcessTypes(); }
virtual IStringIterator *getProcesses(const char *type) const
{ return c->getProcesses(type); }
virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const
Expand Down Expand Up @@ -8616,6 +8618,13 @@ IStringIterator *CLocalWorkUnit::getLogs(const char *type, const char *instance)
return new CStringPTreeAttrIterator(p->getElements(xpath.str()), "@log");
}

IPropertyTreeIterator* CLocalWorkUnit::getProcessTypes() const
{
VStringBuffer xpath("Process/*");
CriticalBlock block(crit);
return p->getElements(xpath.str());
}

IPropertyTreeIterator* CLocalWorkUnit::getProcesses(const char *type, const char *instance) const
{
VStringBuffer xpath("Process/%s/", type);
Expand Down
1 change: 1 addition & 0 deletions common/workunit/workunit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ interface IConstWorkUnit : extends IConstWorkUnitInfo
virtual const IPropertyTree * getXmlParams() const = 0;
virtual unsigned __int64 getHash() const = 0;
virtual IStringIterator *getLogs(const char *type, const char *instance=NULL) const = 0;
virtual IPropertyTreeIterator *getProcessTypes() const = 0;
virtual IStringIterator *getProcesses(const char *type) const = 0;
virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const = 0;

Expand Down
1 change: 1 addition & 0 deletions common/workunit/workunit.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public:
virtual const IPropertyTree *getXmlParams() const;
virtual unsigned __int64 getHash() const;
virtual IStringIterator *getLogs(const char *type, const char *component) const;
virtual IPropertyTreeIterator *getProcessTypes() const;
virtual IStringIterator *getProcesses(const char *type) const;
virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const;
virtual IStringVal & getSnapshot(IStringVal & str) const;
Expand Down
2 changes: 1 addition & 1 deletion esp/scm/ws_workunits.ecm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ EspInclude(ws_workunits_queryset_req_resp);

ESPservice [
auth_feature("DEFERRED"), //This declares that the method logic handles feature level authorization
version("1.97"), default_client_version("1.97"), cache_group("ESPWsWUs"),
version("1.98"), default_client_version("1.98"), cache_group("ESPWsWUs"),
noforms,exceptions_inline("./smc_xslt/exceptions.xslt"),use_method_name] WsWorkunits
{
ESPmethod [cache_seconds(60), resp_xsl_default("/esp/xslt/workunits.xslt")] WUQuery(WUQueryRequest, WUQueryResponse);
Expand Down
1 change: 1 addition & 0 deletions esp/scm/ws_workunits_req_resp.ecm
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ ESPrequest WUInfoRequest
[min_ver("1.66")] bool IncludeAllowedClusters(true);
[min_ver("1.73")] bool IncludeTotalClusterTime(true);
[min_ver("1.78")] bool IncludeServiceNames(false);
[min_ver("1.98")] bool IncludeProcesses(false);
[min_ver("1.16")] bool SuppressResultSchemas(false);
[min_ver("1.25")] string ThorSlaveIP;
};
Expand Down
13 changes: 13 additions & 0 deletions esp/scm/ws_workunits_struct.ecm
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ ESPStruct [nil_remove] ThorLogInfo
int NumberSlaves;
};

ESPStruct [nil_remove] ECLWUProcess
{
string Name;
string Type;
string PodName; //containerized only
int InstanceNumber(1); //containerized only
string Log; //bare metal only
string PID; //bare metal only
string Pattern; //bare metal only
int Max(1); //bare metal only
};

ESPStruct [nil_remove] ECLWorkunitLW
{
string Wuid;
Expand Down Expand Up @@ -442,6 +454,7 @@ ESPStruct [nil_remove] ECLWorkunit
[min_ver("1.85")] double FileAccessCost;
[min_ver("1.87")] double CompileCost;
[min_ver("1.91")] bool NoAccess(false);
[min_ver("1.98")] ESParray<ESPstruct ECLWUProcess> ECLWUProcessList;
};

ESPStruct [nil_remove] WUECLAttribute
Expand Down
46 changes: 46 additions & 0 deletions esp/services/ws_workunits/ws_workunitsHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,50 @@ void WsWuInfo::getServiceNames(IEspECLWorkunit &info, unsigned long flags)
info.setServiceNames(serviceNames);
}

void WsWuInfo::getECLWUProcesses(IEspECLWorkunit &info, unsigned long flags)
{
if (!(flags & WUINFO_IncludeProcesses))
return;

IArrayOf<IEspECLWUProcess> processList;
Owned<IPropertyTreeIterator> processGroupItr = cw->getProcessTypes();
ForEach(*processGroupItr)
{
IPropertyTree &processGroup = processGroupItr->query();
const char *type = processGroup.queryName();

Owned<IPropertyTreeIterator> processItr = processGroup.getElements("*");
ForEach(*processItr)
{
IPropertyTree &process = processItr->query();
Owned<IEspECLWUProcess> p = createECLWUProcess();
p->setName(process.queryName());
p->setType(type);
const char *podName = process.queryProp("@podName");
if (!isEmptyString(podName))
p->setPodName(podName);
unsigned instanceNum = process.getPropInt("@instanceNum", NotFound);
if (NotFound != instanceNum)
p->setInstanceNumber(instanceNum);
const char *pid = process.queryProp("@pid");
if (!isEmptyString(pid))
p->setPID(pid);
const char *log = process.queryProp("@log");
if (!isEmptyString(log))
p->setLog(log);
unsigned max = process.getPropInt("@max", NotFound);
if (NotFound != max)
p->setMax(max);
const char *pattern = process.queryProp("@pattern");
if (!isEmptyString(pattern))
p->setPattern(pattern);

processList.append(*p.getClear());
}
}
info.setECLWUProcessList(processList);
}

void WsWuInfo::getEventScheduleFlag(IEspECLWorkunit &info)
{
info.setEventSchedule(0);
Expand Down Expand Up @@ -1371,6 +1415,8 @@ void WsWuInfo::getInfo(IEspECLWorkunit &info, unsigned long flags)
getApplicationValues(info, flags);
getWorkflow(info, flags);
getServiceNames(info, flags);
if (version>=1.98)
getECLWUProcesses(info, flags);
}

#ifndef _CONTAINERIZED
Expand Down
2 changes: 2 additions & 0 deletions esp/services/ws_workunits/ws_workunitsHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct WsWUExceptions
#define WUINFO_IncludeAllowedClusters 0x10000
#define WUINFO_IncludeTotalClusterTime 0x20000
#define WUINFO_IncludeServiceNames 0x40000
#define WUINFO_IncludeProcesses 0x80000
#define WUINFO_All 0xFFFFFFFF

static constexpr unsigned defaultMaxLogRecords = 10000;
Expand Down Expand Up @@ -470,6 +471,7 @@ class WsWuInfo
void getResult(IConstWUResult &r, IArrayOf<IEspECLResult>& results, unsigned long flags);
void getStats(const WuScopeFilter & filter, const StatisticsFilter& statsFilter, bool createDescriptions, IArrayOf<IEspWUStatisticItem>& statistics);
void getServiceNames(IEspECLWorkunit &info, unsigned long flags);
void getECLWUProcesses(IEspECLWorkunit &info, unsigned long flags);

#ifndef _CONTAINERIZED
void getWUProcessLogSpecs(const char* processName, const char* logSpec, const char* logDir, bool eclAgent, StringArray& logSpecs);
Expand Down
2 changes: 2 additions & 0 deletions esp/services/ws_workunits/ws_workunitsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,8 @@ bool CWsWorkunitsEx::onWUInfo(IEspContext &context, IEspWUInfoRequest &req, IEsp
flags|=WUINFO_IncludeTotalClusterTime;
if (req.getIncludeServiceNames())
flags|=WUINFO_IncludeServiceNames;
if (req.getIncludeProcesses())
flags|=WUINFO_IncludeProcesses;

PROGLOG("WUInfo: %s %lx", wuid.str(), flags);

Expand Down

0 comments on commit e0da31b

Please sign in to comment.