Fixed issue 31370: Added log to importentry processor
authorGuillermo Alvarez de Eulate <guillermo.alvarez@openbravo.com>
Thu, 05 Nov 2015 11:55:31 +0100
changeset 28100 c6bfc013b9d1
parent 28099 14753c185bd5
child 28101 239c6606f978
Fixed issue 31370: Added log to importentry processor
src/org/openbravo/service/importprocess/ImportEntryManager.java
src/org/openbravo/service/importprocess/ImportEntryProcessor.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Nov 05 11:43:28 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Nov 05 11:55:31 2015 +0100
@@ -512,6 +512,9 @@
               // don't block eachother with the limited batch size
               // being read
               for (String typeOfData : typesOfData) {
+
+                log.debug("Reading import entries for type of data " + typeOfData);
+
                 final String importEntryQryStr = "from " + ImportEntry.ENTITY_NAME + " where "
                     + ImportEntry.PROPERTY_TYPEOFDATA + "='" + typeOfData + "' and "
                     + ImportEntry.PROPERTY_IMPORTSTATUS + "='Initial' order by "
@@ -528,11 +531,18 @@
                   while (entries.next()) {
                     entryCount++;
                     final ImportEntry entry = (ImportEntry) entries.get(0);
+
+                    if (log.isDebugEnabled()) {
+                      log.debug("Handle import entry " + entry.getIdentifier());
+                    }
+
                     try {
                       manager.handleImportEntry(entry);
                       // remove it from the internal cache to keep it small
                       OBDal.getInstance().getSession().evict(entry);
                     } catch (Throwable t) {
+                      ImportProcessUtils.logError(log, t);
+
                       // ImportEntryProcessors are custom implementations which can cause
                       // errors, so always catch them to prevent other import entries
                       // from not getting processed
@@ -555,9 +565,9 @@
               // give the threads time to process it all before trying
               // a next batch of entries
               try {
-                // wait one second per 50 records, somewhat arbitrary
+                // wait one second per 30 records, somewhat arbitrary
                 // but high enough for most cases
-                Thread.sleep(1000 * (entryCount / 50));
+                Thread.sleep(Math.max(2000, 1000 * (entryCount / 30)));
               } catch (Exception ignored) {
               }
             } else {
--- a/src/org/openbravo/service/importprocess/ImportEntryProcessor.java	Thu Nov 05 11:43:28 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryProcessor.java	Thu Nov 05 11:55:31 2015 +0100
@@ -303,8 +303,19 @@
 
               // not changed, process
               final String typeOfData = localImportEntry.getTypeofdata();
+
+              if (logger.isDebugEnabled()) {
+                logger.debug("Processing entry " + localImportEntry.getIdentifier() + " "
+                    + typeOfData);
+              }
+
               processEntry(localImportEntry);
 
+              if (logger.isDebugEnabled()) {
+                logger.debug("Finished Processing entry " + localImportEntry.getIdentifier() + " "
+                    + typeOfData);
+              }
+
               // don't use the import entry anymore, touching methods on it
               // may re-open a session
               localImportEntry = null;
@@ -341,6 +352,8 @@
               }
 
             } catch (Throwable t) {
+              ImportProcessUtils.logError(logger, t);
+
               // bit rough but ensures that the connection is released/closed
               try {
                 OBDal.getInstance().rollbackAndClose();
@@ -382,6 +395,8 @@
           } catch (Exception ignored) {
           }
 
+          logger.debug("Trying to deregister process " + key);
+
           // no more entries and deregistered
           if (importEntryProcessor.deregisterProcessThread(this)) {
             importEntryIds.clear();