details:   https://code.openbravo.com/erp/devel/pi/rev/4ce12b4d9e1f
changeset: 28564:4ce12b4d9e1f
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Feb 01 15:40:17 2016 +0100
summary:   Fixes issue 32074: The import entry manager can be shut down and 
restarted

There were two problems:
- The isShutdown attribute was not being set to false after restarting the 
ImportEntryManager
- The ImportEntryManger was not being stopped properly, there were processes 
that kept being run after shutting it down, specially when shutting the 
ImportEntryManager down just after having started it, but before the 
initialWaitTime, that is when the manager actually starts working.

diffstat:

 src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java |  6 
+++++-
 src/org/openbravo/service/importprocess/ImportEntryManager.java        |  8 
++++++++
 src/org/openbravo/service/importprocess/ImportEntryProcessor.java      |  6 
++++++
 3 files changed, 19 insertions(+), 1 deletions(-)

diffs (78 lines):

diff -r d37debbe555d -r 4ce12b4d9e1f 
src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java    
Sun Jan 31 12:59:02 2016 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java    
Mon Feb 01 15:40:17 2016 +0100
@@ -104,7 +104,6 @@
 
     @Override
     public void run() {
-
       Thread.currentThread().setName("Import Entry Archiver");
 
       // don't start right away at startup, give the system time to
@@ -116,6 +115,11 @@
       }
       log.debug("Run loop started");
 
+      if (manager.isShutDown) {
+        // don't even start, the import entry manager has been shut down
+        return;
+      }
+
       // make ourselves an admin
       OBContext.setOBContext("0", "0", "0", "0");
       Date lastCreated = null;
diff -r d37debbe555d -r 4ce12b4d9e1f 
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java   Sun Jan 
31 12:59:02 2016 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java   Mon Feb 
01 15:40:17 2016 +0100
@@ -161,6 +161,10 @@
 
   private boolean isShutDown = false;
 
+  public boolean isShutDown() {
+    return isShutDown;
+  }
+
   public ImportEntryManager() {
     instance = this;
     importBatchSize = ImportProcessUtils.getCheckIntProperty(log, 
"import.batch.size",
@@ -195,6 +199,7 @@
     managerThread = new ImportEntryManagerThread(this);
     executorService.submit(managerThread);
     importEntryArchiveManager.start();
+    isShutDown = false;
   }
 
   public long getNumberOfQueuedTasks() {
@@ -502,6 +507,9 @@
         Thread.sleep(manager.initialWaitTime);
       } catch (Exception ignored) {
       }
+      if (manager.isShutDown) {
+        return;
+      }
       log.debug("Run loop started");
       try {
         List<String> typesOfData = null;
diff -r d37debbe555d -r 4ce12b4d9e1f 
src/org/openbravo/service/importprocess/ImportEntryProcessor.java
--- a/src/org/openbravo/service/importprocess/ImportEntryProcessor.java Sun Jan 
31 12:59:02 2016 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryProcessor.java Mon Feb 
01 15:40:17 2016 +0100
@@ -286,6 +286,9 @@
       try {
         while (true) {
           try {
+            if (importEntryManager.isShutDown()) {
+              return;
+            }
             doRunCycle();
           } catch (Throwable logIt) {
             // prevent the loop from exiting, only log the exception
@@ -331,6 +334,9 @@
       QueuedEntry queuedImportEntry;
       while ((queuedImportEntry = importEntries.poll()) != null) {
         try {
+          if (importEntryManager.isShutDown()) {
+            return;
+          }
           final long t0 = System.currentTimeMillis();
 
           // set the same obcontext as was being used for the original

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to