Browse Source

Merge pull request #9216 from wangkx/h14841a

HPCC-14841 Return more WU graph information in WUQueryDetails

Reviewed-By: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Reviewed-By: Gordon Smith <gordon.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 years ago
parent
commit
0cb4977c2b

+ 4 - 2
esp/scm/ws_workunits.ecm

@@ -1472,9 +1472,11 @@ ESPresponse [exceptions_inline] WUQueryDetailsResponse
     [min_ver("1.46")] string CompileTime;
     [min_ver("1.46")] ESParray<string> LibrariesUsed;
     [min_ver("1.46")] int CountGraphs;
-    [min_ver("1.46")] ESParray<string> GraphIds;
+    [min_ver("1.46"), depr_ver("1.64")] ESParray<string> GraphIds;
     [min_ver("1.50")] int ResourceURLCount;
     [min_ver("1.51")] ESParray<string, Address> WsEclAddresses;
+    [min_ver("1.64")] ESParray<ESPstruct ECLGraph> WUGraphs;
+    [min_ver("1.64")] ESParray<ESPstruct ECLTimer> WUTimers;
 };
 
 ESPrequest WUMultiQuerySetDetailsRequest
@@ -1792,7 +1794,7 @@ ESPresponse [exceptions_inline, nil_remove] WUGetNumFileToCopyResponse
 
 ESPservice [
     auth_feature("DEFERRED"), //This declares that the method logic handles feature level authorization
-    version("1.63"), default_client_version("1.63"),
+    version("1.64"), default_client_version("1.64"),
     noforms,exceptions_inline("./smc_xslt/exceptions.xslt"),use_method_name] WsWorkunits
 {
     ESPmethod [resp_xsl_default("/esp/xslt/workunits.xslt")]     WUQuery(WUQueryRequest, WUQueryResponse);

+ 102 - 93
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -370,66 +370,70 @@ void WsWuInfo::addTimerToList(SCMStringBuffer& name, const char * scope, IConstW
     timers.append(*t.getLink());
 }
 
-void WsWuInfo::getTimers(IEspECLWorkunit &info, unsigned flags)
+void WsWuInfo::doGetTimers(IArrayOf<IEspECLTimer>& timers)
 {
-    if (!(flags & WUINFO_IncludeTimers))
-        return;
-    try
-    {
-        unsigned __int64 totalThorTimeValue = 0;
-        unsigned __int64 totalThorTimerCount = 0; //Do we need this?
+    unsigned __int64 totalThorTimeValue = 0;
+    unsigned __int64 totalThorTimerCount = 0; //Do we need this?
 
-        IArrayOf<IEspECLTimer> timers;
-        StatisticsFilter filter;
-        filter.setScopeDepth(1, 2);
-        filter.setMeasure(SMeasureTimeNs);
-        Owned<IConstWUStatisticIterator> it = &cw->getStatistics(&filter);
-        if (it->first())
+    StatisticsFilter filter;
+    filter.setScopeDepth(1, 2);
+    filter.setMeasure(SMeasureTimeNs);
+    Owned<IConstWUStatisticIterator> it = &cw->getStatistics(&filter);
+    if (it->first())
+    {
+        ForEach(*it)
         {
-            ForEach(*it)
-            {
-                IConstWUStatistic & cur = it->query();
-                SCMStringBuffer name, scope;
-                cur.getDescription(name, true);
-                cur.getScope(scope);
+            IConstWUStatistic & cur = it->query();
+            SCMStringBuffer name, scope;
+            cur.getDescription(name, true);
+            cur.getScope(scope);
 
-                bool isThorTiming = false;//Should it be renamed as isClusterTiming?
-                if ((cur.getCreatorType() == SCTsummary) && (cur.getKind() == StTimeElapsed) && streq(scope.str(), GLOBAL_SCOPE))
-                {
-                    SCMStringBuffer creator;
-                    cur.getCreator(creator);
-                    if (streq(creator.str(), "thor") || streq(creator.str(), "hthor") ||
-                        streq(creator.str(), "roxie"))
-                        isThorTiming = true;
-                }
-                else if (strieq(name.str(), TOTALTHORTIME)) // legacy
+            bool isThorTiming = false;//Should it be renamed as isClusterTiming?
+            if ((cur.getCreatorType() == SCTsummary) && (cur.getKind() == StTimeElapsed) && streq(scope.str(), GLOBAL_SCOPE))
+            {
+                SCMStringBuffer creator;
+                cur.getCreator(creator);
+                if (streq(creator.str(), "thor") || streq(creator.str(), "hthor") ||
+                    streq(creator.str(), "roxie"))
                     isThorTiming = true;
+            }
+            else if (strieq(name.str(), TOTALTHORTIME)) // legacy
+                isThorTiming = true;
 
-                if (isThorTiming)
-                {
-                    totalThorTimeValue += cur.getValue();
-                    totalThorTimerCount += cur.getCount();
-                }
-                else
-                    addTimerToList(name, scope.str(), cur, timers);
+            if (isThorTiming)
+            {
+                totalThorTimeValue += cur.getValue();
+                totalThorTimerCount += cur.getCount();
             }
+            else
+                addTimerToList(name, scope.str(), cur, timers);
         }
+    }
 
-        if (totalThorTimeValue > 0)
-        {
-            StringBuffer totalThorTimeText;
-            formatStatistic(totalThorTimeText, totalThorTimeValue, SMeasureTimeNs);
+    if (totalThorTimeValue > 0)
+    {
+        StringBuffer totalThorTimeText;
+        formatStatistic(totalThorTimeText, totalThorTimeValue, SMeasureTimeNs);
 
-            Owned<IEspECLTimer> t= createECLTimer("","");
-            if (version > 1.52)
-                t->setName(TOTALCLUSTERTIME);
-            else
-                t->setName(TOTALTHORTIME);
-            t->setValue(totalThorTimeText.str());
-            t->setCount((unsigned)totalThorTimerCount);
-            timers.append(*t.getLink());
-        }
+        Owned<IEspECLTimer> t= createECLTimer("","");
+        if (version > 1.52)
+            t->setName(TOTALCLUSTERTIME);
+        else
+            t->setName(TOTALTHORTIME);
+        t->setValue(totalThorTimeText.str());
+        t->setCount((unsigned)totalThorTimerCount);
+        timers.append(*t.getLink());
+    }
+}
 
+void WsWuInfo::getTimers(IEspECLWorkunit &info, unsigned flags)
+{
+    if (!(flags & WUINFO_IncludeTimers))
+        return;
+    try
+    {
+        IArrayOf<IEspECLTimer> timers;
+        doGetTimers(timers);
         info.setTimers(timers);
     }
     catch(IException* e)
@@ -701,6 +705,54 @@ bool WsWuInfo::legacyHasSubGraphTimings()
     return false;
 }
 
+void WsWuInfo::doGetGraphs(IArrayOf<IEspECLGraph>& graphs)
+{
+    SCMStringBuffer runningGraph;
+    WUGraphIDType id;
+
+    WUState st = cw->getState();
+    bool running = (!(st==WUStateFailed || st==WUStateAborted || st==WUStateCompleted) && cw->getRunningGraph(runningGraph,id));
+
+    Owned<IConstWUGraphMetaIterator> it = &cw->getGraphsMeta(GraphTypeAny);
+    ForEach(*it)
+    {
+        IConstWUGraphMeta &graph = it->query();
+
+        SCMStringBuffer name, label, type;
+        graph.getName(name);
+        graph.getLabel(label);
+
+        graph.getTypeName(type);
+        WUGraphState graphState = graph.getState();
+
+        Owned<IEspECLGraph> g= createECLGraph();
+        g->setName(name.str());
+        g->setLabel(label.str());
+        g->setType(type.str());
+        if (WUGraphComplete == graphState)
+            g->setComplete(true);
+        else if (running && (WUGraphRunning == graphState))
+        {
+            g->setRunning(true);
+            g->setRunningId(id);
+        }
+        else if (WUGraphFailed == graphState)
+            g->setFailed(true);
+
+        if (version >= 1.53)
+        {
+            SCMStringBuffer s;
+            Owned<IConstWUStatistic> whenGraphStarted = cw->getStatistic(NULL, name.str(), StWhenGraphStarted);
+            Owned<IConstWUStatistic> whenGraphFinished = cw->getStatistic(NULL, name.str(), StWhenGraphFinished);
+            if (whenGraphStarted)
+                g->setWhenStarted(whenGraphStarted->getFormattedValue(s).str());
+            if (whenGraphFinished)
+                g->setWhenFinished(whenGraphFinished->getFormattedValue(s).str());
+        }
+        graphs.append(*g.getLink());
+    }
+}
+
 void WsWuInfo::getGraphInfo(IEspECLWorkunit &info, unsigned flags)
 {
      if (version > 1.01)
@@ -716,51 +768,8 @@ void WsWuInfo::getGraphInfo(IEspECLWorkunit &info, unsigned flags)
 
     try
     {
-        SCMStringBuffer runningGraph;
-        WUGraphIDType id;
-
-        WUState st = cw->getState();
-        bool running = (!(st==WUStateFailed || st==WUStateAborted || st==WUStateCompleted) && cw->getRunningGraph(runningGraph,id));
-
         IArrayOf<IEspECLGraph> graphs;
-        Owned<IConstWUGraphMetaIterator> it = &cw->getGraphsMeta(GraphTypeAny);
-        ForEach(*it)
-        {
-            IConstWUGraphMeta &graph = it->query();
-
-            SCMStringBuffer name, label, type;
-            graph.getName(name);
-            graph.getLabel(label);
-
-            graph.getTypeName(type);
-            WUGraphState graphState = graph.getState();
-
-            Owned<IEspECLGraph> g= createECLGraph();
-            g->setName(name.str());
-            g->setLabel(label.str());
-            g->setType(type.str());
-            if (WUGraphComplete == graphState)
-                g->setComplete(true);
-            else if (running && (WUGraphRunning == graphState))
-            {
-                g->setRunning(true);
-                g->setRunningId(id);
-            }
-            else if (WUGraphFailed == graphState)
-                g->setFailed(true);
-
-            if (version >= 1.53)
-            {
-                SCMStringBuffer s;
-                Owned<IConstWUStatistic> whenGraphStarted = cw->getStatistic(NULL, name.str(), StWhenGraphStarted);
-                Owned<IConstWUStatistic> whenGraphFinished = cw->getStatistic(NULL, name.str(), StWhenGraphFinished);
-                if (whenGraphStarted)
-                    g->setWhenStarted(whenGraphStarted->getFormattedValue(s).str());
-                if (whenGraphFinished)
-                    g->setWhenFinished(whenGraphFinished->getFormattedValue(s).str());
-            }
-            graphs.append(*g.getLink());
-        }
+        doGetGraphs(graphs);
         info.setGraphs(graphs);
     }
     catch(IException* e)

+ 2 - 0
esp/services/ws_workunits/ws_workunitsHelpers.hpp

@@ -166,8 +166,10 @@ public:
     void getSourceFiles(IEspECLWorkunit &info, unsigned flags);
     unsigned getTimerCount();
     void getTimers(IEspECLWorkunit &info, unsigned flags);
+    void doGetTimers(IArrayOf<IEspECLTimer>& timers);
     void getHelpers(IEspECLWorkunit &info, unsigned flags);
     void getGraphInfo(IEspECLWorkunit &info, unsigned flags);
+    void doGetGraphs(IArrayOf<IEspECLGraph>& graphs);
     void getWUGraphNameAndTypes(WUGraphType graphType, IArrayOf<IEspNameAndType>& graphNameAndTypes);
     void getGraphTimingData(IArrayOf<IConstECLTimingData> &timingData, unsigned flags);
     bool getFileSize(const char* fileName, const char* IPAddress, offset_t& fileSize);

+ 21 - 4
esp/services/ws_workunits/ws_workunitsQuerySets.cpp

@@ -1642,10 +1642,13 @@ bool CWsWorkunitsEx::onWUQueryDetails(IEspContext &context, IEspWUQueryDetailsRe
             libUsed.append(libs->query().getName(s).str());
         if (libUsed.length())
             resp.setLibrariesUsed(libUsed);
-        unsigned numGraphIds = getGraphIdsByQueryId(querySet, queryId, graphIds);
-        resp.setCountGraphs(numGraphIds);
-        if (numGraphIds > 0)
-            resp.setGraphIds(graphIds);
+        if (version < 1.64)
+        {
+            unsigned numGraphIds = getGraphIdsByQueryId(querySet, queryId, graphIds);
+            resp.setCountGraphs(numGraphIds);
+            if (numGraphIds > 0)
+                resp.setGraphIds(graphIds);
+        }
     }
 
     StringArray logicalFiles;
@@ -1679,6 +1682,20 @@ bool CWsWorkunitsEx::onWUQueryDetails(IEspContext &context, IEspWUQueryDetailsRe
     {
         WsWuInfo winfo(context, wuid);
         resp.setResourceURLCount(winfo.getResourceURLCount());
+        if (version >= 1.64)
+        {
+            IArrayOf<IEspECLTimer> timers;
+            winfo.doGetTimers(timers); //Graph Duration
+            if (timers.length())
+                resp.setWUTimers(timers);
+
+            IArrayOf<IEspECLGraph> graphs;
+            winfo.doGetGraphs(graphs); //Graph Name, Label, Started, Finished, Type
+            unsigned numGraphIds = graphs.length();
+            resp.setCountGraphs(numGraphIds);
+            if (numGraphIds > 0)
+                resp.setWUGraphs(graphs);
+        }
     }
     if (req.getIncludeWsEclAddresses())
     {