瀏覽代碼

Merge pull request #15955 from jakesmith/HPCC-27440-use-same-tempdir-baremetal

HPCC-27440 Revert to common tempdir in baremetal (per thor instance)

Reviewed-By: Gavin Halliday <gavin.halliday@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 3 年之前
父節點
當前提交
e2d10d9654
共有 4 個文件被更改,包括 36 次插入18 次删除
  1. 7 1
      thorlcr/graph/thgraphmaster.cpp
  2. 7 1
      thorlcr/graph/thgraphslave.cpp
  3. 21 15
      thorlcr/thorutil/thormisc.cpp
  4. 1 1
      thorlcr/thorutil/thormisc.hpp

+ 7 - 1
thorlcr/graph/thgraphmaster.cpp

@@ -1485,10 +1485,16 @@ CJobMaster::CJobMaster(IConstWorkUnit &_workunit, const char *graphName, ILoaded
     xgmml.set(graphXGMML);
     xgmml.set(graphXGMML);
 
 
     StringBuffer tempDir(globals->queryProp("@thorTempDirectory"));
     StringBuffer tempDir(globals->queryProp("@thorTempDirectory"));
+#ifdef _CONTAINERIZED
     // multiple thor jobs can be running on same node, sharing same local disk for temp storage.
     // multiple thor jobs can be running on same node, sharing same local disk for temp storage.
     // make unique by adding wuid+graphName+worker-num
     // make unique by adding wuid+graphName+worker-num
     VStringBuffer uniqueSubDir("%s_%s_0", workunit->queryWuid(), graphName); // 0 denotes master (workers = 1..N)
     VStringBuffer uniqueSubDir("%s_%s_0", workunit->queryWuid(), graphName); // 0 denotes master (workers = 1..N)
-    SetTempDir(tempDir, uniqueSubDir, "thtmp");
+    SetTempDir(tempDir, uniqueSubDir, "thtmp", false); // no point in clearing as dir. is unique per job+graph
+#else
+    // in bare-metal where only 1 Thor instance of each name, re-use same dir, in order to guarantee it will be cleared on startup
+    VStringBuffer uniqueSubDir("%s_0", globals->queryProp("@name")); // 0 denotes master (workers = 1..N)
+    SetTempDir(tempDir, uniqueSubDir, "thtmp", true);
+#endif
 }
 }
 
 
 void CJobMaster::endJob()
 void CJobMaster::endJob()

+ 7 - 1
thorlcr/graph/thgraphslave.cpp

@@ -1713,8 +1713,14 @@ CJobSlave::CJobSlave(ISlaveWatchdog *_watchdog, IPropertyTree *_workUnitInfo, co
     StringBuffer tempDir(globals->queryProp("@thorTempDirectory"));
     StringBuffer tempDir(globals->queryProp("@thorTempDirectory"));
     // multiple thor jobs can be running on same node, sharing same local disk for temp storage.
     // multiple thor jobs can be running on same node, sharing same local disk for temp storage.
     // make unique by adding wuid+graphName+worker-num
     // make unique by adding wuid+graphName+worker-num
+#ifdef _CONTAINERIZED
     VStringBuffer uniqueSubDir("%s_%s_%u", wuid.str(), graphName, globals->getPropInt("@slavenum"));
     VStringBuffer uniqueSubDir("%s_%s_%u", wuid.str(), graphName, globals->getPropInt("@slavenum"));
-    SetTempDir(tempDir, uniqueSubDir, "thtmp");
+    SetTempDir(tempDir, uniqueSubDir, "thtmp", false); // no point in clearing as dir. is unique per job+graph
+#else
+    // in bare-metal where only 1 Thor instance of each name, re-use same dir, in order to guarantee it will be cleared on startup
+    VStringBuffer uniqueSubDir("%s_%u", globals->queryProp("@name"), globals->getPropInt("@slavenum"));
+    SetTempDir(tempDir, uniqueSubDir, "thtmp", true);
+#endif
 }
 }
 
 
 CJobChannel *CJobSlave::addChannel(IMPServer *mpServer)
 CJobChannel *CJobSlave::addChannel(IMPServer *mpServer)

+ 21 - 15
thorlcr/thorutil/thormisc.cpp

@@ -636,19 +636,7 @@ public:
     { 
     { 
         return subDirPath; 
         return subDirPath; 
     }
     }
-    void setTempDir(const char *_rootDir, const char *_subDirName, const char *_prefix)
-    {
-        assertex(!isEmptyString(_rootDir) && !isEmptyString(_prefix) && !isEmptyString(_subDirName));
-        CriticalBlock block(crit);
-        assertex(subDirPath.isEmpty());
-        rootDir.set(_rootDir);
-        addPathSepChar(rootDir);
-        subDirName.set(_subDirName);
-        prefix.set(_prefix);
-        subDirPath.setf("%s%s", rootDir.str(), subDirName.str());
-        recursiveCreateDirectory(subDirPath);
-    }
-    void clear(bool log)
+    void clearTempDirectory(bool log)
     {
     {
         assertex(subDirPath.length());
         assertex(subDirPath.length());
         Owned<IDirectoryIterator> iter = createDirectoryIterator(subDirPath);
         Owned<IDirectoryIterator> iter = createDirectoryIterator(subDirPath);
@@ -668,6 +656,24 @@ public:
                 }
                 }
             }
             }
         }
         }
+    }
+    void setTempDir(const char *_rootDir, const char *_subDirName, const char *_prefix, bool clearDir)
+    {
+        assertex(!isEmptyString(_rootDir) && !isEmptyString(_prefix) && !isEmptyString(_subDirName));
+        CriticalBlock block(crit);
+        assertex(subDirPath.isEmpty());
+        rootDir.set(_rootDir);
+        addPathSepChar(rootDir);
+        subDirName.set(_subDirName);
+        prefix.set(_prefix);
+        subDirPath.setf("%s%s", rootDir.str(), subDirName.str());
+        recursiveCreateDirectory(subDirPath);
+        if (clearDir)
+            clearTempDirectory(true);
+    }
+    void clear(bool log)
+    {
+        clearTempDirectory(log);
         try
         try
         {
         {
             Owned<IFile> dirIFile = createIFile(subDirPath);
             Owned<IFile> dirIFile = createIFile(subDirPath);
@@ -714,9 +720,9 @@ void GetTempFilePath(StringBuffer &name, const char *suffix)
     TempNameHandler.getTempName(name, suffix, true);
     TempNameHandler.getTempName(name, suffix, true);
 }
 }
 
 
-void SetTempDir(const char *rootTempDir, const char *uniqueSubDir, const char *tempPrefix)
+void SetTempDir(const char *rootTempDir, const char *uniqueSubDir, const char *tempPrefix, bool clearDir)
 {
 {
-    TempNameHandler.setTempDir(rootTempDir, uniqueSubDir, tempPrefix);
+    TempNameHandler.setTempDir(rootTempDir, uniqueSubDir, tempPrefix, clearDir);
     LOG(MCdebugProgress, thorJob, "temporary rootTempdir: %s, uniqueSubDir: %s, prefix: %s", rootTempDir, uniqueSubDir, tempPrefix);
     LOG(MCdebugProgress, thorJob, "temporary rootTempdir: %s, uniqueSubDir: %s, prefix: %s", rootTempDir, uniqueSubDir, tempPrefix);
 }
 }
 
 

+ 1 - 1
thorlcr/thorutil/thormisc.hpp

@@ -507,7 +507,7 @@ extern graph_decl void setExceptionActivityInfo(CGraphElementBase &container, IT
 
 
 extern graph_decl void GetTempFilePath(StringBuffer &name, const char *suffix);
 extern graph_decl void GetTempFilePath(StringBuffer &name, const char *suffix);
 extern graph_decl void GetTempFileName(StringBuffer &name, const char *suffix);
 extern graph_decl void GetTempFileName(StringBuffer &name, const char *suffix);
-extern graph_decl void SetTempDir(const char *rootTempDir, const char *uniqueSubDir, const char *tempPrefix);
+extern graph_decl void SetTempDir(const char *rootTempDir, const char *uniqueSubDir, const char *tempPrefix, bool clearDir);
 extern graph_decl void ClearTempDir();
 extern graph_decl void ClearTempDir();
 extern graph_decl const char *queryTempDir();
 extern graph_decl const char *queryTempDir();
 extern graph_decl void loadCmdProp(IPropertyTree *tree, const char *cmdProp);
 extern graph_decl void loadCmdProp(IPropertyTree *tree, const char *cmdProp);