diff options
author | Keith Wall <kwall@apache.org> | 2014-06-13 14:26:15 +0000 |
---|---|---|
committer | Keith Wall <kwall@apache.org> | 2014-06-13 14:26:15 +0000 |
commit | e99117956fa997fee274cdad39f5702a183a0935 (patch) | |
tree | d5f0455aecba7828fae81a9df378f862ec5baf13 /java | |
parent | b9200f43f09a36b502e3d74fc7c7500b00fd850d (diff) | |
download | qpid-python-e99117956fa997fee274cdad39f5702a183a0935.tar.gz |
QPID-5801: [Java Broker] BDB HA - ensure that replication exceptions when reading the message id sequence cause the environment to restart
Addresses review comment from Alex Rudyy.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1602441 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r-- | java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java index 1e1447325e..be1c7c140e 100644 --- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java +++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java @@ -644,10 +644,7 @@ public class BDBConfigurationStore implements MessageStoreProvider, DurableConfi public <T extends StorableMessageMetaData> StoredMessage<T> addMessage(T metaData) { - Sequence mmdSeq = _environmentFacade.openSequence(getMessageMetaDataSeqDb(), - MESSAGE_METADATA_SEQ_KEY, - MESSAGE_METADATA_SEQ_CONFIG); - long newMessageId = mmdSeq.get(null, 1); + long newMessageId = getNextMessageSequenceNumber(); if (metaData.isPersistent()) { @@ -659,6 +656,26 @@ public class BDBConfigurationStore implements MessageStoreProvider, DurableConfi } } + private long getNextMessageSequenceNumber() + { + long newMessageId; + try + { + // The implementations of sequences mean that there is only a transaction + // after every n sequence values, where n is the MESSAGE_METADATA_SEQ_CONFIG.getCacheSize() + + Sequence mmdSeq = _environmentFacade.openSequence(getMessageMetaDataSeqDb(), + MESSAGE_METADATA_SEQ_KEY, + MESSAGE_METADATA_SEQ_CONFIG); + newMessageId = mmdSeq.get(null, 1); + } + catch (DatabaseException de) + { + throw _environmentFacade.handleDatabaseException("Cannot get sequence value for new message", de); + } + return newMessageId; + } + @Override public boolean isPersistent() { |