Explorar o código

HPCC-13092 Return more variables in WsTopology.TpGroupQuery

1. return the 'kind' (Thor, Roxie, or HThor) for each Group;
2. return the '@replicateOutputs' of the thor cluster which
uses the Group.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx %!s(int64=10) %!d(string=hai) anos
pai
achega
e7bd6bb953

+ 6 - 5
esp/scm/ws_topology.ecm

@@ -63,10 +63,11 @@ ESPStruct TpLogicalCluster
 
 //  ===========================================================================
 
-ESPStruct TpGroup
+ESPStruct [nil_remove] TpGroup
 {
     string Name;
-    string Prefix;
+    [min_ver("1.21")] string Kind;
+    [min_ver("1.21")] bool ReplicateOutputs;
 };
 
 //  ===========================================================================
@@ -353,9 +354,9 @@ ESPresponse [exceptions_inline] TpLogicalClusterQueryResponse
 };
 
 
-ESPrequest TpGroupQueryRequest
+ESPrequest [nil_remove] TpGroupQueryRequest
 {
-    
+    [min_ver("1.21")] string Kind;
 };
 
 ESPresponse [exceptions_inline] TpGroupQueryResponse
@@ -582,7 +583,7 @@ ESPresponse [exceptions_inline,encode(0)] TpGetServicePluginsResponse
     ESParray<ESPstruct TpEspServicePlugin, Plugin> Plugins;
 };
 
-ESPservice [noforms, version("1.20"), default_client_version("1.20"), exceptions_inline("./smc_xslt/exceptions.xslt")] WsTopology
+ESPservice [noforms, version("1.21"), default_client_version("1.21"), exceptions_inline("./smc_xslt/exceptions.xslt")] WsTopology
 {
     ESPuses ESPStruct TpBinding;
     ESPuses ESPstruct TpCluster;

+ 1 - 1
esp/services/ws_topology/ws_topologyService.cpp

@@ -1212,7 +1212,7 @@ bool CWsTopologyEx::onTpGroupQuery(IEspContext &context, IEspTpGroupQueryRequest
             throw MakeStringException(ECLWATCH_TOPOLOGY_ACCESS_DENIED, "Failed to do Group Query. Permission denied.");
 
         IArrayOf<IEspTpGroup> Groups;
-        m_TpWrapper.getGroupList(Groups);
+        m_TpWrapper.getGroupList(context.getClientVersion(), req.getKind(), Groups);
         resp.setTpGroups(Groups);
     }
     catch(IException* e)

+ 45 - 10
esp/smc/SMCLib/TpWrapper.cpp

@@ -1320,32 +1320,67 @@ void CTpWrapper::getHthorClusterList(IArrayOf<IEspTpCluster>& clusterList)
 }
 
 
-void CTpWrapper::getGroupList(IArrayOf<IEspTpGroup> &GroupList)
+void CTpWrapper::getGroupList(double espVersion, const char* kindReq, IArrayOf<IEspTpGroup> &GroupList)
 {
     try
     {
         Owned<IRemoteConnection> conn = querySDS().connect("/Groups", myProcessSession(), RTM_LOCK_READ, SDS_LOCK_TIMEOUT);
         Owned<IPropertyTreeIterator> groups= conn->queryRoot()->getElements("Group");
-        if (groups->first()) {
-            do {
+        if (groups->first())
+        {
+            do
+            {
                 IPropertyTree &group = groups->query();
+                const char* kind = group.queryProp("@kind");
+                if (kindReq && *kindReq && !strieq(kindReq, kind))
+                    continue;
+
                 IEspTpGroup* pGroup = createTpGroup("","");
-                pGroup->setName(group.queryProp("@name"));
+                const char* name = group.queryProp("@name");
+                pGroup->setName(name);
+                if (espVersion >= 1.21)
+                {
+                    pGroup->setKind(kind);
+                    pGroup->setReplicateOutputs(checkGroupReplicateOutputs(name, kind));
+                }
                 GroupList.append(*pGroup);
-                
             } while (groups->next());
         }
     }
-    catch(IException* e){   
-      StringBuffer msg;
-      e->errorMessage(msg);
+    catch(IException* e)
+    {
+        StringBuffer msg;
+        e->errorMessage(msg);
         WARNLOG("%s", msg.str());
         e->Release();
     }
-    catch(...){
+    catch(...)
+    {
         WARNLOG("Unknown Exception caught within CTpWrapper::getGroupList");
     }
-    StringBuffer cluster;
+}
+
+bool CTpWrapper::checkGroupReplicateOutputs(const char* groupName, const char* kind)
+{
+    if (strieq(kind, "Roxie") || strieq(kind, "hthor"))
+        return false;
+
+    Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
+    Owned<IConstEnvironment> environment = factory->openEnvironment();
+    Owned<IPropertyTree> root = &environment->getPTree();
+    if (!root)
+        throw MakeStringException(ECLWATCH_CANNOT_GET_ENV_INFO, "Failed to get environment information.");
+
+    Owned<IPropertyTreeIterator> it= root->getElements("Software/ThorCluster");
+    ForEach(*it)
+    {
+        StringBuffer thorClusterGroupName;
+        IPropertyTree& cluster = it->query();
+        getClusterGroupName(cluster, thorClusterGroupName);
+        if (thorClusterGroupName.length() && strieq(thorClusterGroupName.str(), groupName))
+            return cluster.getPropBool("@replicateOutputs", false);
+    }
+    return false;
 }
 
 void CTpWrapper::resolveGroupInfo(const char* groupName,StringBuffer& Cluster, StringBuffer& ClusterPrefix)

+ 4 - 3
esp/smc/SMCLib/TpWrapper.hpp

@@ -136,8 +136,9 @@ private:
     void getAttPath(const char* Path,StringBuffer& returnStr);
     bool ContainsProcessDefinition(IPropertyTree& node,const char* clusterName);
     const char* getNodeNameTag(const char* MachineType);
-   void fetchInstances(const char* ServiceType, IPropertyTree& service, IArrayOf<IEspTpMachine>& tpMachines);
-    
+    void fetchInstances(const char* ServiceType, IPropertyTree& service, IArrayOf<IEspTpMachine>& tpMachines);
+    bool checkGroupReplicateOutputs(const char* groupName, const char* kind);
+
 public:
     IMPLEMENT_IINTERFACE;
     CTpWrapper() {};
@@ -146,7 +147,7 @@ public:
     bool getClusterLCR(const char* clusterType, const char* clusterName);
     void getClusterProcessList(const char* ClusterType, IArrayOf<IEspTpCluster>& clusters, bool ignoreduplicatqueues=false, bool ignoreduplicategroups=false);
     void getHthorClusterList(IArrayOf<IEspTpCluster>& clusterList);
-    void getGroupList(IArrayOf<IEspTpGroup> &Groups);
+    void getGroupList(double espVersion, const char* kindReq, IArrayOf<IEspTpGroup> &Groups);
     void getCluster(const char* ClusterType,IPropertyTree& returnRoot);
     void getClusterMachineList(double clientVersion, const char* ClusterType,const char* ClusterPath, const char* ClusterDirectory, 
                                         IArrayOf<IEspTpMachine> &MachineList, bool& hasThorSpareProcess, const char* ClusterName = NULL);