You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2014/09/10 07:16:13 UTC

git commit: LOG4J2-391 - FlumePersistentManager now handles LockConflictExceptions in Berkeley Db when sending a batch

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 7d0935f42 -> be6f48a9b


LOG4J2-391 - FlumePersistentManager now handles LockConflictExceptions in Berkeley Db when sending a batch


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/be6f48a9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/be6f48a9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/be6f48a9

Branch: refs/heads/master
Commit: be6f48a9b4402eb1f40cb0749ef6f02755efe120
Parents: 7d0935f
Author: rgoers <ra...@dslextreme.com>
Authored: Tue Sep 9 22:15:46 2014 -0700
Committer: rgoers <ra...@dslextreme.com>
Committed: Tue Sep 9 22:15:46 2014 -0700

----------------------------------------------------------------------
 .../flume/appender/FlumePersistentManager.java  | 42 ++++++++++++++------
 src/changes/changes.xml                         | 23 ++++++-----
 2 files changed, 43 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/be6f48a9/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
index a9001f1..237041f 100644
--- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
+++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
@@ -658,18 +658,34 @@ public class FlumePersistentManager extends FlumeAvroManager {
         private boolean sendBatch(DatabaseEntry key, final DatabaseEntry data) throws Exception {
             boolean errors = false;
             OperationStatus status;
-            Cursor cursor = database.openCursor(null, CursorConfig.DEFAULT);
+            Cursor cursor = null;
             try {
-                status = cursor.getFirst(key, data, null);
-
-                final BatchEvent batch = new BatchEvent();
-                for (int i = 0; status == OperationStatus.SUCCESS && i < batchSize; ++i) {
-                    final SimpleEvent event = createEvent(data);
-                    if (event != null) {
-                        batch.addEvent(event);
+            	final BatchEvent batch = new BatchEvent();
+            	for (int retryIndex = 0; retryIndex < lockTimeoutRetryCount; ++retryIndex) {
+            		try {
+            			cursor = database.openCursor(null, CursorConfig.DEFAULT);
+            			status = cursor.getFirst(key, data, null);
+
+            			for (int i = 0; status == OperationStatus.SUCCESS && i < batchSize; ++i) {
+            				final SimpleEvent event = createEvent(data);
+            				if (event != null) {
+            					batch.addEvent(event);
+            				}
+            				status = cursor.getNext(key, data, null);
+            			}
+            			break;
+            		} catch (final LockConflictException lce) {
+            			if (cursor != null) {
+            				try {
+                                cursor.close();
+                                cursor = null;
+                            } catch (final Exception ex) {
+                                LOGGER.trace("Ignored exception closing cursor during lock conflict.");
+                            }
+                        }
                     }
-                    status = cursor.getNext(key, data, null);
-                }
+            	}
+
                 try {
                     manager.send(batch);
                 } catch (final Exception ioe) {
@@ -677,8 +693,10 @@ public class FlumePersistentManager extends FlumeAvroManager {
                     errors = true;
                 }
                 if (!errors) {
-                    cursor.close();
-                    cursor = null;
+                	if (cursor != null) {
+	                    cursor.close();
+	                    cursor = null;
+                	}
                     Transaction txn = null;
                     Exception exception = null;
                     for (int retryIndex = 0; retryIndex < lockTimeoutRetryCount; ++retryIndex) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/be6f48a9/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f23f77a..cce512c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
   </properties>
   <body>
     <release version="2.?.?" date="2014-??-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-391" dev="rgoers" type="fix" due-to="Kamal Bahadur">
+        FlumePersistentManager now handles LockConflictExceptions in Berkeley Db when sending a batch.
+      </action>
       <action issue="LOG4J2-782" dev="mattsicker" type="fix">
         Remove invalid Oracle Maven repository.
       </action>
@@ -62,17 +65,17 @@
       </action>
       <action issue="LOG4J2-766" dev="ggregory" type="update" due-to="Bruno P. Kinoshita">
         Incomplete documentation for JSONLayout.
-      </action>      
+      </action>
       <action issue="LOG4J2-800" dev="ggregory" type="update">
         All life cycle implementations should be serializable.
-      </action>      
+      </action>
       <action issue="LOG4J2-801" dev="ggregory" type="update">
         org.apache.logging.log4j.core.Logger should be serializable.
-      </action>      
+      </action>
       <action issue="LOG4J2-810" dev="ggregory" type="update">
         Update javax.mail to 1.5.2 from 1.5.0.
-      </action>      
-    </release> 
+      </action>
+    </release>
     <release version="2.0.2" date="2014-08-16" description="Bug fixes and enhancements">
       <action issue="LOG4J2-775" dev="ggregory" type="update">
         Update Apache Flume to 1.5.0.1 from 1.5.0.
@@ -119,17 +122,17 @@
       <action issue="LOG4J2-756" dev="rpopma" type="fix" due-to="Scott Harrington">
         Prevent JUnit test from creating unnecessary Log4j2Plugins.dat during build.
       </action>
-    </release> 
+    </release>
     <release version="2.0.1" date="2014-07-29" description="Bug fixes">
       <action issue="LOG4J2-744" dev="rpopma" type="fix" due-to="Scott Harrington">
         Avoid unnecessary Clock calls when TimestampMessage is logged.
-      </action>      
+      </action>
       <action issue="LOG4J2-704" dev="rpopma" type="fix">
         Improved error message if configuration file not found.
-      </action>      
+      </action>
       <action issue="LOG4J2-750" dev="ggregory" type="fix" due-to="Mike Calmus">
         Webapp configuration page has incorrect class name.
-      </action>      
+      </action>
       <action issue="LOG4J2-749" dev="rpopma" type="fix" due-to="Scott Harrington">
         Retain the default date pattern after fixing the ISO8601 pattern.
       </action>
@@ -187,7 +190,7 @@
       <action issue="LOG4J2-733" dev="ggregory" type="updated">
         Update to latest Jackson jars from the 2.4.1.X line.
       </action>
-    </release> 
+    </release>
     <release version="2.0" date="2014-07-12" description="GA Release">
       <action issue="LOG4J2-705" dev="rpopma" type="fix">
         Fixed issue where Async Logger does not log thread context stack data.