瀏覽代碼

HPCC-12426 Add WUQueryDetails option to list applicable WsEcl Addresses

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 10 年之前
父節點
當前提交
106cdd7fe6
共有 2 個文件被更改,包括 65 次插入0 次删除
  1. 2 0
      esp/scm/ws_workunits.ecm
  2. 63 0
      esp/services/ws_workunits/ws_workunitsQuerySets.cpp

+ 2 - 0
esp/scm/ws_workunits.ecm

@@ -1334,6 +1334,7 @@ ESPrequest WUQueryDetailsRequest
     string QuerySet;
     bool IncludeStateOnClusters(false);
     bool IncludeSuperFiles(false);
+    bool IncludeWsEclAddresses(false);
 };
 
 ESPStruct QuerySuperFile
@@ -1366,6 +1367,7 @@ ESPresponse [exceptions_inline] WUQueryDetailsResponse
     [min_ver("1.46")] int CountGraphs;
     [min_ver("1.46")] ESParray<string> GraphIds;
     [min_ver("1.50")] int ResourceURLCount;
+    [min_ver("1.51")] ESParray<string, Address> WsEclAddresses;
 };
 
 ESPrequest WUMultiQuerySetDetailsRequest

+ 63 - 0
esp/services/ws_workunits/ws_workunitsQuerySets.cpp

@@ -1593,6 +1593,69 @@ bool CWsWorkunitsEx::onWUQueryDetails(IEspContext &context, IEspWUQueryDetailsRe
         WsWuInfo winfo(context, wuid);
         resp.setResourceURLCount(winfo.getResourceURLCount());
     }
+    if (req.getIncludeWsEclAddresses())
+    {
+        StringBuffer daliAddress;
+        if (!daliServers.isEmpty())
+        {
+            const char *finger = daliServers.get();
+            while (*finger && !strchr(":;,", *finger))
+                daliAddress.append(*finger++);
+        }
+
+        StringArray wseclAddresses;
+        Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
+        Owned<IConstEnvironment> env = factory->openEnvironment();
+        if (env)
+        {
+            Owned<IPropertyTree> root = &env->getPTree();
+            Owned<IPropertyTreeIterator> services = root->getElements("Software/EspService[Properties/@type='ws_ecl']");
+            StringArray serviceNames;
+            VStringBuffer xpath("Target[@name='%s']", querySet);
+            ForEach(*services)
+            {
+                IPropertyTree &service = services->query();
+                if (!service.hasProp("Target") || service.hasProp(xpath))
+                    serviceNames.append(service.queryProp("@name"));
+            }
+
+            Owned<IPropertyTreeIterator> processes = root->getElements("Software/EspProcess");
+            ForEach(*processes)
+            {
+                StringArray netAddrs;
+                IPropertyTree &process = processes->query();
+                Owned<IPropertyTreeIterator> instances = process.getElements("Instance");
+                ForEach(*instances)
+                {
+                    IPropertyTree &instance = instances->query();
+                    const char *netAddr = instance.queryProp("@netAddress");
+                    if (!netAddr || !*netAddr)
+                        continue;
+                    if (streq(netAddr, ".") && daliAddress.length())
+                        netAddrs.append(daliAddress);
+                    else
+                        netAddrs.append(netAddr);
+                }
+                Owned<IPropertyTreeIterator> bindings = process.getElements("EspBinding");
+                ForEach(*bindings)
+                {
+                    IPropertyTree &binding = bindings->query();
+                    const char *srvName = binding.queryProp("@service");
+                    if (!serviceNames.contains(srvName))
+                        continue;
+                    const char *port = binding.queryProp("@port");
+                    if (!port || !*port)
+                        continue;
+                    ForEachItemIn(i, netAddrs)
+                    {
+                        VStringBuffer wseclAddr("%s:%s", netAddrs.item(i), port);
+                        wseclAddresses.append(wseclAddr);
+                    }
+                }
+            }
+        }
+        resp.setWsEclAddresses(wseclAddresses);
+    }
 
     return true;
 }