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
Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
  • Loading branch information
wangkx committed Nov 6, 2023
1 parent c852637 commit 523bb2f
Show file tree
Hide file tree
Showing 9 changed files with 70 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 @@ -4427,6 +4427,8 @@ class CLockedWorkUnit : implements ILocalWorkUnit, implements IExtendedWUInterfa
{ return c->getProcesses(type); }
virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const
{ return c->getProcesses(type, instance); }
virtual IPropertyTreeIterator* getAllProcesses() const
{ return c->getAllProcesses(); }
virtual unsigned getTotalThorTime() const
{ return c->getTotalThorTime(); }
virtual WUGraphState queryGraphState(const char *graphName) 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::getAllProcesses() 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 @@ -1294,6 +1294,7 @@ interface IConstWorkUnit : extends IConstWorkUnitInfo
virtual IStringIterator *getLogs(const char *type, const char *instance=NULL) const = 0;
virtual IStringIterator *getProcesses(const char *type) const = 0;
virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const = 0;
virtual IPropertyTreeIterator* getAllProcesses() const = 0;

// Note that these don't read/modify the workunit itself, but rather the associated progress info.
// As such they can be called without locking the workunit, and are 'const' as far as the WU is concerned.
Expand Down
1 change: 1 addition & 0 deletions common/workunit/workunit.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public:
virtual IStringIterator *getLogs(const char *type, const char *component) const;
virtual IStringIterator *getProcesses(const char *type) const;
virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const;
virtual IPropertyTreeIterator* getAllProcesses() const;
virtual IStringVal & getSnapshot(IStringVal & str) const;
virtual ErrorSeverity getWarningSeverity(unsigned code, ErrorSeverity defaultSeverity) 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; //containerized only
string Log; //bare metal only
string PID; //bare metal only
string Pattern; //bare metal only
int Max; //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
40 changes: 40 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,44 @@ 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->getAllProcesses();
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);
if (process.hasProp("@podName"))
p->setPodName(process.queryProp("@podName"));
if (process.hasProp("@instanceNum"))
p->setInstanceNumber(process.getPropInt("@instanceNum", 1));
if (process.hasProp("@pid"))
p->setPID(process.queryProp("@pid"));
if (process.hasProp("@log"))
p->setLog(process.queryProp("@log"));
if (process.hasProp("@max"))
p->setMax(process.getPropInt("@max", 1));
if (process.hasProp("@pattern"))
p->setPattern(process.queryProp("@pattern"));

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

void WsWuInfo::getEventScheduleFlag(IEspECLWorkunit &info)
{
info.setEventSchedule(0);
Expand Down Expand Up @@ -1371,6 +1409,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 523bb2f

Please sign in to comment.