Selaa lähdekoodia

HPCC-22851 Add wutool option to add issues found by analyzer to workunit

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Shamser Ahmed 5 vuotta sitten
vanhempi
commit
23b999777f

+ 13 - 5
common/workunit/workunit.cpp

@@ -4043,8 +4043,8 @@ public:
             { return c->getAbortTimeStamp(); }
 
 
-    virtual void clearExceptions()
-            { c->clearExceptions(); }
+    virtual void clearExceptions(const char *source=nullptr)
+            { c->clearExceptions(source); }
     virtual void commit()
             { c->commit(); }
     virtual IWUException * createException()
@@ -8896,7 +8896,7 @@ unsigned CLocalWorkUnit::getExceptionCount() const
     return exceptions.length();
 }
 
-void CLocalWorkUnit::clearExceptions()
+void CLocalWorkUnit::clearExceptions(const char *source)
 {
     CriticalBlock block(crit);
     // For this to be legally called, we must have the write-able interface. So we are already locked for write.
@@ -8906,8 +8906,16 @@ void CLocalWorkUnit::clearExceptions()
         IWUException &e = exceptions.item(idx);
         SCMStringBuffer s;
         e.getExceptionSource(s);
-        if (strieq(s.s, "eclcc") || strieq(s.s, "eclccserver") || strieq(s.s, "eclserver") )
-            break;
+        if (source)
+        {
+            if (!strieq(s.s, source))
+                continue;
+        }
+        else
+        {
+            if (strieq(s.s, "eclcc") || strieq(s.s, "eclccserver") || strieq(s.s, "eclserver") )
+                break;
+        }
         VStringBuffer xpath("Exceptions/Exception[@sequence='%d']", e.getSequence());
         p->removeProp(xpath);
         exceptions.remove(idx);

+ 1 - 1
common/workunit/workunit.hpp

@@ -1293,7 +1293,7 @@ interface IDistributedFile;
 
 interface IWorkUnit : extends IConstWorkUnit
 {
-    virtual void clearExceptions() = 0;
+    virtual void clearExceptions(const char *source=nullptr) = 0;
     virtual void commit() = 0;
     virtual IWUException * createException() = 0;
     virtual void addProcess(const char *type, const char *instance, unsigned pid, const char *log=NULL) = 0;

+ 1 - 1
common/workunit/workunit.ipp

@@ -349,7 +349,7 @@ public:
     virtual IStringVal & getAbortBy(IStringVal & str) const;
     virtual unsigned __int64 getAbortTimeStamp() const;
 
-    void clearExceptions();
+    void clearExceptions(const char *source=nullptr);
     void commit();
     IWUException *createException();
     void addProcess(const char *type, const char *instance, unsigned pid, const char *log);

+ 7 - 1
common/wuanalysis/anawu.cpp

@@ -414,9 +414,15 @@ void WUANALYSIS_API analyseWorkunit(IWorkUnit * wu, WuAnalyseOptions & options)
     analyser.update(wu);
 }
 
-void WUANALYSIS_API analyseAndPrintIssues(IConstWorkUnit * wu, WuAnalyseOptions & options)
+void WUANALYSIS_API analyseAndPrintIssues(IConstWorkUnit * wu, WuAnalyseOptions & options, bool updatewu)
 {
     WorkunitAnalyser analyser(options);
     analyser.analyse(wu);
     analyser.print();
+    if (updatewu)
+    {
+        Owned<IWorkUnit> lockedwu = &(wu->lock());
+        lockedwu->clearExceptions("Workunit Analyser");
+        analyser.update(lockedwu);
+    }
 }

+ 1 - 1
common/wuanalysis/anawu.hpp

@@ -28,5 +28,5 @@ struct WuAnalyseOptions
 };
 
 void WUANALYSIS_API analyseWorkunit(IWorkUnit * wu, WuAnalyseOptions & options);
-void WUANALYSIS_API analyseAndPrintIssues(IConstWorkUnit * wu, WuAnalyseOptions & options);
+void WUANALYSIS_API analyseAndPrintIssues(IConstWorkUnit * wu, WuAnalyseOptions & options, bool updatewu);
 #endif

+ 2 - 2
plugins/cassandra/cassandrawu.cpp

@@ -2752,11 +2752,11 @@ public:
         CPersistedWorkUnit::_loadExceptions();
     }
 
-    virtual void clearExceptions()
+    virtual void clearExceptions(const char * source=nullptr)
     {
         CriticalBlock b(crit);
         noteDirty("*Exceptions/Exception", wuExceptionsMappings);
-        CPersistedWorkUnit::clearExceptions();
+        CPersistedWorkUnit::clearExceptions(source);
     }
 
     virtual IPropertyTree *getUnpackedTree(bool includeProgress) const

+ 1 - 1
tools/wutool/wutool.cpp

@@ -221,7 +221,7 @@ static void process(IConstWorkUnit &w, IProperties *globals, const StringArray &
     else if (stricmp(action, "analyze")==0)
     {
         WuAnalyseOptions options; // TODO: allow options to be set from from command line parameters
-        analyseAndPrintIssues(&w, options);
+        analyseAndPrintIssues(&w, options, globals->getPropBool("UPDATEWU"));
     }
     else if (stricmp(action, "dump")==0)
     {