Ver código fonte

HPCC-24958 Add getContainerTargetClusters to ESP SMC services

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 4 anos atrás
pai
commit
1de3e2173e

+ 4 - 0
esp/services/ws_dfu/ws_dfuXRefService.cpp

@@ -572,7 +572,11 @@ void addUsedFilesFromPackageMaps(MapStringTo<bool> &usedFileMap, const char *pro
     if (!packageSet)
         throw MakeStringException(ECLWATCH_PACKAGEMAP_NOTRESOLVED, "Unable to retrieve package information from dali /PackageMaps");
     StringArray pmids;
+#ifdef _CONTAINERIZED
+    Owned<IStringIterator> targets = getContainerTargetClusters("roxie", process);
+#else
     Owned<IStringIterator> targets = getTargetClusters("RoxieCluster", process);
+#endif
     ForEach(*targets)
     {
         SCMStringBuffer target;

+ 5 - 1
esp/services/ws_fs/ws_fsService.cpp

@@ -878,7 +878,11 @@ bool CFileSprayEx::getOneDFUWorkunit(IEspContext& context, const char* wuid, IEs
     const char* clusterName = wu->getClusterName(cluster).str();
     if (clusterName && *clusterName)
     {
-        Owned<IStringIterator> targets = getTargetClusters(NULL, clusterName);
+#ifdef _CONTAINERIZED
+        Owned<IStringIterator> targets = getContainerTargetClusters(nullptr, clusterName);
+#else
+        Owned<IStringIterator> targets = getTargetClusters(nullptr, clusterName);
+#endif
         if (!targets->first())
             resultWU->setClusterName(clusterName);
         else

+ 4 - 0
esp/services/ws_machine/ws_machineService.cpp

@@ -2918,7 +2918,11 @@ bool Cws_machineEx::onGetComponentUsage(IEspContext& context, IEspGetComponentUs
 
 StringArray& Cws_machineEx::listTargetClusterNames(IConstEnvironment* constEnv, StringArray& targetClusters)
 {
+#ifdef _CONTAINERIZED
+    Owned<IStringIterator> targets = getContainerTargetClusters(nullptr, nullptr);
+#else
     Owned<IStringIterator> targets = getTargetClusters(nullptr, nullptr);
+#endif
     ForEach(*targets)
     {
         SCMStringBuffer target;

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

@@ -29,6 +29,7 @@
 #include "dautils.hpp"
 #include "httpclient.hpp"
 #include "portlist.h" //ROXIE_SERVER_PORT
+#include "TpWrapper.hpp"
 
 #define DALI_FILE_LOOKUP_TIMEOUT (1000*15*1)  // 15 seconds
 
@@ -37,8 +38,6 @@ const unsigned ROXIECONTROLQUERYTIMEOUT = 3000; //3 second
 const unsigned ROXIECONTROLQUERIESTIMEOUT = 30000; //30 second
 const unsigned ROXIELOCKCONNECTIONTIMEOUT = 60000; //60 second
 
-#define SDS_LOCK_TIMEOUT (5*60*1000) // 5mins, 30s a bit short
-
 //The CQuerySetQueryActionTypes[] has to match with the ESPenum QuerySetQueryActionTypes in the ecm file.
 static unsigned NumOfQuerySetQueryActionTypes = 7;
 static const char *QuerySetQueryActionTypes[] = { "Suspend", "Unsuspend", "ToggleSuspend", "Activate",
@@ -417,7 +416,11 @@ void QueryFilesInUse::loadTarget(IPropertyTree *t, const char *target, unsigned
 
 void QueryFilesInUse::loadTargets(IPropertyTree *t, unsigned flags)
 {
-    Owned<IStringIterator> targets = getTargetClusters("RoxieCluster", NULL);
+#ifdef _CONTAINERIZED
+    Owned<IStringIterator> targets = getContainerTargetClusters("roxie", nullptr);
+#else
+    Owned<IStringIterator> targets = getTargetClusters("RoxieCluster", nullptr);
+#endif
     SCMStringBuffer s;
     ForEach(*targets)
     {
@@ -935,7 +938,12 @@ bool CWsWorkunitsEx::onWUPublishWorkunit(IEspContext &context, IEspWUPublishWork
 bool CWsWorkunitsEx::onWUQuerysets(IEspContext &context, IEspWUQuerysetsRequest & req, IEspWUQuerysetsResponse & resp)
 {
     IArrayOf<IEspQuerySet> querySets;
-    Owned<IStringIterator> targets = getTargetClusters(NULL, NULL);
+#ifdef _CONTAINERIZED
+    Owned<IStringIterator> targets = getContainerTargetClusters(nullptr, nullptr);
+#else
+    Owned<IStringIterator> targets = getTargetClusters(nullptr, nullptr);
+#endif
+
     SCMStringBuffer target;
     ForEach(*targets)
     {
@@ -1612,7 +1620,11 @@ void CWsWorkunitsEx::getSuspendedQueriesByCluster(MapStringTo<bool> &suspendedQu
     }
     else
     {
+#ifdef _CONTAINERIZED
+        Owned<IStringIterator> targets = getContainerTargetClusters("roxie", nullptr);
+#else
         Owned<IStringIterator> targets = getTargetClusters("RoxieCluster", nullptr);
+#endif
         ForEach(*targets)
         {
             SCMStringBuffer target;
@@ -1666,7 +1678,11 @@ bool CWsWorkunitsEx::onWUListQueriesUsingFile(IEspContext &context, IEspWUListQu
     else // if (process && *process)
     {
         SCMStringBuffer targetStr;
+#ifdef _CONTAINERIZED
+        Owned<IStringIterator> targetClusters = getContainerTargetClusters("roxie", process);
+#else
         Owned<IStringIterator> targetClusters = getTargetClusters("RoxieCluster", process);
+#endif
         ForEach(*targetClusters)
             targets.append(targetClusters->str(targetStr).str());
         logMsg.append(", process ").append(process);

+ 41 - 0
esp/smc/SMCLib/TpWrapper.cpp

@@ -2010,3 +2010,44 @@ extern TPWRAPPER_API ISashaCommand* archiveOrRestoreWorkunits(StringArray& wuids
             sashaAddress.str());
     return cmd.getClear();
 }
+
+extern TPWRAPPER_API IStringIterator* getContainerTargetClusters(const char* processType, const char* processName)
+{
+    Owned<CStringArrayIterator> ret = new CStringArrayIterator;
+    Owned<IPropertyTreeIterator> queues = queryComponentConfig().getElements("queues");
+    ForEach(*queues)
+    {
+        IPropertyTree& queue = queues->query();
+        if (!isEmptyString(processType))
+        {
+            const char* type = queue.queryProp("@type");
+            if (isEmptyString(type) || !strieq(type, processType))
+                continue;
+        }
+        const char* qName = queue.queryProp("@name");
+        if (isEmptyString(qName))
+            continue;
+
+        if (!isEmptyString(processName) && !strieq(qName, processName))
+            continue;
+
+        ret->append_unique(qName);
+    }
+    if (!isEmptyString(processType) && !strieq("roxie", processType))
+        return ret.getClear();
+
+    Owned<IPropertyTreeIterator> services = queryComponentConfig().getElements("services[@type='roxie']");
+    ForEach(*services)
+    {
+        IPropertyTree& service = services->query();
+        const char* targetName = service.queryProp("@target");
+        if (isEmptyString(targetName))
+            continue;
+
+        if (!isEmptyString(processName) && !strieq(targetName, processName))
+            continue;
+
+        ret->append_unique(targetName);
+    }
+    return ret.getClear();
+}

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

@@ -211,6 +211,7 @@ private:
 };
 
 extern TPWRAPPER_API ISashaCommand* archiveOrRestoreWorkunits(StringArray& wuids, IProperties* params, bool archive, bool dfu);
+extern TPWRAPPER_API IStringIterator *getContainerTargetClusters(const char* processType, const char* processName);
 
 #endif //_ESPWIZ_TpWrapper_HPP__