Browse Source

Merge pull request #11906 from mayx/HPCC-20739-ExtraBinding

HPCC-20739 No need to load or show empty static ESDL binding

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 6 years ago
parent
commit
57ac86187a
2 changed files with 35 additions and 92 deletions
  1. 21 18
      esp/platform/espcfg.cpp
  2. 14 74
      esp/services/esdl_svc_engine/esdl_monitor.cpp

+ 21 - 18
esp/platform/espcfg.cpp

@@ -473,26 +473,29 @@ CEspConfig::CEspConfig(IProperties* inputs, IPropertyTree* envpt, IPropertyTree*
                     else
                     {
                         ptree->getProp("@type", bcfg->type);
-                        ptree->getProp("@plugin", bcfg->plugin);
-                        fixPlugin(bcfg->plugin);
-                        bcfg->isDefault = ptree->getPropBool("@defaultBinding", false);
-
-                        StringBuffer addr;
-                        ptree->getProp("@netAddress", addr);
-                        if (strcmp(addr.str(), ".") == 0)
-                        {
-                            // Here we interpret '.' as binding to all interfaces, so convert it to "0.0.0.0"
-                            bcfg->address.append("0.0.0.0");
-                        }
-                        else
+                        if (!streq(bcfg->type.str(), "EsdlBinding"))
                         {
-                            bcfg->address.append(addr.str());
+                            ptree->getProp("@plugin", bcfg->plugin);
+                            fixPlugin(bcfg->plugin);
+                            bcfg->isDefault = ptree->getPropBool("@defaultBinding", false);
+
+                            StringBuffer addr;
+                            ptree->getProp("@netAddress", addr);
+                            if (strcmp(addr.str(), ".") == 0)
+                            {
+                                // Here we interpret '.' as binding to all interfaces, so convert it to "0.0.0.0"
+                                bcfg->address.append("0.0.0.0");
+                            }
+                            else
+                            {
+                                bcfg->address.append(addr.str());
+                            }
+
+                            ptree->getProp("@service", bcfg->service_name);
+                            ptree->getProp("@protocol", bcfg->protocol_name);
+
+                            m_bindings.push_back(bcfg.getClear());
                         }
-
-                        ptree->getProp("@service", bcfg->service_name);
-                        ptree->getProp("@protocol", bcfg->protocol_name);
-
-                        m_bindings.push_back(bcfg.getClear());
                     }
                 }
 

+ 14 - 74
esp/services/esdl_svc_engine/esdl_monitor.cpp

@@ -235,14 +235,6 @@ public:
                 continue;
             }
             cur.getProp("@espbinding", data->name);
-            if (data->name.length() != 0 && existsStaticBinding(data->name.str()))
-            {
-                DBGLOG("ESDL binding %s has esp binding configured, no need to create it dynamically, skip.", data->id.str());
-                continue;
-            }
-            else
-                DBGLOG("ESDL binding %s doesn't have esp binding configured, creating the binding dynamically...", data->id.str());
-
             data->port = cur.getPropInt("@port");
             if (data->port == 0)
             {
@@ -299,19 +291,11 @@ public:
             if (theBinding)
             {
                 DBGLOG("Requesting clearing of binding %s", data->id.str());
-                if (data->name.length() > 0 && existsStaticBinding(data->name.str()))
-                {
-                    DBGLOG("Static esp binding exists for this esdl binding.");
-                    theBinding->reloadBindingFromCentralStore(data->id.str()); //clear the binding by reloading
-                }
-                else
-                {
-                    theBinding->clearBindingState();
-                    if (data->port <= 0)
-                        data->port = theBinding->getPort();
-                    DBGLOG("Removing binding from port %d", data->port);
-                    queryEspServer()->removeBinding(data->port, *theBinding);
-                }
+                theBinding->clearBindingState();
+                if (data->port <= 0)
+                    data->port = theBinding->getPort();
+                DBGLOG("Removing binding from port %d", data->port);
+                queryEspServer()->removeBinding(data->port, *theBinding);
                 removeBindingFromMap(data->id.str());
             }
             else
@@ -346,41 +330,14 @@ public:
                 return;
             }
 
-            bool existsStatic = false;
-            if (data->name.length() > 0)
-                existsStatic = existsStaticBinding(data->name.str());
-            else
+            if (data->name.length() == 0)
                 data->name.set(data->id);
-            if (!existsStatic)
-            {
-                DBGLOG("ESDL binding %s doesn't have esp binding configured, creating the binding dynamically...", data->id.str());
-                if (data->port == 0)
-                {
-                    DBGLOG("Port is not provided for binding, can't create binding.");
-                    return;
-                }
-                addBinding(data);
-            }
-            else
+            if (data->port == 0)
             {
-                DBGLOG("ESDL binding %s has esp binding configured, reloading the esp binding...", data->id.str());
-                //Reload static binding
-                IEspServer* server = queryEspServer();
-                IEspRpcBinding* espBinding = server->queryBinding(data->name.str());
-                if (espBinding != nullptr)
-                {
-                    EsdlBindingImpl* esdlBinding = dynamic_cast<EsdlBindingImpl*>(espBinding);
-                    if (esdlBinding != nullptr)
-                    {
-                        esdlBinding->reloadBindingFromCentralStore(data->id.str());
-                        registerBinding(data->id.str(), esdlBinding);
-                    }
-                    else
-                        DBGLOG("The esp binding failed to be cast to esdl binding.");
-                }
-                else
-                    DBGLOG("Esp binding not found.");
+                DBGLOG("Port is not provided for binding, can't create binding.");
+                return;
             }
+            addBinding(data);
         }
         else
         {
@@ -432,21 +389,6 @@ private:
         DBGLOG("Successfully instantiated new DESDL binding %s and service", data->id.str());
     }
 
-    bool existsStaticBinding(const char* espBinding)
-    {
-        if (!espBinding || !*espBinding)
-            return false;
-        DBGLOG("Checking if there is esp binding %s configured...", espBinding);
-        IPropertyTree* procpt = queryEspServer()->queryProcConfig();
-        if (procpt)
-        {
-            VStringBuffer xpath("EspBinding[@name='%s']", espBinding);
-            if (procpt->queryPropTree(xpath.str()) != nullptr)
-                return true;
-        }
-        return false;
-    }
-
     bool espProcessMatch(const char* espProcess)
     {
         if (!espProcess)
@@ -486,14 +428,12 @@ private:
             //If esp's original config has one configured for this binding, use it
             VStringBuffer xpath("EspBinding[@name='%s']", bindingName);
             IPropertyTree* bindingtree = procpt->queryPropTree(xpath.str());
-            if (bindingtree)
+            if (!bindingtree)
             {
-                bindingtree->getProp("@protocol", protocol);
-                return LINK(procpt);
+                //Otherwise check if there's binding configured on the same port
+                xpath.setf("EspBinding[@type='EsdlBinding'][@port=%s][1]", port);
+                bindingtree = procpt->queryPropTree(xpath.str());
             }
-            //Otherwise check if there's binding configured on the same port
-            xpath.setf("EspBinding[@type='EsdlBinding'][@port=%s][1]", port);
-            bindingtree = procpt->queryPropTree(xpath.str());
             if (!bindingtree)
             {
                 //Otherwise check if there's binding configured with port 0