Browse Source

HPCC-10490 Show primary clusters for XRef

In multi-thor setups, the XREF cluster list should show
primary thor instances. In this fix, getPrimaryThorProcesses()
is added to IConstWUClusterInfo. The method picks primary
thor instance only if thor name matches the group name.
Using that method, WsDfuXRef service shows primary thor
instances in the XREF cluster list.

Signed-off-by: Kevin Wang kevin.wang@lexisnexis.com
Kevin Wang 11 years ago
parent
commit
2c621b41d6

+ 16 - 1
common/workunit/workunit.cpp

@@ -4256,6 +4256,7 @@ class CEnvironmentClusterInfo: public CInterface, implements IConstWUClusterInfo
     SocketEndpointArray roxieServers;
     StringAttr thorQueue;
     StringArray thorProcesses;
+    StringArray primaryThorProcess;
     StringAttr prefix;
     ClusterType platform;
     unsigned clusterWidth;
@@ -4269,10 +4270,20 @@ public:
         {
             thorQueue.set(getClusterThorQueueName(queue.clear(), name));
             clusterWidth = 0;
+            bool isMultiThor = (thors.length() > 1);
             ForEachItemIn(i,thors) 
             {
                 IPropertyTree &thor = thors.item(i);
-                thorProcesses.append(thor.queryProp("@name"));
+                const char* thorName = thor.queryProp("@name");
+                thorProcesses.append(thorName);
+                if (!isMultiThor)
+                    primaryThorProcess.append(thorName);
+                else
+                {
+                    const char *nodeGroup = thor.queryProp("@nodeGroup");
+                    if (!nodeGroup || strieq(nodeGroup, thorName))
+                        primaryThorProcess.append(thorName);
+                }
                 unsigned nodes = thor.getCount("ThorSlaveProcess");
                 if (!nodes)
                     throw MakeStringException(WUERR_MismatchClusterSize,"CEnvironmentClusterInfo: Thor cluster can not have 0 slave processes");
@@ -4351,6 +4362,10 @@ public:
     {
         return thorProcesses;
     }
+    const StringArray & getPrimaryThorProcesses() const
+    {
+        return primaryThorProcess;
+    }
 
     const SocketEndpointArray & getRoxieServers() const
     {

+ 1 - 0
common/workunit/workunit.hpp

@@ -552,6 +552,7 @@ interface IConstWUClusterInfo : extends IInterface
     virtual IStringVal & getServerQueue(IStringVal & str) const = 0;
     virtual IStringVal & getRoxieProcess(IStringVal & str) const = 0;
     virtual const StringArray & getThorProcesses() const = 0;
+    virtual const StringArray & getPrimaryThorProcesses() const = 0;
     virtual const SocketEndpointArray & getRoxieServers() const = 0;
 };
 

+ 31 - 27
esp/services/ws_dfu/ws_dfuXRefService.cpp

@@ -455,6 +455,24 @@ bool CWsDfuXRefEx::onDFUXRefBuildCancel(IEspContext &context, IEspDFUXRefBuildCa
     return true;
 }
 
+void CWsDfuXRefEx::addXRefNode(const char* name, IPropertyTree* pXRefNodeTree)
+{
+    IPropertyTree* XRefTreeNode = pXRefNodeTree->addPropTree("XRefNode", createPTree(ipt_caseInsensitive));
+    XRefTreeNode->setProp("Name",name);
+    Owned<IXRefNode> xRefNode = XRefNodeManager->getXRefNode(name);
+    if (!xRefNode)
+    {
+        XRefTreeNode->setProp("Modified","");
+        XRefTreeNode->setProp("Status","Not Run");
+    }
+    else
+    {
+        StringBuffer modified, status;
+        XRefTreeNode->setProp("Modified",xRefNode->getLastModified(modified).str());
+        XRefTreeNode->setProp("Status",xRefNode->getStatus(status).str());
+    }
+}
+
 bool CWsDfuXRefEx::onDFUXRefList(IEspContext &context, IEspDFUXRefListRequest &req, IEspDFUXRefListResponse &resp)
 {
     try
@@ -467,39 +485,25 @@ bool CWsDfuXRefEx::onDFUXRefList(IEspContext &context, IEspDFUXRefListRequest &r
         DBGLOG("CWsDfuXRefEx::onDFUXRefList User=%s",username.str());
 
 
-        //Firstly we need to get a list of the available Thor Cluster....
-        IArrayOf<IEspTpCluster> clusters;
-        CTpWrapper _topology;
-        _topology.getClusterProcessList(eqThorCluster,clusters,false,true);
-        ///_topology.getClusterList(eqRoxieCluster,clusters,false,true);
+        CConstWUClusterInfoArray clusters;
+        getEnvironmentClusterInfo(clusters);
 
+        BoolHash uniqueProcesses;
         Owned<IPropertyTree> pXRefNodeTree = createPTree("XRefNodes");
-        //DBGLOG("CWsDfuXRefEx::onDFUXRefList1\n");
-
-        for (unsigned x=0;x<=clusters.ordinality();x++)
+        ForEachItemIn(c, clusters)
         {
-            IPropertyTree* XRefTreeNode = pXRefNodeTree->addPropTree("XRefNode", createPTree(ipt_caseInsensitive));
-            
-            IEspTpCluster* cluster = x<clusters.ordinality()?&clusters.item(x):NULL;        
-            const char *clustername = cluster?cluster->getName():"SuperFiles";
-
-            XRefTreeNode->setProp("Name",clustername);
-            //create the node if it doesn;t exist
-            Owned<IXRefNode> xRefNode = XRefNodeManager->getXRefNode(clustername);
-            if (xRefNode == 0)
-            {
-                XRefTreeNode->setProp("Modified","");
-                XRefTreeNode->setProp("Status","Not Run");
-            }
-            else
+            IConstWUClusterInfo &cluster = clusters.item(c);
+            const StringArray &primaryThorProcesses = cluster.getPrimaryThorProcesses();
+            ForEachItemIn(i,primaryThorProcesses)
             {
-                  StringBuffer buf;
-                XRefTreeNode->setProp("Modified",xRefNode->getLastModified(buf).str());
-                    buf.clear();
-                XRefTreeNode->setProp("Status",xRefNode->getStatus(buf).str());
+                const char *thorProcess = primaryThorProcesses.item(i);
+                if (uniqueProcesses.getValue(thorProcess))
+                    continue;
+                uniqueProcesses.setValue(thorProcess, true);
+                addXRefNode(thorProcess, pXRefNodeTree);
             }
         }
-        
+        addXRefNode("SuperFiles", pXRefNodeTree);
 
         StringBuffer buf;
         resp.setDFUXRefListResult(toXML(pXRefNodeTree, buf).str());

+ 1 - 0
esp/services/ws_dfu/ws_dfuXRefService.hpp

@@ -160,6 +160,7 @@ private:
 
 private:
     IXRefFilesNode* getFileNodeInterface(IXRefNode& XRefNode,const char* nodeType);
+    void addXRefNode(const char* name, IPropertyTree* pXRefNodeTree);
 public:
    IMPLEMENT_IINTERFACE;