qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1786939 - in /qpid/java/branches/6.0.x: ./ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/
Date Tue, 14 Mar 2017 17:32:09 GMT
Author: kwall
Date: Tue Mar 14 17:32:09 2017
New Revision: 1786939

URL: http://svn.apache.org/viewvc?rev=1786939&view=rev
Log:
QPID-7684: [Java Broker, BDB] Adhere to recommended practice for retrying after a LockConflictException.

Merged from 6.1.x branch with command:

svn merge -c 1786935   ^/qpid/java/branches/6.1.x

Modified:
    qpid/java/branches/6.0.x/   (props changed)
    qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
    qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
    qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java

Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 14 17:32:09 2017
@@ -9,6 +9,6 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/branches/6.1.x:1767487,1770199,1774599,1785143,1785279,1785819,1786019,1786342,1786731,1786924
-/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720340,1720664,1721151,1721198,1722019-1722020,1722246,1722339,1722416,1722674,1722678,1722683,1722711,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1725760,1726176,1726244-1726246,1726249,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727532,1727555,1727608,1727951,1727954,1728089,1728167,1728302,1728497,1728501,1728524,1728639,1728651,1728772,1729215,1729297,1729347,1729356,1729406,1729408,1729412,1729515,1729638,1729656-1729
 657,1729783,1729828,1729832,1729841,1729851,1729886,1729904,1729973,1730019,1730025,1730052,1730072,1730088,1730494,1730499,1730547,1730559,1730567,1730578,1730585,1730651,1730697,1730712-1730713,1730805,1731029,1731110,1731210,1731225,1731444,1731551,1731612,1732184,1732452,1732461,1732465,1732525,1732812,1733467,1734452,1736478,1736751,1736838,1737804,1737835,1737853,1737984,1737992,1738119,1738135,1738231,1738271,1738607,1738610,1738731,1738914,1741702,1742257,1742284,1742339,1742544,1742900,1742926,1743161,1743228,1743383,1743982,1744012-1744013,1744046,1744123,1744157,1744276,1744403,1745424,1745450,1746140,1746273,1747526,1748254,1748723,1748818,1749349,1749399,1749482,1749524,1750359-1750360,1750943,1751433,1754251,1754354,1754392,1754429,1754510,1754550,1755561,1755957,1758628,1758640,1758766,1758964,1758980,1759774,1759783,1760032,1760337,1760522,1760546,1762070,1763653,1763966,1763988,1765350,1765609,1765828,1766032,1766547,1766553,1766796,1769597,1772365,1774446,1785117,1
 785158,1785311,1785854,1785936,1786188,1786690
+/qpid/java/branches/6.1.x:1767487,1770199,1774599,1785143,1785279,1785819,1786019,1786342,1786731,1786924,1786935
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720340,1720664,1721151,1721198,1722019-1722020,1722246,1722339,1722416,1722674,1722678,1722683,1722711,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1725760,1726176,1726244-1726246,1726249,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727532,1727555,1727608,1727951,1727954,1728089,1728167,1728302,1728497,1728501,1728524,1728639,1728651,1728772,1729215,1729297,1729347,1729356,1729406,1729408,1729412,1729515,1729638,1729656-1729
 657,1729783,1729828,1729832,1729841,1729851,1729886,1729904,1729973,1730019,1730025,1730052,1730072,1730088,1730494,1730499,1730547,1730559,1730567,1730578,1730585,1730651,1730697,1730712-1730713,1730805,1731029,1731110,1731210,1731225,1731444,1731551,1731612,1732184,1732452,1732461,1732465,1732525,1732812,1733467,1734452,1736478,1736751,1736838,1737804,1737835,1737853,1737984,1737992,1738119,1738135,1738231,1738271,1738607,1738610,1738731,1738914,1741702,1742257,1742284,1742339,1742544,1742900,1742926,1743161,1743228,1743383,1743982,1744012-1744013,1744046,1744123,1744157,1744276,1744403,1745424,1745450,1746140,1746273,1747526,1748254,1748723,1748818,1749349,1749399,1749482,1749524,1750359-1750360,1750943,1751433,1754251,1754354,1754392,1754429,1754510,1754550,1755561,1755957,1758628,1758640,1758766,1758964,1758980,1759774,1759783,1760032,1760337,1760522,1760546,1762070,1763653,1763966,1763988,1765350,1765609,1765828,1766032,1766547,1766553,1766796,1769597,1772365,1774446,1785117,1
 785158,1785311,1785854,1785936,1786188,1786690,1786723,1786923
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java?rev=1786939&r1=1786938&r2=1786939&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
(original)
+++ qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
Tue Mar 14 17:32:09 2017
@@ -20,7 +20,6 @@ package org.apache.qpid.server.store.ber
 
 import static org.apache.qpid.server.store.berkeleydb.BDBUtils.DEFAULT_DATABASE_CONFIG;
 import static org.apache.qpid.server.store.berkeleydb.BDBUtils.abortTransactionSafely;
-import static org.apache.qpid.server.store.berkeleydb.BDBUtils.closeCursorSafely;
 
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
@@ -413,10 +412,8 @@ public abstract class AbstractBDBMessage
 
     private void visitMessagesInternal(MessageHandler handler, EnvironmentFacade environmentFacade)
     {
-        Cursor cursor = null;
-        try
+        try(Cursor cursor = getMessageMetaDataDb().openCursor(null, null))
         {
-            cursor = getMessageMetaDataDb().openCursor(null, null);
             DatabaseEntry key = new DatabaseEntry();
             DatabaseEntry value = new DatabaseEntry();
             MessageMetaDataBinding valueBinding = MessageMetaDataBinding.getInstance();
@@ -450,20 +447,6 @@ public abstract class AbstractBDBMessage
         {
             throw environmentFacade.handleDatabaseException("Cannot visit messages", e);
         }
-        finally
-        {
-            if (cursor != null)
-            {
-                try
-                {
-                    cursor.close();
-                }
-                catch(RuntimeException e)
-                {
-                    throw environmentFacade.handleDatabaseException("Cannot close cursor",
e);
-                }
-            }
-        }
     }
 
     private void sleepOrThrowOnLockConflict(int attempts, String throwMessage, LockConflictException
cause)
@@ -1485,25 +1468,25 @@ public abstract class AbstractBDBMessage
         {
             checkMessageStoreOpen();
 
-            Cursor cursor = null;
-            List<QueueEntryKey> entries = new ArrayList<QueueEntryKey>();
+            final List<QueueEntryKey> entries = new ArrayList<>();
             try
             {
-                cursor = getDeliveryDb().openCursor(null, null);
-                DatabaseEntry key = new DatabaseEntry();
-                DatabaseEntry value = new DatabaseEntry();
-                value.setPartial(0, 0, true);
-
-                QueueEntryBinding keyBinding = QueueEntryBinding.getInstance();
-                keyBinding.objectToEntry(new QueueEntryKey(queue.getId(),0l), key);
-
-                boolean searchCompletedSuccessfully = false;
                 int attempts = 0;
                 boolean completed = false;
                 do
                 {
-                    try
+                    try(Cursor cursor = getDeliveryDb().openCursor(null, null))
                     {
+                        boolean searchCompletedSuccessfully = false;
+                        entries.clear();
+
+                        DatabaseEntry key = new DatabaseEntry();
+                        DatabaseEntry value = new DatabaseEntry();
+                        value.setPartial(0, 0, true);
+
+                        QueueEntryBinding keyBinding = QueueEntryBinding.getInstance();
+                        keyBinding.objectToEntry(new QueueEntryKey(queue.getId(),0l), key);
+
                         if (!searchCompletedSuccessfully && (searchCompletedSuccessfully
= cursor.getSearchKeyRange(key,value, LockMode.DEFAULT) == OperationStatus.SUCCESS))
                         {
                             QueueEntryKey entry = keyBinding.entryToObject(key);
@@ -1532,7 +1515,7 @@ public abstract class AbstractBDBMessage
                     }
                     catch (LockConflictException e)
                     {
-                        sleepOrThrowOnLockConflict(attempts++, "Cannot visit messages", e);
+                        sleepOrThrowOnLockConflict(attempts++, "Cannot visit message instances",
e);
                     }
                 }
                 while (!completed);
@@ -1541,10 +1524,6 @@ public abstract class AbstractBDBMessage
             {
                 throw getEnvironmentFacade().handleDatabaseException("Cannot visit message
instances", e);
             }
-            finally
-            {
-                closeCursorSafely(cursor, getEnvironmentFacade());
-            }
 
             for(QueueEntryKey entry : entries)
             {
@@ -1565,11 +1544,9 @@ public abstract class AbstractBDBMessage
         {
             checkMessageStoreOpen();
 
-            Cursor cursor = null;
-            List<QueueEntryKey> entries = new ArrayList<QueueEntryKey>();
-            try
+            List<QueueEntryKey> entries = new ArrayList<>();
+            try(Cursor cursor = getDeliveryDb().openCursor(null, null))
             {
-                cursor = getDeliveryDb().openCursor(null, null);
                 DatabaseEntry key = new DatabaseEntry();
                 QueueEntryBinding keyBinding = QueueEntryBinding.getInstance();
 
@@ -1585,10 +1562,6 @@ public abstract class AbstractBDBMessage
             {
                 throw getEnvironmentFacade().handleDatabaseException("Cannot visit message
instances", e);
             }
-            finally
-            {
-                closeCursorSafely(cursor, getEnvironmentFacade());
-            }
 
             for(QueueEntryKey entry : entries)
             {
@@ -1607,10 +1580,8 @@ public abstract class AbstractBDBMessage
         {
             checkMessageStoreOpen();
 
-            Cursor cursor = null;
-            try
+            try(Cursor cursor = getXidDb().openCursor(null, null))
             {
-                cursor = getXidDb().openCursor(null, null);
                 DatabaseEntry key = new DatabaseEntry();
                 XidBinding keyBinding = XidBinding.getInstance();
                 PreparedTransactionBinding valueBinding = new PreparedTransactionBinding();
@@ -1632,10 +1603,6 @@ public abstract class AbstractBDBMessage
             {
                 throw getEnvironmentFacade().handleDatabaseException("Cannot recover distributed
transactions", e);
             }
-            finally
-            {
-                closeCursorSafely(cursor, getEnvironmentFacade());
-            }
         }
 
 

Modified: qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java?rev=1786939&r1=1786938&r2=1786939&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
(original)
+++ qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
Tue Mar 14 17:32:09 2017
@@ -22,7 +22,6 @@ package org.apache.qpid.server.store.ber
 
 import static org.apache.qpid.server.store.berkeleydb.BDBUtils.DEFAULT_DATABASE_CONFIG;
 import static org.apache.qpid.server.store.berkeleydb.BDBUtils.abortTransactionSafely;
-import static org.apache.qpid.server.store.berkeleydb.BDBUtils.closeCursorSafely;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -165,11 +164,8 @@ public class BDBConfigurationStore imple
     private void doVisitAllConfiguredObjectRecords(ConfiguredObjectRecordHandler handler)
     {
         Map<UUID, BDBConfiguredObjectRecord> configuredObjects = new HashMap<UUID,
BDBConfiguredObjectRecord>();
-        Cursor objectsCursor = null;
-        Cursor hierarchyCursor = null;
-        try
+        try(Cursor objectsCursor = getConfiguredObjectsDb().openCursor(null, null))
         {
-            objectsCursor = getConfiguredObjectsDb().openCursor(null, null);
             DatabaseEntry key = new DatabaseEntry();
             DatabaseEntry value = new DatabaseEntry();
 
@@ -184,27 +180,24 @@ public class BDBConfigurationStore imple
             }
 
             // set parents
-            hierarchyCursor = getConfiguredObjectHierarchyDb().openCursor(null, null);
-            while (hierarchyCursor.getNext(key, value, LockMode.RMW) == OperationStatus.SUCCESS)
+            try(Cursor hierarchyCursor = getConfiguredObjectHierarchyDb().openCursor(null,
null))
             {
-                HierarchyKey hk = HierarchyKeyBinding.getInstance().entryToObject(key);
-                UUID parentId = UUIDTupleBinding.getInstance().entryToObject(value);
-                BDBConfiguredObjectRecord child = configuredObjects.get(hk.getChildId());
-                if(child != null)
+                while (hierarchyCursor.getNext(key, value, LockMode.RMW) == OperationStatus.SUCCESS)
                 {
-                    ConfiguredObjectRecord parent = configuredObjects.get(parentId);
-                    if(parent != null)
+                    HierarchyKey hk = HierarchyKeyBinding.getInstance().entryToObject(key);
+                    UUID parentId = UUIDTupleBinding.getInstance().entryToObject(value);
+                    BDBConfiguredObjectRecord child = configuredObjects.get(hk.getChildId());
+                    if(child != null)
                     {
-                        child.addParent(hk.getParentType(), parent);
+                        ConfiguredObjectRecord parent = configuredObjects.get(parentId);
+                        if(parent != null)
+                        {
+                            child.addParent(hk.getParentType(), parent);
+                        }
                     }
                 }
             }
         }
-        finally
-        {
-            closeCursorSafely(objectsCursor, _environmentFacade);
-            closeCursorSafely(hierarchyCursor, _environmentFacade);
-        }
 
         for (ConfiguredObjectRecord record : configuredObjects.values())
         {

Modified: qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java?rev=1786939&r1=1786938&r2=1786939&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
(original)
+++ qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
Tue Mar 14 17:32:09 2017
@@ -47,22 +47,6 @@ public class BDBUtils
     private static final Pattern NON_REP_JE_PARAM_PATTERN = Pattern.compile("^je\\.(?!rep\\.).*");
     private static final Pattern REP_JE_PARAM_PATTERN = Pattern.compile("^je\\.rep\\..*");
 
-    public static void closeCursorSafely(Cursor cursor, final EnvironmentFacade environmentFacade)
throws StoreException
-    {
-        if (cursor != null)
-        {
-            try
-            {
-                cursor.close();
-            }
-            catch (RuntimeException e)
-            {
-                // We need the possible side effect of the facade restarting the environment
but don't care about the exception
-                throw environmentFacade.handleDatabaseException("Cannot close cursor", e);
-            }
-        }
-    }
-
     public static void abortTransactionSafely(Transaction tx, EnvironmentFacade environmentFacade)
     {
         try



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message