This reads the DS configs from the standard location /home/deltasvr/cluster.xml, which if it exists, is presumed to be owned by root.

Return TypeFunction nameArguments
hzEcodeReadConfigDS(void)

Declared and defined in file: hdbADP.cpp

Function Logic:

0:START 1:unknown 2:Return hzerr(E_NOTFOUND,Delta config file %s not found\n,*s_deltaConf) 3:rc 4:unknown 5:Return hzerr(rc,Config (%s): Could not load\n,*s_deltaConf) 6:pRoot 7:unknown 8:Return hzerr(rc,Config (%s): Expected root tag. Got <%s>\n,*s_deltaConf,pRoot->txtName()) 9:pNC 10:unknown 11:Return hzerr(rc,Config (%s): Expected tag as 1st child of \n,*s_deltaConf) 12:unknown 13:unknown 14:nIndex 15:pNS->NameEQ(pointB) 16:nIndex 17:pNS->NameEQ(pointC) 18:nIndex 19:pNS->NameEQ(pointD) 20:nIndex 21:Return hzerr(E_CONFIG,Illegal tag <%s> in . Only allowed\n,pNS->txtName()) 22:unknown 23:Return hzerr(E_DUPLICATE,Duplicate tag <%s> in \n,pNS->txtName()) 24:unknown 25:unknown 26:s_DS_Hosts 27:ai.NameEQ(addr) 28:unknown 29:ipa 30:unknown 31:Return hzerr(E_CONFIG,Line %d: Invalid IP address (%s)\n,pNS->Line(),ai.Value()) 32:s_DS_Addrs 33:ai.NameEQ(port) 34:unknown 35:nPort 36:unknown 37:Return hzerr(E_CONFIG,Line %d: Invalid port (%s)\n,pNS->Line(),ai.Value()) 38:s_DS_Ports 39:Return hzerr(E_CONFIG,Line %d: Illegal attribute %s. Only host|addr|port allowed,pNS->Line(),ai.Name()) 40:unknown 41:Return hzerr(E_CONFIG,No hostname specified for server %s,pNS->txtName()) 42:unknown 43:unknown 44:Return hzerr(E_CONFIG,Line %d: Invalid IP address (port is %u)\n,pNS->Line(),s_DS_Ports[nIndex]) 45:unknown 46:Return hzerr(E_CONFIG,Line %d: IP address supplied but no port\n,pNS->Line()) 47:unknown 48:s_deltaPort 49:unknown 50:unknown 51:unknown 52:rc items 53:unknown 54:unknown 55:appName 56:ai.NameEQ(appid) 57:unknown 58:nAppId 59:unknown 60:rc items 61:rc items 62:unknown 63:rc items 64:unknown 65:rc items 66:unknown 67:unknown 68:rc items 69:unknown 70:rc items 71:unknown 72:items 73:Return rc

Function body:

hzEcode ReadConfigDS (void)
{
   //  This reads the DS configs from the standard location /home/deltasvr/cluster.xml, which if it exists, is presumed to be owned by root.
   _hzfunc(__func__) ;
   FSTAT       fs ;        //  File status
   hzDocXml    X ;         //  XML document
   hzChain     err ;       //  Error report
   hzAttrset   ai ;        //  Attribute iterator
   hzXmlNode*  pRoot ;     //  Root XML tag
   hzXmlNode*  pN ;        //  XML node/tag
   hzXmlNode*  pNC ;       //  XML node for <deltaCluster> tag
   hzXmlNode*  pNS ;       //  XML node for <point[A-D]> tags
   hzString    appName ;   //  Application name
   hzIpaddr    ipa ;       //  IP address
   uint32_t    nAppId ;    //  App id
   uint32_t    nPort ;     //  Port number
   uint32_t    nIndex ;    //  Server iterator
   hzEcode     rc ;        //  Return code
   /*
   **  ** Read the DS config to obtain delta cluster info and to find the appID as used by the DS
   **      */
   if (lstat(s_deltaConf, &fs) < 0)
       return hzerr(E_NOTFOUND, "Delta config file %s not found\n", *s_deltaConf) ;
   rc = X.Load(s_deltaConf) ;
   if (rc != E_OK)
       return hzerr(rc, "Config (%s): Could not load\n", *s_deltaConf) ;
   pRoot = X.GetRoot() ;
   if (!pRoot->NameEQ("ConfigDS"))
       return hzerr(rc, "Config (%s): Expected <ConfigDS> root tag. Got <%s>\n", *s_deltaConf, pRoot->txtName()) ;
   //  Process <deltaCluster> tag
   pNC = pRoot->GetFirstChild() ;
   if (!pNC || !pNC->NameEQ("deltaCluster"))
       return hzerr(rc, "Config (%s): Expected <deltaCluster> tag as 1st child of <ConfigDS>\n", *s_deltaConf) ;
   //  Expect <deltaCluster> subtags to describe servers
   for (pNS = pNC->GetFirstChild() ; pNS ; pNS = pNS->Sibling())
   {
       if      (pNS->NameEQ("pointA")) nIndex = 0;
       else if (pNS->NameEQ("pointB")) nIndex = 1;
       else if (pNS->NameEQ("pointC")) nIndex = 2;
       else if (pNS->NameEQ("pointD")) nIndex = 3;
       else
           return hzerr(E_CONFIG, "Illegal tag <%s> in <deltaCluster>. Only <point[A-D]> allowed\n", pNS->txtName()) ;
       if (s_DS_Hosts[nIndex])
           return hzerr(E_DUPLICATE, "Duplicate tag <%s> in <deltaCluster>\n", pNS->txtName()) ;
       for (ai = pNS ; ai.Valid() ; ai.Advance())
       {
           if (ai.NameEQ("host"))
               s_DS_Hosts[nIndex] = ai.Value() ;
           else if (ai.NameEQ("addr"))
           {
               if (ai.Value())
               {
                   ipa = ai.Value() ;
                   if (ipa == _hzGlobal_nullIP)
                       return hzerr(E_CONFIG, "Line %d: Invalid IP address (%s)\n", pNS->Line(), ai.Value()) ;
                   s_DS_Addrs[nIndex] = ipa ;
               }
           }
           else if (ai.NameEQ("port"))
           {
               if (ai.Value())
               {
                   nPort = atoi(ai.Value()) ;
                   if (!nPort)
                       return hzerr(E_CONFIG, "Line %d: Invalid port (%s)\n", pNS->Line(), ai.Value()) ;
                   s_DS_Ports[nIndex] = nPort ;
               }
           }
           else
               return hzerr(E_CONFIG, "Line %d: Illegal attribute %s. Only host|addr|port allowed", pNS->Line(), ai.Name()) ;
       }
       //  Check we have everything
       if (!s_DS_Hosts[nIndex])
           return hzerr(E_CONFIG, "No hostname specified for server %s", pNS->txtName()) ;
       if (s_DS_Addrs[nIndex] || s_DS_Ports[nIndex])
       {
           //  Both must be either NULL or set
           if (s_DS_Addrs[nIndex] == _hzGlobal_nullIP)
               return hzerr(E_CONFIG, "Line %d: Invalid IP address (port is %u)\n", pNS->Line(), s_DS_Ports[nIndex]) ;
           if (!s_DS_Ports[nIndex])
               return hzerr(E_CONFIG, "Line %d: IP address supplied but no port\n", pNS->Line()) ;
           //  Get port for notifications
           if (ipa == _hzGlobal_livehost)
               s_deltaPort = nPort ;
       }
   }
   //  Process <deltaCluster> siblings. Expect <dsApp> and <dsRealm> tags. Only process <dsApp>
   for (pN = pNC->Sibling() ; rc == E_OK && pN ; pN = pN->Sibling())
   {
       //  Only interested in <deltaCluster> here
       if (!pN->NameEQ("dsRealm"))
           continue ;
       if (!pN->NameEQ("dsApp"))
           { rc = E_CONFIG ; err.Printf("Illegal tag <%s> in <ConfigDS>. Only <dsRealm> and <dsApp> allowed\n", pN->txtName()) ; }
       //  Process DS attributes
       for (ai = pN ; ai.Valid() ; ai.Advance())
       {
           if (ai.NameEQ("appname"))
               appName = ai.Value() ;
           else if (ai.NameEQ("appid"))
           {
               if (ai.Value())
               {
                   nAppId = atoi(ai.Value()) ;
                   if (!nAppId)
                       { rc = E_CONFIG ; err.Printf("Line %d: Invalid app id (%s)\n", pNS->Line(), ai.Value()) ; }
               }
           }
           else
               { rc = E_CONFIG ; err.Printf("Line %d: Illegal <dsApp> attribute %s. Only host|addr|port allowed", pN->Line(), ai.Name()) ; }
       }
       if (!appName)   { rc = E_CONFIG ; err.Printf("Line %d: <dsApp> tag does not specify an appName\n", pN->Line()) ; }
       if (!nAppId)    { rc = E_CONFIG ; err.Printf("Line %d: <dsApp> tag does not specify an app ID\n", pN->Line()) ; }
       if (rc == E_OK)
       {
           if (s_mapDS_AppsByName.Exists(appName)) { rc = E_DUPLICATE ; err.Printf("Line %d: App (%s) already exists\n", pN->Line(), *appName) ; }
           if (s_mapDS_AppsByID.Exists(nAppId))    { rc = E_DUPLICATE ; err.Printf("Line %d: App ID (%u) already exists\n", pN->Line(), nAppId) ; }
       }
   }
   if (err.Size())
       threadLog(err) ;
   return rc ;
}