瀏覽代碼

HPCC-20103 Fix two problems for retrieving thorslave log

1. The existing ZAP report code fails to read includeThorSlaveLog
flag from ECLWatch UI request. The correct logic should be: if the
flag is 'on', return thor slave logs. The includeThorSlaveLog flag
should be default to 'on'.
2. The getClusterThorGroupName() call should be moved out of the
getWorkunitThorSlaveLog() because getClusterThorGroupName() has
been called before the getWorkunitThorSlaveLog() calls inside ZAP
report code.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 7 年之前
父節點
當前提交
a5009ccd19

+ 1 - 1
esp/scm/ws_workunits.ecm

@@ -1894,7 +1894,7 @@ ESPrequest [nil_remove] WUCreateZAPInfoRequest
     string WhereSlow;
     [min_ver("1.53"), depr_ver("1.70")] string Password;
     [min_ver("1.65")] string ZAPFileName;
-    [min_ver("1.57")] bool IncludeThorSlaveLog(false);
+    [min_ver("1.57")] string IncludeThorSlaveLog("on");
     [min_ver("1.70")] string ZAPPassword;
 };
 

+ 13 - 13
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -2026,7 +2026,7 @@ void WsWuInfo::getWorkunitThorLog(const char* fileName, MemoryBuffer& buf, const
     }
 }
 
-void WsWuInfo::getWorkunitThorSlaveLog(const char *instanceName, const char *ipAddress, const char* logDate,
+void WsWuInfo::getWorkunitThorSlaveLog(const char *groupName, const char *ipAddress, const char* logDate,
     const char* logDir, int slaveNum, MemoryBuffer& buf, const char* outFile, bool forDownload)
 {
     if (isEmpty(logDir))
@@ -2037,17 +2037,12 @@ void WsWuInfo::getWorkunitThorSlaveLog(const char *instanceName, const char *ipA
     StringBuffer slaveIPAddress, logName;
     if (slaveNum > 0)
     {
-        if (isEmpty(instanceName))
-            throw MakeStringException(ECLWATCH_INVALID_INPUT,"Thor instance not specified.");
+        if (isEmpty(groupName))
+            throw MakeStringException(ECLWATCH_INVALID_INPUT,"Thor Group Name not specified.");
 
-        StringBuffer groupName;
-        getClusterThorGroupName(groupName, instanceName);
-        if (groupName.isEmpty())
-            throw MakeStringException(ECLWATCH_INVALID_INPUT, "Failed to get Thor Group Name for %s", instanceName);
-
-        Owned<IGroup> nodeGroup = queryNamedGroupStore().lookup(groupName.str());
+        Owned<IGroup> nodeGroup = queryNamedGroupStore().lookup(groupName);
         if (!nodeGroup || (nodeGroup->ordinality() == 0))
-            throw MakeStringException(ECLWATCH_INVALID_INPUT, "Node group %s not found", groupName.str());
+            throw MakeStringException(ECLWATCH_INVALID_INPUT, "Node group %s not found", groupName);
 
         nodeGroup->queryNode(slaveNum-1).endpoint().getIpText(slaveIPAddress);
         if (slaveIPAddress.length() < 1)
@@ -3723,7 +3718,7 @@ void CWsWuFileHelper::createWUZAPFile(IEspContext& context, Owned<IConstWorkUnit
     createZAPWUGraphProgressFile(request.wuid.str(), inFileNamePrefixWithPath.str());
     createProcessLogfile(cwu, winfo, "EclAgent", folderToZIP.str());
     createProcessLogfile(cwu, winfo, "Thor", folderToZIP.str());
-    if (request.includeThorSlaveLog)
+    if (strieq(request.includeThorSlaveLog.str(), "on"))
         createThorSlaveLogfile(cwu, winfo, folderToZIP.str());
 
     //Write out to ZIP file
@@ -3900,12 +3895,17 @@ void CWsWuFileHelper::readWUFile(const char* wuid, const char* workingFolder, Ws
         break;
     case CWUFileType_ThorSlaveLog:
     {
-        StringBuffer logDir;
+        StringBuffer logDir, groupName;
+        const char* instanceName = item.getClusterGroup();
+        getClusterThorGroupName(groupName, instanceName);
+        if (groupName.isEmpty())
+            throw MakeStringException(ECLWATCH_INVALID_INPUT, "Failed to get Thor Group Name for %s", instanceName);
+
         fileName.set("ThorSlave.log");
         fileMimeType.set(HTTP_TYPE_TEXT_PLAIN);
         getConfigurationDirectory(directories, "log", "thor", item.getProcess(), logDir);
         fileNameWithPath.set(workingFolder).append(PATHSEPCHAR).append(fileName.str());
-        winfo.getWorkunitThorSlaveLog(item.getClusterGroup(), item.getIPAddress(), item.getLogDate(), logDir.str(), item.getSlaveNumber(), mb, fileNameWithPath.str(), false);
+        winfo.getWorkunitThorSlaveLog(groupName.str(), item.getIPAddress(), item.getLogDate(), logDir.str(), item.getSlaveNumber(), mb, fileNameWithPath.str(), false);
         break;
     }
     case CWUFileType_EclAgentLog:

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

@@ -3014,10 +3014,14 @@ bool CWsWorkunitsEx::onWUFile(IEspContext &context,IEspWULogFileRequest &req, IE
             }
             else if (strieq(File_ThorSlaveLog,req.getType()))
             {
-                StringBuffer logDir;
+                StringBuffer logDir, groupName;
                 getConfigurationDirectory(directories, "log", "thor", req.getProcess(), logDir);
+                const char* instanceName = req.getClusterGroup();
+                getClusterThorGroupName(groupName, instanceName);
+                if (groupName.isEmpty())
+                    throw MakeStringException(ECLWATCH_INVALID_INPUT, "Failed to get Thor Group Name for %s", instanceName);
 
-                winfo.getWorkunitThorSlaveLog(req.getClusterGroup(), req.getIPAddress(), req.getLogDate(), logDir.str(), req.getSlaveNumber(), mb, nullptr, false);
+                winfo.getWorkunitThorSlaveLog(groupName.str(), req.getIPAddress(), req.getLogDate(), logDir.str(), req.getSlaveNumber(), mb, nullptr, false);
                 openSaveFile(context, opt, req.getSizeLimit(), "ThorSlave.log", HTTP_TYPE_TEXT_PLAIN, mb, resp);
             }
             else if (strieq(File_EclAgentLog,req.getType()))