logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1487685 - in /logging/log4j/log4j2/trunk: flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java src/changes/changes.xml
Date Wed, 29 May 2013 23:58:50 GMT
Author: rgoers
Date: Wed May 29 23:58:50 2013
New Revision: 1487685

URL: http://svn.apache.org/r1487685
Log:
LOG4J2-269 - Use transaction when batch size is 1

Modified:
    logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java?rev=1487685&r1=1487684&r2=1487685&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
(original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
Wed May 29 23:58:50 2013
@@ -424,7 +424,8 @@ public class FlumePersistentManager exte
                                 }
                             }
                         } else {
-                            Cursor cursor = database.openCursor(null, null);
+                            Transaction txn = environment.beginTransaction(null, null);
+                            Cursor cursor = database.openCursor(txn, null);
                             try {
                                 status = cursor.getFirst(key, data, LockMode.RMW);
                                 while (status == OperationStatus.SUCCESS) {
@@ -447,14 +448,23 @@ public class FlumePersistentManager exte
                                     }
                                     status = cursor.getNext(key, data, LockMode.RMW);
                                 }
+                                if (cursor != null) {
+                                    cursor.close();
+                                    cursor = null;
+                                }
+                                txn.commit();
+                                txn = null;
                             } catch (Exception ex) {
-                                LOGGER.error("Error reading database", ex);
+                                LOGGER.error("Error reading or writing to database", ex);
                                 shutdown = true;
                                 break;
                             } finally {
                                 if (cursor != null) {
                                     cursor.close();
                                 }
+                                if (txn != null) {
+                                    txn.abort();
+                                }
                             }
                         }
                         if (errors) {

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1487685&r1=1487684&r2=1487685&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Wed May 29 23:58:50 2013
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-beta7" date="2013-??-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-269" dev="rgoers" type="fix">
+        Use transaction when batch size is 1.
+      </action>
       <action issue="LOG4J2-268" dev="rgoers" type="fix">
         Add guid to FlumeEvent headers for non-Map Messages.
       </action>



Mime
View raw message