From b6405e0bc1728b5754f27ad58cbc17b4e73c3bf0 Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Tue, 12 Apr 2016 21:36:19 +0000
Subject: [PATCH] monitoring fixes from trunk

---
 src/python/dm/common/processing/fileProcessingThread.py     | 3 +++
 .../dm/daq_web_service/service/impl/fileSystemObserver.py   | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/python/dm/common/processing/fileProcessingThread.py b/src/python/dm/common/processing/fileProcessingThread.py
index f535b56f..0e9b8a25 100755
--- a/src/python/dm/common/processing/fileProcessingThread.py
+++ b/src/python/dm/common/processing/fileProcessingThread.py
@@ -36,6 +36,7 @@ class FileProcessingThread(threading.Thread):
                 self.logger.debug('File %s processing is cancelled' % (filePath))
                 endProcessingTime = time.time() 
                 statusMonitor.fileProcessingCancelled(filePath, endProcessingTime) 
+                statusMonitor.updateStatus()
                 return 
             self.logger.debug('Starting to process file %s' % filePath)
             startProcessingTime = fileInfo.get('startProcessingTime', time.time())
@@ -67,6 +68,7 @@ class FileProcessingThread(threading.Thread):
                         endProcessingTime = time.time() 
                         if statusMonitor:
                             statusMonitor.fileProcessed(filePath, endProcessingTime) 
+                            statusMonitor.updateStatus()
                 except Exception, ex:
                     self.logger.exception(ex)
                     processingError = '%s processing error: %s' % (processorName, str(ex))
@@ -84,6 +86,7 @@ class FileProcessingThread(threading.Thread):
                         endProcessingTime = time.time() 
                         if statusMonitor:
                             statusMonitor.fileProcessingError(filePath, processingError, endProcessingTime) 
+                            statusMonitor.updateStatus()
                         self.logger.debug('No more %s retries left for file %s, remaining plugins will not process it' % (processorName, filePath))
                         return 
                     else:
diff --git a/src/python/dm/daq_web_service/service/impl/fileSystemObserver.py b/src/python/dm/daq_web_service/service/impl/fileSystemObserver.py
index b3900e5a..74ef566b 100755
--- a/src/python/dm/daq_web_service/service/impl/fileSystemObserver.py
+++ b/src/python/dm/daq_web_service/service/impl/fileSystemObserver.py
@@ -108,9 +108,11 @@ class FileSystemObserver(threading.Thread,Singleton):
             observedFile = ObservedFile(filePath=filePath, dataDirectory=dataDirectory, experiment=experiment)
             observedFile['daqInfo'] = daqInfo.toDictWithOriginalKeys()
             observedFile['statusMonitor'] = daqInfo
+            self.observedFileMap[filePath] = observedFile
+            self.logger.debug('New observed file: %s', filePath)
+        else:
+            self.logger.debug('Observed file updated: %s', filePath)
         observedFile.setLastUpdateTimeToNow()
-        self.observedFileMap[filePath] = observedFile
-        self.logger.debug('Observed file updated: %s', filePath)
        
     @ThreadingUtility.synchronize
     def checkObservedFilesForProcessing(self):
-- 
GitLab