Просмотр исходного кода

HPCC-25331 Fix packagemap lookup of cluster information in cloud

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexisrisk.com>
Anthony Fishbeck 4 лет назад
Родитель
Сommit
4d5a94b72d

+ 1 - 0
esp/services/ws_packageprocess/CMakeLists.txt

@@ -42,6 +42,7 @@ include_directories (
          ${HPCC_SOURCE_DIR}/common/thorhelper
          ${HPCC_SOURCE_DIR}/rtl/eclrtl
          ${HPCC_SOURCE_DIR}/dali/dfu
+         ${HPCC_SOURCE_DIR}/dali/sasha
          ${HPCC_SOURCE_DIR}/fs/dafsclient
          ${HPCC_SOURCE_DIR}/common/workunit
          ${HPCC_SOURCE_DIR}/rtl/include

+ 9 - 16
esp/services/ws_packageprocess/ws_packageprocessService.cpp

@@ -29,8 +29,7 @@
 #include "package.h"
 #include "eclwatch_errorlist.hpp"
 #include "exception_util.hpp"
-
-#define SDS_LOCK_TIMEOUT (5*60*1000) // 5mins, 30s a bit short
+#include "TpWrapper.hpp"
 
 void CWsPackageProcessEx::init(IPropertyTree *cfg, const char *process, const char *service)
 {
@@ -102,8 +101,6 @@ IPropertyTree *getPkgSetRegistry(const char *process, bool readonly)
 ////////////////////////////////////////////////////////////////////////////////////////
 const unsigned roxieQueryRoxieTimeOut = 60000;
 
-#define SDS_LOCK_TIMEOUT (5*60*1000) // 5mins, 30s a bit short
-
 bool isFileKnownOnCluster(const char *logicalname, IConstWUClusterInfo *clusterInfo, IUserDescriptor* userdesc)
 {
     Owned<IDistributedFile> dst = queryDistributedFileDirectory().lookup(logicalname, userdesc, true, false, false, nullptr, defaultPrivilegedUser);
@@ -119,7 +116,7 @@ bool isFileKnownOnCluster(const char *logicalname, IConstWUClusterInfo *clusterI
 
 bool isFileKnownOnCluster(const char *logicalname, const char *target, IUserDescriptor* userdesc)
 {
-    Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
+    Owned<IConstWUClusterInfo> clusterInfo = getWUClusterInfoByName(target);
     if (!clusterInfo)
         throw MakeStringException(PKG_TARGET_NOT_DEFINED, "Could not find information about target cluster %s ", target);
 
@@ -160,7 +157,7 @@ void cloneFileInfoToDali(unsigned updateFlags, StringArray &notFound, IPropertyT
 
 void cloneFileInfoToDali(unsigned updateFlags, StringArray &notFound, IPropertyTree *packageMap, const char *lookupDaliIp, const char *dstCluster, const char *srcCluster, const char *prefix, IUserDescriptor* userdesc, bool allowForeignFiles)
 {
-    Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(dstCluster);
+    Owned<IConstWUClusterInfo> clusterInfo = getWUClusterInfoByName(dstCluster);
     if (!clusterInfo)
         throw MakeStringException(PKG_TARGET_NOT_DEFINED, "Could not find information about target cluster %s ", dstCluster);
 
@@ -274,7 +271,7 @@ public:
     }
     IConstWUClusterInfo *ensureClusterInfo()
     {
-        clusterInfo.setown(getTargetClusterInfo(target));
+        clusterInfo.setown(getWUClusterInfoByName(target));
         if (!clusterInfo)
             throw MakeStringException(PKG_TARGET_NOT_DEFINED, "Could not find information about target cluster %s ", target.str());
         return clusterInfo;
@@ -370,7 +367,7 @@ public:
         else
         {
             CConstWUClusterInfoArray clusters;
-            getEnvironmentClusterInfo(clusters);
+            getWUClusterInfo(clusters);
             ForEachItemIn(i, clusters)
             {
                 IConstWUClusterInfo &cluster = clusters.item(i);
@@ -1129,7 +1126,7 @@ bool CWsPackageProcessEx::onValidatePackage(IEspContext &context, IEspValidatePa
         IArrayOf<IEspValidateResult> results;
         if (!streq(target, "*"))
         {
-            Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
+            Owned<IConstWUClusterInfo> clusterInfo = getWUClusterInfoByName(target);
             if (!clusterInfo)
                 throw makeStringException(PKG_TARGET_NOT_DEFINED, "Target cluster not found");
             validatePackage(context, req, packageMapTree, clusterInfo, queriesToVerify, queriesToIgnore,
@@ -1138,7 +1135,7 @@ bool CWsPackageProcessEx::onValidatePackage(IEspContext &context, IEspValidatePa
         else
         {
             CConstWUClusterInfoArray clusters;
-            getEnvironmentClusterInfo(clusters);
+            getWUClusterInfo(clusters);
             ForEachItemIn(i, clusters)
             {
                 IConstWUClusterInfo &cluster = clusters.item(i);
@@ -1253,13 +1250,9 @@ bool CWsPackageProcessEx::onGetPackageMapSelectOptions(IEspContext &context, IEs
         bool includeProcesses = req.getIncludeProcesses();
         if (includeTargets || includeProcesses)
         {
-            Owned<IEnvironmentFactory> factory = getEnvironmentFactory(true);
-            Owned<IConstEnvironment> env = factory->openEnvironment();
-            Owned<IPropertyTree> root = &env->getPTree();
-
             IArrayOf<IConstTargetData> targets;
             CConstWUClusterInfoArray clusters;
-            getEnvironmentClusterInfo(root, clusters);
+            getWUClusterInfo(clusters);
             ForEachItemIn(c, clusters)
             {
                 SCMStringBuffer str;
@@ -1348,7 +1341,7 @@ bool CWsPackageProcessEx::onGetQueryFileMapping(IEspContext &context, IEspGetQue
     if (!target || !*target)
         throw MakeStringException(PKG_TARGET_NOT_DEFINED, "Target cluster required");
 
-    Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
+    Owned<IConstWUClusterInfo> clusterInfo = getWUClusterInfoByName(target);
     if (!clusterInfo)
         throw MakeStringException(PKG_TARGET_NOT_DEFINED, "Unable to find target cluster");
     if (clusterInfo->getPlatform()!=RoxieCluster)

+ 17 - 5
esp/smc/SMCLib/TpWrapper.cpp

@@ -2077,6 +2077,7 @@ class CContainerWUClusterInfo : public CSimpleInterfaceOf<IConstWUClusterInfo>
     StringAttr thorQueue;
     ClusterType platform;
     unsigned clusterWidth;
+    StringArray thorProcesses;
 
 public:
     CContainerWUClusterInfo(const char* _name, const char* type, unsigned _clusterWidth)
@@ -2087,6 +2088,7 @@ public:
         {
             thorQueue.set(getClusterThorQueueName(queue.clear(), name));
             platform = ThorLCRCluster;
+            thorProcesses.append(name);
         }
         else if (strieq(type, "roxie"))
         {
@@ -2156,11 +2158,12 @@ public:
     }
     virtual IStringVal & getRoxieProcess(IStringVal & str) const override
     {
-        UNIMPLEMENTED;
+        str.set(name.get());
+        return str;
     }
     virtual const StringArray & getThorProcesses() const override
     {
-        UNIMPLEMENTED;
+        return thorProcesses;
     }
     virtual const StringArray & getPrimaryThorProcesses() const override
     {
@@ -2180,15 +2183,15 @@ public:
     }
     virtual unsigned getRoxieRedundancy() const override
     {
-        UNIMPLEMENTED;
+        return 1;
     }
     virtual unsigned getChannelsPerNode() const override
     {
-        UNIMPLEMENTED;
+        return 1;
     }
     virtual int getRoxieReplicateOffset() const override
     {
-        UNIMPLEMENTED;
+        return 0;
     }
     virtual const char *getAlias() const override
     {
@@ -2210,6 +2213,15 @@ extern TPWRAPPER_API unsigned getContainerWUClusterInfo(CConstWUClusterInfoArray
     return clusters.ordinality();
 }
 
+extern TPWRAPPER_API unsigned getWUClusterInfo(CConstWUClusterInfoArray& clusters)
+{
+#ifndef _CONTAINERIZED
+    return getEnvironmentClusterInfo(clusters);
+#else
+    return getContainerWUClusterInfo(clusters);
+#endif
+}
+
 extern TPWRAPPER_API IConstWUClusterInfo* getWUClusterInfoByName(const char* clusterName)
 {
 #ifndef _CONTAINERIZED

+ 1 - 0
esp/smc/SMCLib/TpWrapper.hpp

@@ -215,6 +215,7 @@ private:
 extern TPWRAPPER_API ISashaCommand* archiveOrRestoreWorkunits(StringArray& wuids, IProperties* params, bool archive, bool dfu);
 
 extern TPWRAPPER_API unsigned getContainerWUClusterInfo(CConstWUClusterInfoArray& clusters);
+extern TPWRAPPER_API unsigned getWUClusterInfo(CConstWUClusterInfoArray& clusters);
 extern TPWRAPPER_API IConstWUClusterInfo* getWUClusterInfoByName(const char* clustName);
 
 extern TPWRAPPER_API IStringIterator *getContainerTargetClusters(const char* processType, const char* processName);