Bug #2500
closedtoo much ldap tree computing before commiting/ too much logging
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
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
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).
Updated by François ARMAND over 12 years ago
- Status changed from In progress to Pending technical review
- % Done changed from 0 to 100
Applied in changeset 80748e00928f6265aa72d9880a89aef538c84b3e.
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
Updated by Benoît PECCATTE over 9 years ago
- Category changed from 26 to Web - Nodes & inventories