Prechádzať zdrojové kódy

Merge pull request #15684 from jakesmith/HPCC-27014-allow-reverse-group-lookup

HPCC-27014 If descriptor cluster name not known, allow reverse lookup

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Merged-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 3 rokov pred
rodič
commit
0a426d1d50
1 zmenil súbory, kde vykonal 34 pridanie a 8 odobranie
  1. 34 8
      dali/base/dadfs.cpp

+ 34 - 8
dali/base/dadfs.cpp

@@ -3690,10 +3690,36 @@ public:
     {
         clusters.clear();
         unsigned nc = fdesc->numClusters();
-        if (nc) {
-            for (unsigned i=0;i<nc;i++) {
-                IClusterInfo &cluster = OLINK(*fdesc->queryClusterNum(i));
-                clusters.append(cluster);
+        if (nc)
+        {
+            for (unsigned i=0;i<nc;i++)
+            {
+                StringBuffer cname;
+                fdesc->getClusterGroupName(i, cname, nullptr);
+                IClusterInfo *cluster;
+                if (cname.length())
+                    cluster = LINK(fdesc->queryClusterNum(i));
+                else
+                {
+                    // NB: this is non-standard, for situations where the cluster name is not known,
+                    // which happens where none has been provided/set to the file descriptor,
+                    // and the file descriptor has been built up of parts with ips. 
+                    // createClusterInfo will perform a reverse lookup to Dali to try to discover
+                    // a group name.
+                    cluster = createClusterInfo(
+                                  nullptr,
+                                  fdesc->queryClusterGroup(i),
+                                  fdesc->queryPartDiskMapping(i),
+                                  &queryNamedGroupStore()
+                               );
+
+                    if (!cluster->queryGroup(&queryNamedGroupStore()))
+                        IERRLOG("IDistributedFileDescriptor cannot set cluster for %s", logicalName.get());
+                }
+#ifdef EXTRA_LOGGING
+                PROGLOG("setClusters(%d,%s)", i, cluster->queryGroupName());
+#endif
+                clusters.append(*cluster);
             }
         }
         else
@@ -4103,6 +4129,10 @@ public:
             setClusters(fdesc);
             setParts(fdesc,false);
             setUserDescriptor(udesc, user);
+#ifdef EXTRA_LOGGING
+            LOGFDESC("CDistributedFile::attach fdesc",fdesc);
+            LOGPTREE("CDistributedFile::attach root.2",root);
+#endif
         }
         catch (IException *e)
         {
@@ -4110,10 +4140,6 @@ public:
             logicalName.clear();
             throw;
         }
-#ifdef EXTRA_LOGGING
-        LOGFDESC("CDistributedFile::attach fdesc",fdesc);
-        LOGPTREE("CDistributedFile::attach root.2",root);
-#endif
     }
 
     /*