瀏覽代碼

HPCC-8104 Fix duplicated log link and empty log view in ECL WU Details

This fix solves three problems found in the Helpers section of ECL WU
Details page. 1. duplicated log files are displayed; 2. The first
thormaster log is displayed when web link to second thormaster log is
selected from the section; 3. A blank page shows when an EclAgent Log
link is selected from the section. The existing code assumes only one
thormaster log (and one eclagent log) per workunit. When more than one
thormaster log entries occur in WU XML, the entries causes extra loops
to generate duplicated links. The existing links contain process name
as an identifier. When a user clicks one of the links, the code always
picks up the first log file based on the process name. Since no related
log line is found from the first log file, a plank page is displayed.

This fix modifies the code to avoid the extra loops. Inside the web link,
the process name is replaced by log file name. If no related log line
can be found in a log file, the page will display: (Not found a log line
related to this workunit).

Signed-off-by: Kevin Wang <kevin.wang@lexisnexis.com>
Kevin Wang 12 年之前
父節點
當前提交
b79008b8cc

+ 4 - 4
esp/eclwatch/ws_XSLT/wuidcommon.xslt

@@ -1246,25 +1246,25 @@
       </xsl:if>
       <xsl:if test="starts-with(Type, 'ThorLog')">
         <td>
-          <a href="/WsWorkunits/WUFile/ThorLog?Wuid={$wuid}&amp;Process={Description}&amp;Type={Type}"
+          <a href="/WsWorkunits/WUFile/ThorLog?Wuid={$wuid}&amp;Name={Name}&amp;Type={Type}"
                         >
             thormaster.log: <xsl:value-of select="Name"/>
           </a>
         </td>
         <td>
-          <a href="javascript:void(0)" onclick="getOptions('thormaster.log', '/WsWorkunits/WUFile/ThorLog?Wuid={$wuid}&amp;Process={Description}&amp;Type={Type}', false); return false;">
+          <a href="javascript:void(0)" onclick="getOptions('thormaster.log', '/WsWorkunits/WUFile/ThorLog?Wuid={$wuid}&amp;Name={Name}&amp;Type={Type}', false); return false;">
             download
           </a>
         </td>
       </xsl:if>
       <xsl:if test="Type = 'EclAgentLog'">
         <td>
-          <a href="/WsWorkunits/WUFile/EclAgentLog?Wuid={$wuid}&amp;Process={Description}&amp;Type=EclAgentLog">
+          <a href="/WsWorkunits/WUFile/EclAgentLog?Wuid={$wuid}&amp;Name={Name}&amp;Type=EclAgentLog">
               eclagent.log: <xsl:value-of select="Name"/>
           </a>
         </td>
         <td>
-          <a href="javascript:void(0)" onclick="getOptions('eclagent.log', '/WsWorkunits/WUFile/EclAgentLog?Wuid={$wuid}&amp;Process={Description}&amp;Type=EclAgentLog', false); return false;">
+          <a href="javascript:void(0)" onclick="getOptions('eclagent.log', '/WsWorkunits/WUFile/EclAgentLog?Wuid={$wuid}&amp;Name={Name}&amp;Type=EclAgentLog', false); return false;">
             download
           </a>
         </td>

+ 29 - 49
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -486,28 +486,18 @@ void WsWuInfo::getHelpers(IEspECLWorkunit &info, unsigned flags)
 
         if (cw->getWuidVersion() > 0)
         {
-            Owned<IStringIterator> eclAgentInstances = cw->getProcesses("EclAgent");
-            ForEach (*eclAgentInstances)
+            Owned<IStringIterator> eclAgentLogs = cw->getLogs("EclAgent");
+            ForEach (*eclAgentLogs)
             {
-                SCMStringBuffer processName;
-                eclAgentInstances->str(processName);
-                if (processName.length() < 1)
+                SCMStringBuffer logName;
+                eclAgentLogs->str(logName);
+                if (logName.length() < 1)
                     continue;
 
-                Owned<IStringIterator> eclAgentLogs = cw->getLogs("EclAgent", processName.str());
-                ForEach (*eclAgentLogs)
-                {
-                    SCMStringBuffer logName;
-                    eclAgentLogs->str(logName);
-                    if (logName.length() < 1)
-                        continue;
-
-                    Owned<IEspECLHelpFile> h= createECLHelpFile("","");
-                    h->setName(logName.str());
-                    h->setDescription(processName.str());
-                    h->setType(File_EclAgentLog);
-                    helpers.append(*h.getLink());
-                }
+                Owned<IEspECLHelpFile> h= createECLHelpFile("","");
+                h->setName(logName.str());
+                h->setType(File_EclAgentLog);
+                helpers.append(*h.getLink());
             }
         }
         else // legacy wuid
@@ -915,14 +905,17 @@ unsigned WsWuInfo::getWorkunitThorLogInfo(IArrayOf<IEspECLHelpFile>& helpers, IE
 
         unsigned numberOfSlaves = clusterInfo->getSize();
 
+        BoolHash uniqueProcesses;
         Owned<IStringIterator> thorInstances = cw->getProcesses("Thor");
         ForEach (*thorInstances)
         {
             SCMStringBuffer processName;
             thorInstances->str(processName);
-            if (processName.length() < 1)
+            if ((processName.length() < 1) || uniqueProcesses.getValue(processName.str()))
                 continue;
 
+            uniqueProcesses.setValue(processName.str(), true);
+
             StringBuffer groupName;
             getClusterThorGroupName(groupName, processName.str());
 
@@ -1608,32 +1601,23 @@ void appendIOStreamContent(MemoryBuffer &mb, IFileIOStream *ios, bool forDownloa
     }
 }
 
-void WsWuInfo::getWorkunitEclAgentLog(const char* eclAgentInstance, MemoryBuffer& buf)
+void WsWuInfo::getWorkunitEclAgentLog(const char* fileName, MemoryBuffer& buf)
 {
-    SCMStringBuffer logname;
-    Owned<IStringIterator> eclAgentLogs = cw->getLogs("EclAgent", eclAgentInstance);
-    ForEach (*eclAgentLogs)
-    {
-        eclAgentLogs->str(logname);
-        if (logname.length() > 0)
-            break;
-    }
-
-    unsigned pid = cw->getAgentPID();
-    if(logname.length() == 0)
-        throw MakeStringException(ECLWATCH_ECLAGENT_LOG_NOT_FOUND,"EclAgent log file not available for workunit %s.", wuid.str());
-    Owned<IFile> rFile = createIFile(logname.str());
+    if(!fileName || !*fileName)
+        throw MakeStringException(ECLWATCH_ECLAGENT_LOG_NOT_FOUND,"Log file not specified");
+    Owned<IFile> rFile = createIFile(fileName);
     if(!rFile)
-        throw MakeStringException(ECLWATCH_CANNOT_OPEN_FILE, "Cannot open file %s.", logname.str());
+        throw MakeStringException(ECLWATCH_CANNOT_OPEN_FILE, "Cannot open file %s.", fileName);
     OwnedIFileIO rIO = rFile->openShared(IFOread,IFSHfull);
     if(!rIO)
-        throw MakeStringException(ECLWATCH_CANNOT_READ_FILE, "Cannot read file %s.", logname.str());
+        throw MakeStringException(ECLWATCH_CANNOT_READ_FILE, "Cannot read file %s.", fileName);
     OwnedIFileIOStream ios = createBufferedIOStream(rIO);
 
     StringBuffer line;
     bool eof = false;
     bool wuidFound = false;
 
+    unsigned pid = cw->getAgentPID();
     VStringBuffer pidstr(" %5d ", pid);
     char const * pidchars = pidstr.str();
     while(!eof)
@@ -1673,25 +1657,21 @@ void WsWuInfo::getWorkunitEclAgentLog(const char* eclAgentInstance, MemoryBuffer
             buf.append(line.length(), line.str());
         }
     }
+
+    if (buf.length() < 1)
+        buf.append(47, "(Not found a log line related to this workunit)");
 }
 
-void WsWuInfo::getWorkunitThorLog(const char* processName, MemoryBuffer& buf)
+void WsWuInfo::getWorkunitThorLog(const char* fileName, MemoryBuffer& buf)
 {
-    SCMStringBuffer logname;
-    Owned<IStringIterator> thorLogs = cw->getLogs("Thor", processName);
-    ForEach (*thorLogs)
-    {
-        thorLogs->str(logname);
-        if (logname.length() > 0)
-            break;
-    }
-
-    Owned<IFile> rFile = createIFile(logname.str());
+    if(!fileName || !*fileName)
+        throw MakeStringException(ECLWATCH_ECLAGENT_LOG_NOT_FOUND,"Log file not specified");
+    Owned<IFile> rFile = createIFile(fileName);
     if (!rFile)
-        throw MakeStringException(ECLWATCH_CANNOT_OPEN_FILE,"Cannot open file %s.",logname.str());
+        throw MakeStringException(ECLWATCH_CANNOT_OPEN_FILE,"Cannot open file %s.",fileName);
     OwnedIFileIO rIO = rFile->openShared(IFOread,IFSHfull);
     if (!rIO)
-        throw MakeStringException(ECLWATCH_CANNOT_READ_FILE,"Cannot read file %s.",logname.str());
+        throw MakeStringException(ECLWATCH_CANNOT_READ_FILE,"Cannot read file %s.",fileName);
     OwnedIFileIOStream ios = createBufferedIOStream(rIO);
 
     StringBuffer line;

+ 2 - 2
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -2633,7 +2633,7 @@ bool CWsWorkunitsEx::onWUFile(IEspContext &context,IEspWULogFileRequest &req, IE
             }
             else if (strncmp(req.getType(), File_ThorLog, 7) == 0)
             {
-                winfo.getWorkunitThorLog(req.getProcess(), mb);
+                winfo.getWorkunitThorLog(req.getName(), mb);
                 openSaveFile(context, opt, "thormaster.log", HTTP_TYPE_TEXT_PLAIN, mb, resp);
             }
             else if (strieq(File_ThorSlaveLog,req.getType()))
@@ -2646,7 +2646,7 @@ bool CWsWorkunitsEx::onWUFile(IEspContext &context,IEspWULogFileRequest &req, IE
             }
             else if (strieq(File_EclAgentLog,req.getType()))
             {
-                winfo.getWorkunitEclAgentLog(req.getProcess(), mb);
+                winfo.getWorkunitEclAgentLog(req.getName(), mb);
                 openSaveFile(context, opt, "eclagent.log", HTTP_TYPE_TEXT_PLAIN, mb, resp);
             }
             else if (strieq(File_XML,req.getType()))