Project

General

Profile

Actions

Bug #2500

closed

too much ldap tree computing before commiting/ too much logging

Added by Vincent MEMBRÉ over 12 years ago. Updated almost 10 years ago.

Status:
Released
Priority:
2
Category:
Web - Nodes & inventories
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
Name check:
Fix check:
Regression:

Description

when commiting a new report, we make a log before commit, and after commiting, in each of them we process the ldap tree correspondig to the report

So ldap tree must be computed 3 times (one before commit, one to commit and one after)

but is appeared that ldap tree is computed 5 times ! especially 3 times before commit

we are using a reference. If we use a value instead we should resolve that

Plus we create a debug log even if we don't want to log it. we should add a property in logback.xml to fix that


Files

logback.xml (3.04 KB) logback.xml Vincent MEMBRÉ, 2012-05-25 16:36
Actions #1

Updated by Vincent MEMBRÉ over 12 years ago

  • File logback.xml logback.xml added
  • Subject changed from too much ldap tree computing before commiting to too much ldap tree computing before commiting/ too much logging
  • Description updated (diff)
  • Status changed from New to Discussion
 diff --git a/inventory-provisioning-core/src/main/scala/com/normation/inventory/ldap/provisioning/LdifReportLogger.scala b/inventory-provisioning-core/src/main/scala/com/normation/inventory/ldap/provisioning/Ldi
index 7b842e4..c3a1771 100644
--- a/inventory-provisioning-core/src/main/scala/com/normation/inventory/ldap/provisioning/LdifReportLogger.scala
+++ b/inventory-provisioning-core/src/main/scala/com/normation/inventory/ldap/provisioning/LdifReportLogger.scala
@@ -67,7 +67,7 @@ trait LDIFReportLogger {

 object DefaultLDIFReportLogger {
   import org.slf4j.LoggerFactory
-  val logger = LoggerFactory.getLogger(classOf[DefaultLDIFReportLogger])
+  val logger = LoggerFactory.getLogger("trace.ldifreport.in.file")
   val defaultLogDir = System.getProperty("java.io.tmpdir") + 
     System.getProperty("file.separator") + "LDIFLogReport" 
 }
@@ -103,19 +103,21 @@ class DefaultLDIFReportLogger(val LDIFLogDir:String = DefaultLDIFReportLogger.de
       var writer:LDIFWriter = null
       val LDIFFile = fileFromName(reportName,tag)
       try {
-        logger.debug("LDIF log for report processing: " + LDIFFile.getAbsolutePath)
-        writer = new LDIFWriter(LDIFFile)
-        
-        
-        if(LDIFRecords.nonEmpty) { //don't check it if logger trace is not enabled
-          writer.writeLDIFRecord(LDIFRecords.head, comments.getOrElse(null))
-          LDIFRecords.tail.foreach { LDIFRecord => writer.writeLDIFRecord(LDIFRecord) }
-        } else {
-          //write a dummy recored
-          val c = comments.getOrElse("") + "(There was no record to log, a dummy modification is added in log as a placeholder)" 
-          writer.writeLDIFRecord(new LDIFModifyChangeRecord("cn=dummy", new Modification(REPLACE,"dummy", "dummy")), c)          
-        }
-        
+
+        if (logger.isTraceEnabled()){
+          logger.debug("LDIF log for report processing: " + LDIFFile.getAbsolutePath)
+          writer = new LDIFWriter(LDIFFile)
+
+          val ldif = LDIFRecords
+          if(ldif.nonEmpty) { //don't check it if logger trace is not enabled
+            writer.writeLDIFRecord(ldif.head, comments.getOrElse(null))
+            ldif.tail.foreach { LDIFRecord => writer.writeLDIFRecord(LDIFRecord) }
+          } else {
+            //write a dummy recored
+            val c = comments.getOrElse("") + "(There was no record to log, a dummy modification is added in log as a placeholder)" 
+            writer.writeLDIFRecord(new LDIFModifyChangeRecord("cn=dummy", new Modification(REPLACE,"dummy", "dummy")), c)
+          }
+      }

       } catch {
         case e:Exception => logger.error("Exception when loggin (ignored)",e)

I also add a property into logback.xml but it's ignored by git.

  <logger name="trace.ldifreport.in.file" level="off" />

i link that file

Actions #2

Updated by François ARMAND over 12 years ago

  • Status changed from Discussion to In progress
  • Target version changed from 2.3.8 to 2.4.0~beta1

Make it go to 2.4. Could be backported when we are sure that the behaviour is OK (it seems).

Actions #3

Updated by François ARMAND over 12 years ago

  • Priority changed from N/A to 2
Actions #4

Updated by François ARMAND over 12 years ago

  • Status changed from In progress to Pending technical review
  • % Done changed from 0 to 100
Actions #5

Updated by Nicolas CHARLES over 12 years ago

  • Status changed from Pending technical review to Released

This looks valid, thank you both Francois and Vincent

Actions #6

Updated by Benoît PECCATTE almost 10 years ago

  • Category changed from 26 to Web - Nodes & inventories
Actions

Also available in: Atom PDF