diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-02-14 11:46:31 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-02-14 11:46:31 +0000 |
| commit | 763396a3a8c18a9b42e2cf611333e61d4c6444de (patch) | |
| tree | e3898eeb82ddca9e609ef2ba3b45ca271a675f6c /qpid/java | |
| parent | 50b314a51a2c787fcd412a84cb8464f72e3868b4 (diff) | |
| download | qpid-python-763396a3a8c18a9b42e2cf611333e61d4c6444de.tar.gz | |
QPID-5551 : Change AMQStoreException to StoreException which inherits from ServerScopedRuntimeException
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1568252 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
34 files changed, 328 insertions, 535 deletions
diff --git a/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java b/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java index bab68c6f07..aa4ddd8181 100644 --- a/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java +++ b/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java @@ -36,7 +36,7 @@ import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; import org.apache.log4j.Logger; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.jmx.AMQManagedObject; import org.apache.qpid.server.jmx.ManagedObject; import org.apache.qpid.server.store.berkeleydb.BDBHAMessageStore; @@ -189,7 +189,7 @@ public class BDBHAMessageStoreManagerMBean extends AMQManagedObject implements M { _store.removeNodeFromGroup(nodeName); } - catch (AMQStoreException e) + catch (StoreException e) { LOGGER.error("Failed to remove node " + nodeName + " from group", e); throw new JMException(e.getMessage()); @@ -203,7 +203,7 @@ public class BDBHAMessageStoreManagerMBean extends AMQManagedObject implements M { _store.setDesignatedPrimary(primary); } - catch (AMQStoreException e) + catch (StoreException e) { LOGGER.error("Failed to set node " + _store.getNodeName() + " as designated primary", e); throw new JMException(e.getMessage()); @@ -217,7 +217,7 @@ public class BDBHAMessageStoreManagerMBean extends AMQManagedObject implements M { _store.updateAddress(nodeName, newHostName, newPort); } - catch(AMQStoreException e) + catch(StoreException e) { LOGGER.error("Failed to update address for node " + nodeName + " to " + newHostName + ":" + newPort, e); throw new JMException(e.getMessage()); diff --git a/qpid/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java b/qpid/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java index a74c9b3c87..54051ab630 100644 --- a/qpid/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java +++ b/qpid/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java @@ -37,7 +37,7 @@ import javax.management.openmbean.TabularData; import junit.framework.TestCase; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.jmx.AMQManagedObject; import org.apache.qpid.server.jmx.ManagedObjectRegistry; import org.apache.qpid.server.logging.SystemOutMessageLogger; @@ -168,7 +168,7 @@ public class BDBHAMessageStoreManagerMBeanTest extends TestCase public void testRemoveNodeFromReplicationGroupWithError() throws Exception { - doThrow(new AMQStoreException("mocked exception")).when(_store).removeNodeFromGroup(TEST_NODE_NAME); + doThrow(new StoreException("mocked exception")).when(_store).removeNodeFromGroup(TEST_NODE_NAME); try { @@ -190,7 +190,7 @@ public class BDBHAMessageStoreManagerMBeanTest extends TestCase public void testSetAsDesignatedPrimaryWithError() throws Exception { - doThrow(new AMQStoreException("mocked exception")).when(_store).setDesignatedPrimary(true); + doThrow(new StoreException("mocked exception")).when(_store).setDesignatedPrimary(true); try { diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java index 53365e6b96..37fb77f547 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java @@ -44,7 +44,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.log4j.Logger; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.message.EnqueueableMessage; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.queue.AMQQueue; @@ -62,7 +62,6 @@ import org.apache.qpid.server.store.berkeleydb.tuple.QueueEntryBinding; import org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding; import org.apache.qpid.server.store.berkeleydb.tuple.XidBinding; import org.apache.qpid.server.store.berkeleydb.upgrade.Upgrader; -import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.util.FileUtils; public abstract class AbstractBDBMessageStore implements MessageStore, DurableConfigurationStore @@ -328,9 +327,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * * This is required if you do not want to perform recovery of the store data * - * @throws AMQStoreException if the store is not in the correct state + * @throws org.apache.qpid.server.store.StoreException if the store is not in the correct state */ - void startWithNoRecover() throws AMQStoreException + void startWithNoRecover() throws StoreException { _stateManager.attainState(State.INITIALISING); _stateManager.attainState(State.INITIALISED); @@ -489,16 +488,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new ServerScopedRuntimeException("Error recovering persistent state: " + e.getMessage(), e); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("Error recovering persistent state: " + e.getMessage(), e); + throw new StoreException("Error recovering persistent state: " + e.getMessage(), e); } } - private void updateConfigVersion(int newConfigVersion) throws AMQStoreException + private void updateConfigVersion(int newConfigVersion) throws StoreException { Cursor cursor = null; try @@ -515,7 +510,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = cursor.put(key, value); if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Error setting config version: " + status); + throw new StoreException("Error setting config version: " + status); } } cursor.close(); @@ -529,7 +524,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } - private int getConfigVersion() throws AMQStoreException + private int getConfigVersion() throws StoreException { Cursor cursor = null; try @@ -548,7 +543,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = _configVersionDb.put(null, key, value); if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Error initialising config version: " + status); + throw new StoreException("Error initialising config version: " + status); } return 0; } @@ -711,7 +706,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo dtxrh.completeDtxRecordRecovery(); } - public void removeMessage(long messageId, boolean sync) throws AMQStoreException + public void removeMessage(long messageId, boolean sync) throws StoreException { boolean complete = false; @@ -823,11 +818,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e1) { - throw new AMQStoreException("Error aborting transaction " + e1, e1); + throw new StoreException("Error aborting transaction " + e1, e1); } } - throw new AMQStoreException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e); + throw new StoreException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e); } finally { @@ -840,14 +835,14 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e1) { - throw new AMQStoreException("Error aborting transaction " + e1, e1); + throw new StoreException("Error aborting transaction " + e1, e1); } } } } @Override - public void create(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException + public void create(UUID id, String type, Map<String, Object> attributes) throws StoreException { if (_stateManager.isInState(State.ACTIVE)) { @@ -857,7 +852,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } @Override - public void remove(UUID id, String type) throws AMQStoreException + public void remove(UUID id, String type) throws StoreException { if (LOGGER.isDebugEnabled()) { @@ -866,12 +861,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = removeConfiguredObject(null, id); if (status == OperationStatus.NOTFOUND) { - throw new AMQStoreException("Configured object of type " + type + " with id " + id + " not found"); + throw new StoreException("Configured object of type " + type + " with id " + id + " not found"); } } @Override - public UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException + public UUID[] removeConfiguredObjects(final UUID... objects) throws StoreException { com.sleepycat.je.Transaction txn = _environment.beginTransaction(null, null); Collection<UUID> removed = new ArrayList<UUID>(objects.length); @@ -888,17 +883,17 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } @Override - public void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException + public void update(UUID id, String type, Map<String, Object> attributes) throws StoreException { update(false, id, type, attributes, null); } - public void update(ConfiguredObjectRecord... records) throws AMQStoreException + public void update(ConfiguredObjectRecord... records) throws StoreException { update(false, records); } - public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException + public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException { com.sleepycat.je.Transaction txn = _environment.beginTransaction(null, null); for(ConfiguredObjectRecord record : records) @@ -908,7 +903,8 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo txn.commit(); } - private void update(boolean createIfNecessary, UUID id, String type, Map<String, Object> attributes, com.sleepycat.je.Transaction txn) throws AMQStoreException + private void update(boolean createIfNecessary, UUID id, String type, Map<String, Object> attributes, com.sleepycat.je.Transaction txn) throws + StoreException { if (LOGGER.isDebugEnabled()) { @@ -935,17 +931,17 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo status = _configuredObjectsDb.put(txn, key, newValue); if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Error updating queue details within the store: " + status); + throw new StoreException("Error updating queue details within the store: " + status); } } else if (status != OperationStatus.NOTFOUND) { - throw new AMQStoreException("Error finding queue details within the store: " + status); + throw new StoreException("Error finding queue details within the store: " + status); } } catch (DatabaseException e) { - throw new AMQStoreException("Error updating queue details within the store: " + e,e); + throw new StoreException("Error updating queue details within the store: " + e,e); } } @@ -956,10 +952,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * @param queue The the queue to place the message on. * @param messageId The message to enqueue. * - * @throws AMQStoreException If the operation fails for any reason. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason. */ public void enqueueMessage(final com.sleepycat.je.Transaction tx, final TransactionLogResource queue, - long messageId) throws AMQStoreException + long messageId) throws StoreException { DatabaseEntry key = new DatabaseEntry(); @@ -982,7 +978,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo catch (DatabaseException e) { LOGGER.error("Failed to enqueue: " + e.getMessage(), e); - throw new AMQStoreException("Error writing enqueued message with id " + messageId + " for queue " + throw new StoreException("Error writing enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue) queue).getName() + " with id " : "") + queue.getId() + " to database", e); } @@ -995,10 +991,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * @param queue The queue to take the message from. * @param messageId The message to dequeue. * - * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist. */ public void dequeueMessage(final com.sleepycat.je.Transaction tx, final TransactionLogResource queue, - long messageId) throws AMQStoreException + long messageId) throws StoreException { DatabaseEntry key = new DatabaseEntry(); @@ -1018,12 +1014,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = _deliveryDb.delete(tx, key); if (status == OperationStatus.NOTFOUND) { - throw new AMQStoreException("Unable to find message with id " + messageId + " on queue " + throw new StoreException("Unable to find message with id " + messageId + " on queue " + (queue instanceof AMQQueue ? ((AMQQueue) queue).getName() + " with id " : "") + id); } else if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Unable to remove message with id " + messageId + " on queue" + throw new StoreException("Unable to remove message with id " + messageId + " on queue" + (queue instanceof AMQQueue ? ((AMQQueue) queue).getName() + " with id " : "") + id); } @@ -1041,7 +1037,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo LOGGER.error("Failed to dequeue message " + messageId + ": " + e.getMessage(), e); LOGGER.error(tx); - throw new AMQStoreException("Error accessing database while dequeuing message: " + e.getMessage(), e); + throw new StoreException("Error accessing database while dequeuing message: " + e.getMessage(), e); } } @@ -1051,7 +1047,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo byte[] globalId, byte[] branchId, org.apache.qpid.server.store.Transaction.Record[] enqueues, - org.apache.qpid.server.store.Transaction.Record[] dequeues) throws AMQStoreException + org.apache.qpid.server.store.Transaction.Record[] dequeues) throws StoreException { DatabaseEntry key = new DatabaseEntry(); Xid xid = new Xid(format, globalId, branchId); @@ -1070,12 +1066,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo catch (DatabaseException e) { LOGGER.error("Failed to write xid: " + e.getMessage(), e); - throw new AMQStoreException("Error writing xid to database", e); + throw new StoreException("Error writing xid to database", e); } } private void removeXid(com.sleepycat.je.Transaction txn, long format, byte[] globalId, byte[] branchId) - throws AMQStoreException + throws StoreException { DatabaseEntry key = new DatabaseEntry(); Xid xid = new Xid(format, globalId, branchId); @@ -1090,11 +1086,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = _xidDb.delete(txn, key); if (status == OperationStatus.NOTFOUND) { - throw new AMQStoreException("Unable to find xid"); + throw new StoreException("Unable to find xid"); } else if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Unable to remove xid"); + throw new StoreException("Unable to remove xid"); } } @@ -1104,7 +1100,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo LOGGER.error("Failed to remove xid ", e); LOGGER.error(txn); - throw new AMQStoreException("Error accessing database while removing xid: " + e.getMessage(), e); + throw new StoreException("Error accessing database while removing xid: " + e.getMessage(), e); } } @@ -1113,13 +1109,14 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * * @param tx The transaction to commit all operations for. * - * @throws AMQStoreException If the operation fails for any reason. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason. */ - private StoreFuture commitTranImpl(final com.sleepycat.je.Transaction tx, boolean syncCommit) throws AMQStoreException + private StoreFuture commitTranImpl(final com.sleepycat.je.Transaction tx, boolean syncCommit) throws + StoreException { if (tx == null) { - throw new AMQStoreException("Fatal internal error: transactional is null at commitTran"); + throw new StoreException("Fatal internal error: transactional is null at commitTran"); } StoreFuture result; @@ -1135,7 +1132,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error commit tx: " + e.getMessage(), e); + throw new StoreException("Error commit tx: " + e.getMessage(), e); } return result; @@ -1146,9 +1143,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * * @param tx The transaction to abandon. * - * @throws AMQStoreException If the operation fails for any reason. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason. */ - public void abortTran(final com.sleepycat.je.Transaction tx) throws AMQStoreException + public void abortTran(final com.sleepycat.je.Transaction tx) throws StoreException { if (LOGGER.isDebugEnabled()) { @@ -1161,7 +1158,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error aborting transaction: " + e.getMessage(), e); + throw new StoreException("Error aborting transaction: " + e.getMessage(), e); } } @@ -1172,7 +1169,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * * @return a list of message ids for messages enqueued for a particular queue */ - List<Long> getEnqueuedMessages(UUID queueId) throws AMQStoreException + List<Long> getEnqueuedMessages(UUID queueId) throws StoreException { Cursor cursor = null; try @@ -1208,7 +1205,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Database error: " + e.getMessage(), e); + throw new StoreException("Database error: " + e.getMessage(), e); } finally { @@ -1220,7 +1217,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error closing cursor: " + e.getMessage(), e); + throw new StoreException("Error closing cursor: " + e.getMessage(), e); } } } @@ -1244,10 +1241,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * @param offset The offset of the data chunk in the message. * @param contentBody The content of the data chunk. * - * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist. */ protected void addContent(final com.sleepycat.je.Transaction tx, long messageId, int offset, - ByteBuffer contentBody) throws AMQStoreException + ByteBuffer contentBody) throws StoreException { DatabaseEntry key = new DatabaseEntry(); LongBinding.longToEntry(messageId, key); @@ -1259,7 +1256,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = _messageContentDb.put(tx, key, value); if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Error adding content for message id " + messageId + ": " + status); + throw new StoreException("Error adding content for message id " + messageId + ": " + status); } if (LOGGER.isDebugEnabled()) @@ -1270,7 +1267,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error writing AMQMessage with id " + messageId + " to database: " + e.getMessage(), e); + throw new StoreException("Error writing AMQMessage with id " + messageId + " to database: " + e.getMessage(), e); } } @@ -1281,11 +1278,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * @param messageId The message to store the data for. * @param messageMetaData The message meta data to store. * - * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist. */ private void storeMetaData(final com.sleepycat.je.Transaction tx, long messageId, StorableMessageMetaData messageMetaData) - throws AMQStoreException + throws StoreException { if (LOGGER.isDebugEnabled()) { @@ -1310,7 +1307,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error writing message metadata with id " + messageId + " to database: " + e.getMessage(), e); + throw new StoreException("Error writing message metadata with id " + messageId + " to database: " + e.getMessage(), e); } } @@ -1321,9 +1318,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * * @return The message meta data. * - * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist. */ - public StorableMessageMetaData getMessageMetaData(long messageId) throws AMQStoreException + public StorableMessageMetaData getMessageMetaData(long messageId) throws StoreException { if (LOGGER.isDebugEnabled()) { @@ -1341,7 +1338,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = _messageMetaDataDb.get(null, key, value, LockMode.READ_UNCOMMITTED); if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Metadata not found for message with id " + messageId); + throw new StoreException("Metadata not found for message with id " + messageId); } StorableMessageMetaData mdd = messageBinding.entryToObject(value); @@ -1350,7 +1347,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error reading message metadata for message with id " + messageId + ": " + e.getMessage(), e); + throw new StoreException("Error reading message metadata for message with id " + messageId + ": " + e.getMessage(), e); } } @@ -1364,9 +1361,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * * @return The number of bytes inserted into the destination * - * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist. */ - public int getContent(long messageId, int offset, ByteBuffer dst) throws AMQStoreException + public int getContent(long messageId, int offset, ByteBuffer dst) throws StoreException { DatabaseEntry contentKeyEntry = new DatabaseEntry(); LongBinding.longToEntry(messageId, contentKeyEntry); @@ -1390,7 +1387,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo int size = dataAsBytes.length; if (offset > size) { - throw new ServerScopedRuntimeException("Offset " + offset + " is greater than message size " + size + throw new StoreException("Offset " + offset + " is greater than message size " + size + " for message id " + messageId + "!"); } @@ -1407,7 +1404,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error getting AMQMessage with id " + messageId + " to database: " + e.getMessage(), e); + throw new StoreException("Error getting AMQMessage with id " + messageId + " to database: " + e.getMessage(), e); } } @@ -1450,9 +1447,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo * Makes the specified configured object persistent. * * @param configuredObject Details of the configured object to store. - * @throws AMQStoreException If the operation fails for any reason. + * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason. */ - private void storeConfiguredObjectEntry(ConfiguredObjectRecord configuredObject) throws AMQStoreException + private void storeConfiguredObjectEntry(ConfiguredObjectRecord configuredObject) throws StoreException { if (_stateManager.isInState(State.ACTIVE)) { @@ -1470,19 +1467,19 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo OperationStatus status = _configuredObjectsDb.put(null, key, value); if (status != OperationStatus.SUCCESS) { - throw new AMQStoreException("Error writing configured object " + configuredObject + " to database: " + throw new StoreException("Error writing configured object " + configuredObject + " to database: " + status); } } catch (DatabaseException e) { - throw new AMQStoreException("Error writing configured object " + configuredObject + throw new StoreException("Error writing configured object " + configuredObject + " to database: " + e.getMessage(), e); } } } - private OperationStatus removeConfiguredObject(Transaction tx, UUID id) throws AMQStoreException + private OperationStatus removeConfiguredObject(Transaction tx, UUID id) throws StoreException { LOGGER.debug("Removing configured object: " + id); @@ -1495,7 +1492,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch (DatabaseException e) { - throw new AMQStoreException("Error deleting of configured object with id " + id + " from database", e); + throw new StoreException("Error deleting of configured object with id " + id + " from database", e); } } @@ -1536,14 +1533,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo StorableMessageMetaData metaData = _metaDataRef.get(); if(metaData == null) { - try - { - metaData = AbstractBDBMessageStore.this.getMessageMetaData(_messageId); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException(e); - } + metaData = AbstractBDBMessageStore.this.getMessageMetaData(_messageId); _metaDataRef = new SoftReference<StorableMessageMetaData>(metaData); } @@ -1588,15 +1578,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } else { - try - { - return AbstractBDBMessageStore.this.getContent(_messageId, offsetInMessage, dst); - } - catch (AMQStoreException e) - { - // TODO maybe should throw a checked exception, or at least log before throwing - throw new ServerScopedRuntimeException(e); - } + return AbstractBDBMessageStore.this.getContent(_messageId, offsetInMessage, dst); } } @@ -1630,11 +1612,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo } catch(DatabaseException e) { - throw new ServerScopedRuntimeException(e); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } finally { @@ -1658,17 +1636,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo public void remove() { - try - { - int delta = getMetaData().getContentSize(); - AbstractBDBMessageStore.this.removeMessage(_messageId, false); - storedSizeChange(-delta); - - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException(e); - } + int delta = getMetaData().getContentSize(); + AbstractBDBMessageStore.this.removeMessage(_messageId, false); + storedSizeChange(-delta); } private boolean stored() @@ -1693,7 +1663,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo LOGGER.error("Exception during transaction begin, closing store environment.", e); closeEnvironmentSafely(); - throw new ServerScopedRuntimeException("Exception during transaction begin, store environment closed.", e); + throw new StoreException("Exception during transaction begin, store environment closed.", e); } } @@ -1706,89 +1676,41 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo _storeSizeIncrease += storedMessage.getMetaData().getContentSize(); } - try - { - AbstractBDBMessageStore.this.enqueueMessage(_txn, queue, message.getMessageNumber()); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.enqueueMessage(_txn, queue, message.getMessageNumber()); } public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) { - try - { - AbstractBDBMessageStore.this.dequeueMessage(_txn, queue, message.getMessageNumber()); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.dequeueMessage(_txn, queue, message.getMessageNumber()); } public void commitTran() { - try - { - AbstractBDBMessageStore.this.commitTranImpl(_txn, true); - AbstractBDBMessageStore.this.storedSizeChange(_storeSizeIncrease); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.commitTranImpl(_txn, true); + AbstractBDBMessageStore.this.storedSizeChange(_storeSizeIncrease); } public StoreFuture commitTranAsync() { - try - { - AbstractBDBMessageStore.this.storedSizeChange(_storeSizeIncrease); - return AbstractBDBMessageStore.this.commitTranImpl(_txn, false); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.storedSizeChange(_storeSizeIncrease); + return AbstractBDBMessageStore.this.commitTranImpl(_txn, false); } public void abortTran() { - try - { - AbstractBDBMessageStore.this.abortTran(_txn); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.abortTran(_txn); } public void removeXid(long format, byte[] globalId, byte[] branchId) { - try - { - AbstractBDBMessageStore.this.removeXid(_txn, format, globalId, branchId); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.removeXid(_txn, format, globalId, branchId); + } public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues) { - try - { - AbstractBDBMessageStore.this.recordXid(_txn, format, globalId, branchId, enqueues, dequeues); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractBDBMessageStore.this.recordXid(_txn, format, globalId, branchId, enqueues, dequeues); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java index fee1629743..80802b6a0c 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java @@ -26,7 +26,7 @@ import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.util.DbBackup; import org.apache.log4j.Logger; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.util.CommandLineParser; import org.apache.qpid.util.FileUtils; @@ -250,7 +250,7 @@ public class BDBBackup if (fileSet.length == 0) { - throw new ServerScopedRuntimeException("There are no BDB log files to backup in the " + fromdir + " directory."); + throw new StoreException("There are no BDB log files to backup in the " + fromdir + " directory."); } for (int i = 0; i < fileSet.length; i++) @@ -273,7 +273,7 @@ public class BDBBackup catch (IOException ioEx) { // Rethrow this as a runtime exception, as something strange has happened. - throw new ServerScopedRuntimeException(ioEx); + throw new StoreException(ioEx); } } } @@ -293,7 +293,7 @@ public class BDBBackup long now = System.currentTimeMillis(); if ((now - start) > TIMEOUT) { - throw new ServerScopedRuntimeException("Hot backup script failed to complete in " + (TIMEOUT / 1000) + " seconds."); + throw new StoreException("Hot backup script failed to complete in " + (TIMEOUT / 1000) + " seconds."); } } @@ -312,7 +312,7 @@ public class BDBBackup Throwable cause = re.getCause(); if ((cause != null) && (cause instanceof IOException)) { - throw new ServerScopedRuntimeException(re.getMessage() + " fromDir:" + fromdir + " toDir:" + toDirFile, cause); + throw new StoreException(re.getMessage() + " fromDir:" + fromdir + " toDir:" + toDirFile, cause); } else { @@ -330,7 +330,7 @@ public class BDBBackup catch (IOException e) { // Rethrow this as a runtime exception, as something strange has happened. - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java index 0f33dfb325..7f119880b0 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java @@ -35,7 +35,7 @@ import java.util.concurrent.Executors; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.log4j.Logger; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.logging.RootMessageLogger; import org.apache.qpid.server.logging.actors.AbstractActor; import org.apache.qpid.server.logging.actors.CurrentActor; @@ -65,7 +65,6 @@ import com.sleepycat.je.rep.ReplicationNode; import com.sleepycat.je.rep.StateChangeEvent; import com.sleepycat.je.rep.StateChangeListener; import com.sleepycat.je.rep.util.ReplicationGroupAdmin; -import org.apache.qpid.server.util.ServerScopedRuntimeException; public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMessageStore { @@ -154,7 +153,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess if (_coalescingSync && _durability.getLocalSync() == SyncPolicy.SYNC) { - throw new ServerScopedRuntimeException("Coalescing sync cannot be used with master sync policy " + SyncPolicy.SYNC + throw new StoreException("Coalescing sync cannot be used with master sync policy " + SyncPolicy.SYNC + "! Please set highAvailability.coalescingSync to false in store configuration."); } @@ -171,7 +170,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess } else { - throw new ServerScopedRuntimeException("BDB HA configuration key not found. Please specify configuration attribute: " + throw new StoreException("BDB HA configuration key not found. Please specify configuration attribute: " + attributeName); } } @@ -350,7 +349,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess return members; } - public void removeNodeFromGroup(String nodeName) throws AMQStoreException + public void removeNodeFromGroup(String nodeName) throws StoreException { try { @@ -358,15 +357,15 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess } catch (OperationFailureException ofe) { - throw new AMQStoreException("Failed to remove '" + nodeName + "' from group. " + ofe.getMessage(), ofe); + throw new StoreException("Failed to remove '" + nodeName + "' from group. " + ofe.getMessage(), ofe); } catch (DatabaseException e) { - throw new AMQStoreException("Failed to remove '" + nodeName + "' from group. " + e.getMessage(), e); + throw new StoreException("Failed to remove '" + nodeName + "' from group. " + e.getMessage(), e); } } - public void setDesignatedPrimary(boolean isPrimary) throws AMQStoreException + public void setDesignatedPrimary(boolean isPrimary) throws StoreException { try { @@ -385,7 +384,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess } catch (DatabaseException e) { - throw new AMQStoreException("Failed to set '" + _nodeName + "' as designated primary for group. " + e.getMessage(), e); + throw new StoreException("Failed to set '" + _nodeName + "' as designated primary for group. " + e.getMessage(), e); } } @@ -394,7 +393,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess return (ReplicatedEnvironment)getEnvironment(); } - public void updateAddress(String nodeName, String newHostName, int newPort) throws AMQStoreException + public void updateAddress(String nodeName, String newHostName, int newPort) throws StoreException { try { @@ -402,12 +401,12 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess } catch (OperationFailureException ofe) { - throw new AMQStoreException("Failed to update address for '" + nodeName + + throw new StoreException("Failed to update address for '" + nodeName + "' with new host " + newHostName + " and new port " + newPort + ". " + ofe.getMessage(), ofe); } catch (DatabaseException e) { - throw new AMQStoreException("Failed to update address for '" + nodeName + + throw new StoreException("Failed to update address for '" + nodeName + "' with new host " + newHostName + " and new port " + newPort + ". " + e.getMessage(), e); } } @@ -455,7 +454,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess } catch (InterruptedException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java index c9c870b996..acff8e2b21 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java @@ -24,12 +24,12 @@ import java.io.File; import org.apache.log4j.Logger; import org.apache.qpid.server.store.MessageStore; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.StoreFuture; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; -import org.apache.qpid.server.util.ServerScopedRuntimeException; /** * BDBMessageStore implements a persistent {@link MessageStore} using the BDB high performance log. @@ -87,7 +87,7 @@ public class BDBMessageStore extends AbstractBDBMessageStore } catch (InterruptedException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } super.closeInternal(); diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java index 92c4259051..1f05dca41a 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java @@ -25,13 +25,13 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.log4j.Logger; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.StoreFuture; import com.sleepycat.je.CheckpointConfig; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; -import org.apache.qpid.server.util.ServerScopedRuntimeException; public class CommitThreadWrapper { @@ -140,7 +140,7 @@ public class CommitThreadWrapper } catch (InterruptedException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java index b8984c42ca..e3cbeccd6e 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java @@ -25,7 +25,7 @@ import com.sleepycat.bind.tuple.TupleOutput; import com.sleepycat.je.DatabaseException; import org.apache.qpid.framing.FieldTable; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -56,7 +56,7 @@ public class FieldTableEncoding } catch (IOException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java index aa2aa2e2a3..a408732e2f 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java @@ -29,7 +29,7 @@ import org.apache.qpid.server.store.ConfiguredObjectRecord; import com.sleepycat.bind.tuple.TupleBinding; import com.sleepycat.bind.tuple.TupleInput; import com.sleepycat.bind.tuple.TupleOutput; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; @@ -64,7 +64,7 @@ public class ConfiguredObjectBinding extends TupleBinding<ConfiguredObjectRecord catch (IOException e) { //should never happen - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } @@ -80,15 +80,15 @@ public class ConfiguredObjectBinding extends TupleBinding<ConfiguredObjectRecord } catch (JsonMappingException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } catch (JsonGenerationException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } catch (IOException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java index 4cb70c1486..87f8afde4a 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java @@ -40,6 +40,7 @@ import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.FieldTable; import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.server.protocol.v0_8.MessageMetaData; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.StorableMessageMetaData; import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding; import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding; @@ -54,7 +55,6 @@ import com.sleepycat.je.Database; import com.sleepycat.je.DatabaseEntry; import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; -import org.apache.qpid.server.util.ServerScopedRuntimeException; public class UpgradeFrom4To5 extends AbstractStoreUpgrade { @@ -254,7 +254,7 @@ public class UpgradeFrom4To5 extends AbstractStoreUpgrade } else { - throw new ServerScopedRuntimeException("Unable is aborted!"); + throw new StoreException("Unable is aborted!"); } } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java index bba9dbaa74..9b1ab7057b 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java @@ -45,6 +45,7 @@ import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.queue.QueueArgumentsConverter; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding; import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding; import org.apache.qpid.server.util.MapJsonSerializer; @@ -61,7 +62,6 @@ import com.sleepycat.je.Environment; import com.sleepycat.je.LockMode; import com.sleepycat.je.OperationStatus; import com.sleepycat.je.Transaction; -import org.apache.qpid.server.util.ServerScopedRuntimeException; public class UpgradeFrom5To6 extends AbstractStoreUpgrade { @@ -242,7 +242,7 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade return; case ABORT: _logger.error(message); - throw new ServerScopedRuntimeException("Unable to upgrade message " + messageId); + throw new StoreException("Unable to upgrade message " + messageId); } } @@ -596,7 +596,7 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade OperationStatus status = database.put(txn, key, value); if (status != OperationStatus.SUCCESS) { - throw new ServerScopedRuntimeException("Cannot add record into " + database.getDatabaseName() + ":" + status); + throw new StoreException("Cannot add record into " + database.getDatabaseName() + ":" + status); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java index de25c3a6d2..ce00fd1a48 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java @@ -27,7 +27,7 @@ import com.sleepycat.je.DatabaseConfig; import com.sleepycat.je.DatabaseEntry; import com.sleepycat.je.Environment; import com.sleepycat.je.OperationStatus; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; public class UpgradeFrom6To7 extends AbstractStoreUpgrade { @@ -53,7 +53,7 @@ public class UpgradeFrom6To7 extends AbstractStoreUpgrade OperationStatus status = versionDb.put(null, key, value); if (status != OperationStatus.SUCCESS) { - throw new ServerScopedRuntimeException("Error initialising config version: " + status); + throw new StoreException("Error initialising config version: " + status); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java index be6bce4d46..4d536a2f95 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java @@ -24,6 +24,7 @@ import com.sleepycat.je.Cursor; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.berkeleydb.AbstractBDBMessageStore; import com.sleepycat.bind.tuple.IntegerBinding; @@ -34,7 +35,6 @@ import com.sleepycat.je.DatabaseEntry; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.Environment; import com.sleepycat.je.OperationStatus; -import org.apache.qpid.server.util.ServerScopedRuntimeException; public class Upgrader { @@ -75,7 +75,7 @@ public class Upgrader int version = getSourceVersion(versionDb); if(version > AbstractBDBMessageStore.VERSION) { - throw new ServerScopedRuntimeException("Database version " + version + throw new StoreException("Database version " + version + " is higher than the most recent known version: " + AbstractBDBMessageStore.VERSION); } @@ -150,27 +150,27 @@ public class Upgrader } catch (ClassNotFoundException e) { - throw new ServerScopedRuntimeException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + toVersion, e); } catch (NoSuchMethodException e) { - throw new ServerScopedRuntimeException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + toVersion, e); } catch (InvocationTargetException e) { - throw new ServerScopedRuntimeException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + toVersion, e); } catch (InstantiationException e) { - throw new ServerScopedRuntimeException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + toVersion, e); } catch (IllegalAccessException e) { - throw new ServerScopedRuntimeException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version" + toVersion, e); } } diff --git a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java index 3278c50b52..eb3b665242 100644 --- a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java +++ b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java @@ -25,7 +25,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.List; import java.util.UUID; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.ContentHeaderBody; @@ -361,7 +361,7 @@ public class BDBMessageStoreTest extends MessageStoreTest bdbStore.getMessageMetaData(messageid_0_8); fail("No exception thrown when message id not found getting metadata"); } - catch (AMQStoreException e) + catch (StoreException e) { // pass since exception expected } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java index 4897983caf..d6c46ee7d9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java @@ -28,7 +28,7 @@ import java.util.UUID; import org.apache.qpid.server.configuration.ConfigurationEntry; import org.apache.qpid.server.configuration.ConfigurationEntryStore; import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; public class JsonConfigurationEntryStore extends MemoryConfigurationEntryStore { @@ -50,7 +50,7 @@ public class JsonConfigurationEntryStore extends MemoryConfigurationEntryStore { if(!_storeFile.delete()) { - throw new ServerScopedRuntimeException("Unable to overwrite existing configuration store file as requested: " + storeLocation); + throw new StoreException("Unable to overwrite existing configuration store file as requested: " + storeLocation); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java index 076c86fcba..e030d50e56 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java @@ -37,7 +37,7 @@ import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; public class StoreConfigurationChangeListener implements ConfigurationChangeListener { @@ -149,7 +149,7 @@ public class StoreConfigurationChangeListener implements ConfigurationChangeList if (interfaces.size() == 0) { - throw new ServerScopedRuntimeException("Can not identify the configured object type"); + throw new StoreException("Can not identify the configured object type"); } if (interfaces.size() == 1) @@ -186,7 +186,7 @@ public class StoreConfigurationChangeListener implements ConfigurationChangeList } else { - throw new ServerScopedRuntimeException("Can not identify the configured object type as an it implements" + throw new StoreException("Can not identify the configured object type as an it implements" + " more than one configured object interfaces: " + interfaces); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java index dd9f5ebe51..740d57f603 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java @@ -47,7 +47,6 @@ import org.apache.qpid.server.message.EnqueueableMessage; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.plugin.MessageMetaDataType; import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; @@ -229,7 +228,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException("Error encountered when restoring message data from " + + throw new StoreException("Error encountered when restoring message data from " + "persistent store ", e); } } @@ -242,7 +241,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException("Error encountered when restoring distributed transaction " + + throw new StoreException("Error encountered when restoring distributed transaction " + "data from persistent store ", e); } @@ -261,11 +260,11 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (ClassNotFoundException e) { - throw new ServerScopedRuntimeException("Unable to configure message store ", e); + throw new StoreException("Unable to configure message store ", e); } catch (SQLException e) { - throw new ServerScopedRuntimeException("Unable to configure message store ", e); + throw new StoreException("Unable to configure message store ", e); } } @@ -283,7 +282,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC { if(!rs.next()) { - throw new ServerScopedRuntimeException(DB_VERSION_TABLE_NAME + " does not contain the database version"); + throw new StoreException(DB_VERSION_TABLE_NAME + " does not contain the database version"); } int version = rs.getInt(1); switch (version) @@ -293,7 +292,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC case DB_VERSION: return; default: - throw new ServerScopedRuntimeException("Unknown database version: " + version); + throw new StoreException("Unknown database version: " + version); } } finally @@ -627,11 +626,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException("Error recovering persistent state: " + e.getMessage(), e); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("Error recovering persistent state: " + e.getMessage(), e); + throw new StoreException("Error recovering persistent state: " + e.getMessage(), e); } } @@ -785,14 +780,14 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e); + throw new StoreException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e); } } @Override - public void create(UUID id, String type, Map<String,Object> attributes) throws AMQStoreException + public void create(UUID id, String type, Map<String,Object> attributes) throws StoreException { if (_stateManager.isInState(State.ACTIVE)) { @@ -802,17 +797,17 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } @Override - public void remove(UUID id, String type) throws AMQStoreException + public void remove(UUID id, String type) throws StoreException { int results = removeConfiguredObject(id); if (results == 0) { - throw new AMQStoreException(type + " with id " + id + " not found"); + throw new StoreException(type + " with id " + id + " not found"); } } @Override - public void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException + public void update(UUID id, String type, Map<String, Object> attributes) throws StoreException { if (_stateManager.isInState(State.ACTIVE)) { @@ -881,7 +876,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC protected abstract Connection getConnection() throws SQLException; - private byte[] convertStringMapToBytes(final Map<String, String> arguments) throws AMQStoreException + private byte[] convertStringMapToBytes(final Map<String, String> arguments) throws StoreException { byte[] argumentBytes; if(arguments == null) @@ -906,7 +901,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC catch (IOException e) { // This should never happen - throw new AMQStoreException(e.getMessage(), e); + throw new StoreException(e.getMessage(), e); } argumentBytes = bos.toByteArray(); } @@ -919,7 +914,8 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC return new JDBCTransaction(); } - public void enqueueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws AMQStoreException + public void enqueueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws + StoreException { Connection conn = connWrapper.getConnection(); @@ -956,13 +952,14 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC catch (SQLException e) { getLogger().error("Failed to enqueue: " + e.getMessage(), e); - throw new AMQStoreException("Error writing enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + " with id " + queue.getId() + throw new StoreException("Error writing enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + " with id " + queue.getId() + " to database", e); } } - public void dequeueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws AMQStoreException + public void dequeueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws + StoreException { Connection conn = connWrapper.getConnection(); @@ -981,7 +978,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC if(results != 1) { - throw new AMQStoreException("Unable to find message with id " + messageId + " on queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + throw new StoreException("Unable to find message with id " + messageId + " on queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + " with id " + queue.getId()); } @@ -1002,14 +999,14 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC catch (SQLException e) { getLogger().error("Failed to dequeue: " + e.getMessage(), e); - throw new AMQStoreException("Error deleting enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + throw new StoreException("Error deleting enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + " with id " + queue.getId() + " from database", e); } } private void removeXid(ConnectionWrapper connWrapper, long format, byte[] globalId, byte[] branchId) - throws AMQStoreException + throws StoreException { Connection conn = connWrapper.getConnection(); @@ -1028,7 +1025,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC if(results != 1) { - throw new AMQStoreException("Unable to find message with xid"); + throw new StoreException("Unable to find message with xid"); } } finally @@ -1054,13 +1051,13 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC catch (SQLException e) { getLogger().error("Failed to dequeue: " + e.getMessage(), e); - throw new AMQStoreException("Error deleting enqueued message with xid", e); + throw new StoreException("Error deleting enqueued message with xid", e); } } private void recordXid(ConnectionWrapper connWrapper, long format, byte[] globalId, byte[] branchId, - Transaction.Record[] enqueues, Transaction.Record[] dequeues) throws AMQStoreException + Transaction.Record[] enqueues, Transaction.Record[] dequeues) throws StoreException { Connection conn = connWrapper.getConnection(); @@ -1121,7 +1118,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC catch (SQLException e) { getLogger().error("Failed to enqueue: " + e.getMessage(), e); - throw new AMQStoreException("Error writing xid ", e); + throw new StoreException("Error writing xid ", e); } } @@ -1147,7 +1144,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } - public void commitTran(ConnectionWrapper connWrapper) throws AMQStoreException + public void commitTran(ConnectionWrapper connWrapper) throws StoreException { try @@ -1164,7 +1161,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new AMQStoreException("Error commit tx: " + e.getMessage(), e); + throw new StoreException("Error commit tx: " + e.getMessage(), e); } finally { @@ -1172,17 +1169,17 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } } - public StoreFuture commitTranAsync(ConnectionWrapper connWrapper) throws AMQStoreException + public StoreFuture commitTranAsync(ConnectionWrapper connWrapper) throws StoreException { commitTran(connWrapper); return StoreFuture.IMMEDIATE_FUTURE; } - public void abortTran(ConnectionWrapper connWrapper) throws AMQStoreException + public void abortTran(ConnectionWrapper connWrapper) throws StoreException { if (connWrapper == null) { - throw new AMQStoreException("Fatal internal error: transactional context is empty at abortTran"); + throw new StoreException("Fatal internal error: transactional context is empty at abortTran"); } if (getLogger().isDebugEnabled()) @@ -1198,7 +1195,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new AMQStoreException("Error aborting transaction: " + e.getMessage(), e); + throw new StoreException("Error aborting transaction: " + e.getMessage(), e); } } @@ -1237,7 +1234,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC if(result == 0) { - throw new ServerScopedRuntimeException("Unable to add meta data for message " +messageId); + throw new StoreException("Unable to add meta data for message " +messageId); } } finally @@ -1562,7 +1559,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } else { - throw new ServerScopedRuntimeException("Meta data not found for message with id " + messageId); + throw new StoreException("Meta data not found for message with id " + messageId); } } finally @@ -1608,7 +1605,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC catch (SQLException e) { closeConnection(conn); - throw new ServerScopedRuntimeException("Error adding content for message " + messageId + ": " + e.getMessage(), e); + throw new StoreException("Error adding content for message " + messageId + ": " + e.getMessage(), e); } finally { @@ -1640,7 +1637,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC if (offset > size) { - throw new ServerScopedRuntimeException("Offset " + offset + " is greater than message size " + size + throw new StoreException("Offset " + offset + " is greater than message size " + size + " for message id " + messageId + "!"); } @@ -1659,7 +1656,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException("Error retrieving content from offset " + offset + " for message " + messageId + ": " + e.getMessage(), e); + throw new StoreException("Error retrieving content from offset " + offset + " for message " + messageId + ": " + e.getMessage(), e); } finally { @@ -1691,7 +1688,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } } @@ -1707,100 +1704,51 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException("Exception on enqueuing message into message store" + _messageId, e); + throw new StoreException("Exception on enqueuing message into message store" + _messageId, e); } } _storeSizeIncrease += storedMessage.getMetaData().getContentSize(); - try - { - AbstractJDBCMessageStore.this.enqueueMessage(_connWrapper, queue, message.getMessageNumber()); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractJDBCMessageStore.this.enqueueMessage(_connWrapper, queue, message.getMessageNumber()); + } @Override public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) { - try - { - AbstractJDBCMessageStore.this.dequeueMessage(_connWrapper, queue, message.getMessageNumber()); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } - + AbstractJDBCMessageStore.this.dequeueMessage(_connWrapper, queue, message.getMessageNumber()); } @Override public void commitTran() { - try - { - AbstractJDBCMessageStore.this.commitTran(_connWrapper); - storedSizeChange(_storeSizeIncrease); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractJDBCMessageStore.this.commitTran(_connWrapper); + storedSizeChange(_storeSizeIncrease); } @Override public StoreFuture commitTranAsync() { - try - { - StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper); - storedSizeChange(_storeSizeIncrease); - return storeFuture; - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper); + storedSizeChange(_storeSizeIncrease); + return storeFuture; } @Override public void abortTran() { - try - { - AbstractJDBCMessageStore.this.abortTran(_connWrapper); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractJDBCMessageStore.this.abortTran(_connWrapper); } @Override public void removeXid(long format, byte[] globalId, byte[] branchId) { - try - { - AbstractJDBCMessageStore.this.removeXid(_connWrapper, format, globalId, branchId); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractJDBCMessageStore.this.removeXid(_connWrapper, format, globalId, branchId); } @Override public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues) { - try - { - AbstractJDBCMessageStore.this.recordXid(_connWrapper, format, globalId, branchId, enqueues, dequeues); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem has been encountered with the message store", e); - } + AbstractJDBCMessageStore.this.recordXid(_connWrapper, format, globalId, branchId, enqueues, dequeues); } } @@ -1847,7 +1795,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } _metaDataRef = new SoftReference<StorableMessageMetaData>(metaData); } @@ -1933,7 +1881,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC { getLogger().debug("Error when trying to flush message " + _messageId + " to store: " + e); } - throw new ServerScopedRuntimeException(e); + throw new StoreException(e); } finally { @@ -2015,7 +1963,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC _eventManager.addEventListener(eventListener, events); } - private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws AMQStoreException + private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws StoreException { if (_stateManager.isInState(State.ACTIVE)) { @@ -2075,24 +2023,24 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (JsonMappingException e) { - throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); + throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); } catch (JsonGenerationException e) { - throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); + throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); } catch (IOException e) { - throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); + throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); } catch (SQLException e) { - throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); + throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e); } } } - private int removeConfiguredObject(UUID id) throws AMQStoreException + private int removeConfiguredObject(UUID id) throws StoreException { int results = 0; try @@ -2109,12 +2057,12 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new AMQStoreException("Error deleting of configured object with id " + id + " from database: " + e.getMessage(), e); + throw new StoreException("Error deleting of configured object with id " + id + " from database: " + e.getMessage(), e); } return results; } - public UUID[] removeConfiguredObjects(UUID... objects) throws AMQStoreException + public UUID[] removeConfiguredObjects(UUID... objects) throws StoreException { Collection<UUID> removed = new ArrayList<UUID>(objects.length); try @@ -2138,7 +2086,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new AMQStoreException("Error deleting of configured objects " + Arrays.asList(objects) + " from database: " + e.getMessage(), e); + throw new StoreException("Error deleting of configured objects " + Arrays.asList(objects) + " from database: " + e.getMessage(), e); } return removed.toArray(new UUID[removed.size()]); } @@ -2158,7 +2106,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC return results; } - private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws AMQStoreException + private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws StoreException { if (_stateManager.isInState(State.ACTIVE)) { @@ -2176,18 +2124,18 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); + throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); } } } @Override - public void update(ConfiguredObjectRecord... records) throws AMQStoreException + public void update(ConfiguredObjectRecord... records) throws StoreException { update(false, records); } - public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException + public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException { if (_stateManager.isInState(State.ACTIVE) || _stateManager.isInState(State.ACTIVATING)) { @@ -2209,7 +2157,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (SQLException e) { - throw new AMQStoreException("Error updating configured objects in database: " + e.getMessage(), e); + throw new StoreException("Error updating configured objects in database: " + e.getMessage(), e); } } @@ -2219,7 +2167,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC private void updateConfiguredObject(ConfiguredObjectRecord configuredObject, boolean createIfNecessary, Connection conn) - throws SQLException, AMQStoreException + throws SQLException, StoreException { PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT); try @@ -2286,15 +2234,15 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (JsonMappingException e) { - throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); + throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); } catch (JsonGenerationException e) { - throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); + throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); } catch (IOException e) { - throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); + throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); } finally { @@ -2303,7 +2251,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } - private ConfiguredObjectRecord loadConfiguredObject(final UUID id) throws AMQStoreException + private ConfiguredObjectRecord loadConfiguredObject(final UUID id) throws StoreException { ConfiguredObjectRecord result = null; try @@ -2343,28 +2291,29 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (JsonMappingException e) { - throw new AMQStoreException("Error loading of configured object with id " + id + " from database: " + throw new StoreException("Error loading of configured object with id " + id + " from database: " + e.getMessage(), e); } catch (JsonParseException e) { - throw new AMQStoreException("Error loading of configured object with id " + id + " from database: " + throw new StoreException("Error loading of configured object with id " + id + " from database: " + e.getMessage(), e); } catch (IOException e) { - throw new AMQStoreException("Error loading of configured object with id " + id + " from database: " + throw new StoreException("Error loading of configured object with id " + id + " from database: " + e.getMessage(), e); } catch (SQLException e) { - throw new AMQStoreException("Error loading of configured object with id " + id + " from database: " + throw new StoreException("Error loading of configured object with id " + id + " from database: " + e.getMessage(), e); } return result; } - private void loadConfiguredObjects(ConfigurationRecoveryHandler recoveryHandler) throws SQLException, AMQStoreException + private void loadConfiguredObjects(ConfigurationRecoveryHandler recoveryHandler) throws SQLException, + StoreException { Connection conn = newAutoCommitConnection(); @@ -2388,15 +2337,15 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } catch (JsonMappingException e) { - throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e); + throw new StoreException("Error recovering persistent state: " + e.getMessage(), e); } catch (JsonParseException e) { - throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e); + throw new StoreException("Error recovering persistent state: " + e.getMessage(), e); } catch (IOException e) { - throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e); + throw new StoreException("Error recovering persistent state: " + e.getMessage(), e); } finally { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java index ced677b005..3c5fb44d23 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java @@ -124,21 +124,13 @@ public class DurableConfigurationRecoverer implements ConfigurationRecoveryHandl } } - try + if(!updates.isEmpty()) { - if(!updates.isEmpty()) - { - _store.update(true,updates.toArray(new ConfiguredObjectRecord[updates.size()])); - } - if(!deletes.isEmpty()) - { - _store.removeConfiguredObjects(deletes.toArray(new UUID[deletes.size()])); - } + _store.update(true,updates.toArray(new ConfiguredObjectRecord[updates.size()])); } - catch (AMQStoreException e) + if(!deletes.isEmpty()) { - // TODO better exception - throw new ServerScopedRuntimeException("Unable to update config store when upgrading"); + _store.removeConfiguredObjects(deletes.toArray(new UUID[deletes.size()])); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java index 6c90247ebc..e552b3e073 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java @@ -54,9 +54,9 @@ public interface DurableConfigurationStore * @param type The type of the object to persist * @param attributes the attributes of the object to persist * - * @throws AMQStoreException If the operation fails for any reason. + * @throws StoreException If the operation fails for any reason. */ - void create(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException; + void create(UUID id, String type, Map<String, Object> attributes) throws StoreException; /** * Removes the specified persistent configured object. @@ -64,11 +64,11 @@ public interface DurableConfigurationStore * @param id The id of the object to remove. * @param type The type of the object to remove * - * @throws AMQStoreException If the operation fails for any reason. + * @throws StoreException If the operation fails for any reason. */ - void remove(UUID id, String type) throws AMQStoreException; + void remove(UUID id, String type) throws StoreException; - public UUID[] removeConfiguredObjects(UUID... objects) throws AMQStoreException; + public UUID[] removeConfiguredObjects(UUID... objects) throws StoreException; /** @@ -79,13 +79,13 @@ public interface DurableConfigurationStore * @param type The type of the object to update * @param attributes the updated attributes * - * @throws AMQStoreException If the operation fails for any reason. + * @throws StoreException If the operation fails for any reason. */ - void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException; + void update(UUID id, String type, Map<String, Object> attributes) throws StoreException; - public void update(ConfiguredObjectRecord... records) throws AMQStoreException; - public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException; + public void update(ConfiguredObjectRecord... records) throws StoreException; + public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException; void close() throws Exception; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java index 50837d433e..fc5806ccce 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java @@ -69,14 +69,7 @@ public class DurableConfigurationStoreHelper } } - try - { - store.update(queue.getId(), QUEUE, attributesMap); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + store.update(queue.getId(), QUEUE, attributesMap); } public static void createQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue) @@ -97,26 +90,12 @@ public class DurableConfigurationStoreHelper attributesMap.put(attrName, queue.getAttribute(attrName)); } } - try - { - store.create(queue.getId(), QUEUE, attributesMap); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + store.create(queue.getId(), QUEUE, attributesMap); } public static void removeQueue(DurableConfigurationStore store, AMQQueue queue) { - try - { - store.remove(queue.getId(), QUEUE); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + store.remove(queue.getId(), QUEUE); } public static void createExchange(DurableConfigurationStore store, org.apache.qpid.server.exchange.Exchange exchange) @@ -126,28 +105,15 @@ public class DurableConfigurationStoreHelper attributesMap.put(Exchange.TYPE, exchange.getTypeName()); attributesMap.put(Exchange.LIFETIME_POLICY, exchange.isAutoDelete() ? LifetimePolicy.AUTO_DELETE.name() : LifetimePolicy.PERMANENT.name()); - try - { - store.create(exchange.getId(), EXCHANGE, attributesMap); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + + store.create(exchange.getId(), EXCHANGE, attributesMap); } public static void removeExchange(DurableConfigurationStore store, org.apache.qpid.server.exchange.Exchange exchange) { - try - { - store.remove(exchange.getId(), EXCHANGE); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + store.remove(exchange.getId(), EXCHANGE); } public static void createBinding(DurableConfigurationStore store, org.apache.qpid.server.binding.Binding binding) @@ -161,27 +127,14 @@ public class DurableConfigurationStoreHelper { attributesMap.put(Binding.ARGUMENTS, arguments); } - try - { - store.create(binding.getId(), BINDING, attributesMap); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + + store.create(binding.getId(), BINDING, attributesMap); } public static void removeBinding(DurableConfigurationStore store, org.apache.qpid.server.binding.Binding binding) { - try - { - store.remove(binding.getId(), BINDING); - } - catch (AMQStoreException e) - { - throw new ServerScopedRuntimeException("A problem was encountered with the configuration store ", e); - } + store.remove(binding.getId(), BINDING); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java index c80158965c..9fbfba4872 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java @@ -38,7 +38,6 @@ import java.util.UUID; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; @@ -75,7 +74,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore Object storePathAttr = virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH); if(!(storePathAttr instanceof String)) { - throw new ServerScopedRuntimeException("Cannot determine path for configuration storage"); + throw new StoreException("Cannot determine path for configuration storage"); } _directoryName = (String) storePathAttr; _configFileName = _name + ".json"; @@ -94,7 +93,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore } catch (IOException e) { - throw new ServerScopedRuntimeException("Could not write configuration file " + newFile, e); + throw new StoreException("Could not write configuration file " + newFile, e); } } else @@ -126,14 +125,14 @@ public class JsonFileConfigStore implements DurableConfigurationStore { if(!toFile.delete()) { - throw new ServerScopedRuntimeException("Cannot delete file " + toFile.getAbsolutePath()); + throw new StoreException("Cannot delete file " + toFile.getAbsolutePath()); } } File fromFile = new File(_directoryName, fromFileName); if(!fromFile.renameTo(toFile)) { - throw new ServerScopedRuntimeException("Cannot rename file " + fromFile.getAbsolutePath() + " to " + toFile.getAbsolutePath()); + throw new StoreException("Cannot rename file " + fromFile.getAbsolutePath() + " to " + toFile.getAbsolutePath()); } } @@ -158,7 +157,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore } catch (IOException ioe) { - throw new ServerScopedRuntimeException("Cannot create the lock file " + lockFile.getName(), ioe); + throw new StoreException("Cannot create the lock file " + lockFile.getName(), ioe); } catch(OverlappingFileLockException e) { @@ -167,7 +166,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore if(_fileLock == null) { - throw new ServerScopedRuntimeException("Cannot get lock on file " + lockFile.getAbsolutePath() + ". Is another instance running?"); + throw new StoreException("Cannot get lock on file " + lockFile.getAbsolutePath() + ". Is another instance running?"); } } @@ -180,18 +179,18 @@ public class JsonFileConfigStore implements DurableConfigurationStore { if(!dir.canWrite()) { - throw new ServerScopedRuntimeException("Configuration path " + directoryName + " exists, but is not writable"); + throw new StoreException("Configuration path " + directoryName + " exists, but is not writable"); } } else { - throw new ServerScopedRuntimeException("Configuration path " + directoryName + " exists, but is not a directory"); + throw new StoreException("Configuration path " + directoryName + " exists, but is not a directory"); } } else if(!dir.mkdirs()) { - throw new ServerScopedRuntimeException("Cannot create directory " + directoryName); + throw new StoreException("Cannot create directory " + directoryName); } } @@ -231,15 +230,15 @@ public class JsonFileConfigStore implements DurableConfigurationStore } catch (JsonMappingException e) { - throw new ServerScopedRuntimeException("Cannot parse the configuration file " + configFile, e); + throw new StoreException("Cannot parse the configuration file " + configFile, e); } catch (JsonParseException e) { - throw new ServerScopedRuntimeException("Cannot parse the configuration file " + configFile, e); + throw new StoreException("Cannot parse the configuration file " + configFile, e); } catch (IOException e) { - throw new ServerScopedRuntimeException("Could not load the configuration file " + configFile, e); + throw new StoreException("Could not load the configuration file " + configFile, e); } } @@ -312,15 +311,16 @@ public class JsonFileConfigStore implements DurableConfigurationStore } @Override - public synchronized void create(final UUID id, final String type, final Map<String, Object> attributes) throws AMQStoreException + public synchronized void create(final UUID id, final String type, final Map<String, Object> attributes) throws + StoreException { if(_objectsById.containsKey(id)) { - throw new AMQStoreException("Object with id " + id + " already exists"); + throw new StoreException("Object with id " + id + " already exists"); } else if(!CLASS_NAME_MAPPING.containsKey(type)) { - throw new AMQStoreException("Cannot create object of unknown type " + type); + throw new StoreException("Cannot create object of unknown type " + type); } else { @@ -377,7 +377,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore } catch (IOException e) { - throw new ServerScopedRuntimeException("Cannot save to store", e); + throw new StoreException("Cannot save to store", e); } } @@ -423,13 +423,13 @@ public class JsonFileConfigStore implements DurableConfigurationStore } @Override - public void remove(final UUID id, final String type) throws AMQStoreException + public void remove(final UUID id, final String type) throws StoreException { removeConfiguredObjects(id); } @Override - public synchronized UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException + public synchronized UUID[] removeConfiguredObjects(final UUID... objects) throws StoreException { List<UUID> removedIds = new ArrayList<UUID>(); for(UUID id : objects) @@ -446,20 +446,21 @@ public class JsonFileConfigStore implements DurableConfigurationStore } @Override - public void update(final UUID id, final String type, final Map<String, Object> attributes) throws AMQStoreException + public void update(final UUID id, final String type, final Map<String, Object> attributes) throws + StoreException { update(false, new ConfiguredObjectRecord(id, type, attributes)); } @Override - public void update(final ConfiguredObjectRecord... records) throws AMQStoreException + public void update(final ConfiguredObjectRecord... records) throws StoreException { update(false, records); } @Override public void update(final boolean createIfNecessary, final ConfiguredObjectRecord... records) - throws AMQStoreException + throws StoreException { for(ConfiguredObjectRecord record : records) { @@ -471,18 +472,18 @@ public class JsonFileConfigStore implements DurableConfigurationStore final ConfiguredObjectRecord existingRecord = _objectsById.get(id); if(!type.equals(existingRecord.getType())) { - throw new AMQStoreException("Cannot change the type of record " + id + " from type " + throw new StoreException("Cannot change the type of record " + id + " from type " + existingRecord.getType() + " to type " + type); } } else if(!createIfNecessary) { - throw new AMQStoreException("Cannot update record with id " + id + throw new StoreException("Cannot update record with id " + id + " of type " + type + " as it does not exist"); } else if(!CLASS_NAME_MAPPING.containsKey(type)) { - throw new AMQStoreException("Cannot update record of unknown type " + type); + throw new StoreException("Cannot update record of unknown type " + type); } } for(ConfiguredObjectRecord record : records) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AMQStoreException.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/StoreException.java index 98ed01efb4..d63e07810d 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AMQStoreException.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/StoreException.java @@ -20,28 +20,22 @@ */ package org.apache.qpid.server.store; +import org.apache.qpid.server.util.ServerScopedRuntimeException; -/** - * StoreException is a specific type of internal error relating to errors in the message store, such as {@link java.sql.SQLException}. - */ -public class AMQStoreException extends Exception +public class StoreException extends ServerScopedRuntimeException { - /** serialVersionUID */ - private static final long serialVersionUID = 2859681947490637496L; + public StoreException(final String message) + { + super(message); + } - /** - * Creates an exception with an optional message and optional underlying cause. - * - * @param msg The exception message. May be null if not to be set. - * @param cause The underlying cause of the exception. May be null if not to be set. - */ - public AMQStoreException(String msg, Throwable cause) + public StoreException(final String message, final Throwable cause) { - super(((msg == null) ? "Store error" : msg), cause); + super(message, cause); } - - public AMQStoreException(String msg) + + public StoreException(final Throwable cause) { - this(msg, null); + super(cause); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java index fc16f8a367..e4a89b23c0 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java @@ -28,13 +28,12 @@ import java.util.Map; import java.util.concurrent.ScheduledFuture; import org.apache.log4j.Logger; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.message.EnqueueableMessage; import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.Transaction; import org.apache.qpid.server.store.TransactionLogResource; -import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.transport.Xid; @@ -147,15 +146,7 @@ public class DtxBranch } setState(State.TIMEDOUT); - try - { - rollback(); - } - catch (AMQStoreException e) - { - _logger.error("Unexpected error when attempting to rollback DtxBranch "+ _xid + " due to timeout", e); - throw new ServerScopedRuntimeException(e); - } + rollback(); } }); } @@ -227,7 +218,7 @@ public class DtxBranch return false; } - public void prepare() throws AMQStoreException + public void prepare() throws StoreException { if(_logger.isDebugEnabled()) { @@ -245,7 +236,7 @@ public class DtxBranch prePrepareTransaction(); } - public synchronized void rollback() throws AMQStoreException + public synchronized void rollback() throws StoreException { if(_logger.isDebugEnabled()) { @@ -287,7 +278,7 @@ public class DtxBranch _postTransactionActions.clear(); } - public void commit() throws AMQStoreException + public void commit() throws StoreException { if(_logger.isDebugEnabled()) { @@ -328,7 +319,7 @@ public class DtxBranch _postTransactionActions.clear(); } - public void prePrepareTransaction() throws AMQStoreException + public void prePrepareTransaction() throws StoreException { _transaction = _store.newTransaction(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java index 90604b643e..2ac8687411 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.transport.Xid; @@ -117,7 +117,7 @@ public class DtxRegistry } public synchronized void commit(Xid id, boolean onePhase) - throws IncorrectDtxStateException, UnknownDtxBranchException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException + throws IncorrectDtxStateException, UnknownDtxBranchException, StoreException, RollbackOnlyDtxException, TimeoutDtxException { DtxBranch branch = getBranch(id); if(branch != null) @@ -164,7 +164,7 @@ public class DtxRegistry public synchronized void prepare(Xid id) throws UnknownDtxBranchException, - IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException + IncorrectDtxStateException, StoreException, RollbackOnlyDtxException, TimeoutDtxException { DtxBranch branch = getBranch(id); if(branch != null) @@ -207,7 +207,7 @@ public class DtxRegistry public synchronized void rollback(Xid id) throws IncorrectDtxStateException, UnknownDtxBranchException, - AMQStoreException, TimeoutDtxException + StoreException, TimeoutDtxException { DtxBranch branch = getBranch(id); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java index eac118ba8a..302c61e491 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java @@ -26,7 +26,6 @@ import java.util.TreeMap; import java.util.UUID; import org.apache.log4j.Logger; -import org.apache.qpid.server.store.AMQStoreException; import org.apache.qpid.server.exchange.ExchangeFactory; import org.apache.qpid.server.exchange.ExchangeRegistry; import org.apache.qpid.server.logging.actors.CurrentActor; @@ -46,7 +45,6 @@ import org.apache.qpid.server.store.TransactionLogResource; import org.apache.qpid.server.txn.DtxBranch; import org.apache.qpid.server.txn.DtxRegistry; import org.apache.qpid.server.txn.ServerTransaction; -import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.transport.Xid; import org.apache.qpid.transport.util.Functions; @@ -218,17 +216,8 @@ public class VirtualHostConfigRecoveryHandler implements } - try - { - branch.setState(DtxBranch.State.PREPARED); - branch.prePrepareTransaction(); - } - catch (AMQStoreException e) - { - _logger.error("Unexpected database exception when attempting to prepare a recovered XA transaction " + - xidAsString(id), e); - throw new ServerScopedRuntimeException(e); - } + branch.setState(DtxBranch.State.PREPARED); + branch.prePrepareTransaction(); } private static StringBuilder xidAsString(Xid id) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index 963309592c..8b66e7d82f 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -348,7 +348,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest private AMQQueue createTestQueue(String queueName, String queueOwner, boolean exclusive, - final Map<String, Object> arguments) throws AMQStoreException + final Map<String, Object> arguments) throws StoreException { return createTestQueue(queueName, queueOwner, exclusive, null, arguments); } @@ -357,7 +357,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest String queueOwner, boolean exclusive, Exchange alternateExchange, - final Map<String, Object> arguments) throws AMQStoreException + final Map<String, Object> arguments) throws StoreException { AMQQueue queue = mock(AMQQueue.class); when(queue.getName()).thenReturn(queueName); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java index 0d3b2c637d..224a22687f 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java @@ -198,7 +198,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase _store.create(UUID.randomUUID(), "wibble", Collections.<String, Object>emptyMap()); fail("Should not be able to create instance of type wibble"); } - catch (AMQStoreException e) + catch (StoreException e) { // pass } @@ -214,7 +214,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase _store.create(id, "Exchange", Collections.<String, Object>emptyMap()); fail("Should not be able to create two objects with same id"); } - catch (AMQStoreException e) + catch (StoreException e) { // pass } @@ -234,7 +234,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase _store.update(id, "Exchange", Collections.<String, Object>emptyMap()); fail("Should not be able to update object to different type"); } - catch (AMQStoreException e) + catch (StoreException e) { // pass } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java index ffd153b790..223e2c5218 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java @@ -27,7 +27,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; import java.util.UUID; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.exchange.DirectExchange; import org.apache.qpid.server.exchange.Exchange; @@ -404,7 +404,7 @@ public class DurableConfigurationRecovererTest extends QpidTestCase assertEquals(customExchange, _vhost.getQueue(queueId).getAlternateExchange()); } - private void verifyCorrectUpdates(final ConfiguredObjectRecord[] expected) throws AMQStoreException + private void verifyCorrectUpdates(final ConfiguredObjectRecord[] expected) throws StoreException { doAnswer(new Answer() { diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java index f94026d0af..ff7ce0a79d 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java @@ -213,12 +213,12 @@ public class ServerConnection extends Connection implements AMQConnectionModel, ex.setDescription(message); ((ServerSession)session).invoke(ex); - ((ServerSession)session).close(cause, message); + session.close(cause, message); } public LogSubject getLogSubject() { - return (LogSubject) this; + return this; } @Override diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java index 7e2d614b99..0e6b4d3b08 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java @@ -41,7 +41,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import javax.security.auth.Subject; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.server.TransactionTimeoutHelper; import org.apache.qpid.server.TransactionTimeoutHelper.CloseAction; @@ -492,14 +492,14 @@ public class ServerSession extends Session public void prepareDtx(Xid xid) throws UnknownDtxBranchException, - IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException + IncorrectDtxStateException, StoreException, RollbackOnlyDtxException, TimeoutDtxException { getVirtualHost().getDtxRegistry().prepare(xid); } public void commitDtx(Xid xid, boolean onePhase) throws UnknownDtxBranchException, - IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException + IncorrectDtxStateException, StoreException, RollbackOnlyDtxException, TimeoutDtxException { getVirtualHost().getDtxRegistry().commit(xid, onePhase); } @@ -507,7 +507,7 @@ public class ServerSession extends Session public void rollbackDtx(Xid xid) throws UnknownDtxBranchException, - IncorrectDtxStateException, AMQStoreException, TimeoutDtxException + IncorrectDtxStateException, StoreException, TimeoutDtxException { getVirtualHost().getDtxRegistry().rollback(xid); } diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java index 3961bcb080..1bd50533ed 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java @@ -25,7 +25,7 @@ import java.util.LinkedHashMap; import java.util.UUID; import org.apache.log4j.Logger; -import org.apache.qpid.server.store.AMQStoreException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.exchange.AMQUnknownExchangeType; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.exchange.HeadersExchange; @@ -558,9 +558,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage()); } - catch(AMQStoreException e) + catch(StoreException e) { exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage()); + throw e; } } @@ -626,9 +627,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage()); } - catch(AMQStoreException e) + catch(StoreException e) { exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage()); + throw e; } } @@ -667,9 +669,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage()); } - catch(AMQStoreException e) + catch(StoreException e) { exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage()); + throw e; } } diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java index d32ea49e60..5d56329c20 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java @@ -40,7 +40,7 @@ import org.apache.qpid.server.store.Event; import org.apache.qpid.server.store.EventListener; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.MessageStoreConstants; -import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.util.FileUtils; /** @@ -118,7 +118,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa else { getLogger().error("Exception whilst shutting down the store: " + e); - throw new ServerScopedRuntimeException("Error closing message store", e); + throw new StoreException("Error closing message store", e); } } } @@ -308,7 +308,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa catch (SQLException e) { closeConnection(conn); - throw new ServerScopedRuntimeException("Exception while processing store size change", e); + throw new StoreException("Exception while processing store size change", e); } } } @@ -360,7 +360,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa catch (SQLException e) { closeConnection(conn); - throw new ServerScopedRuntimeException("Error reducing on disk size", e); + throw new StoreException("Error reducing on disk size", e); } finally { @@ -408,7 +408,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa catch (SQLException e) { closeConnection(conn); - throw new ServerScopedRuntimeException("Error establishing on disk size", e); + throw new StoreException("Error establishing on disk size", e); } finally { diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java index 3fac83f5a3..621759ef85 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java @@ -34,9 +34,9 @@ import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory; import org.apache.qpid.server.store.AbstractJDBCMessageStore; import org.apache.qpid.server.store.MessageStore; +import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.Transaction; -import org.apache.qpid.server.util.ServerScopedRuntimeException; /** * An implementation of a {@link org.apache.qpid.server.store.MessageStore} that uses a JDBC database as the persistence @@ -265,7 +265,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag } catch (SQLException e) { - throw new ServerScopedRuntimeException("Unable to close connection provider ", e); + throw new StoreException("Unable to close connection provider ", e); } } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java index 093cd6a200..db1d5d9327 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java @@ -186,7 +186,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore @Override - public void create(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException + public void create(UUID id, String type, Map<String, Object> attributes) throws StoreException { doPreDelay("create"); _durableConfigurationStore.create(id, type, attributes); @@ -194,7 +194,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore } @Override - public void remove(UUID id, String type) throws AMQStoreException + public void remove(UUID id, String type) throws StoreException { doPreDelay("remove"); _durableConfigurationStore.remove(id, type); @@ -202,7 +202,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore } @Override - public UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException + public UUID[] removeConfiguredObjects(final UUID... objects) throws StoreException { doPreDelay("remove"); UUID[] removed = _durableConfigurationStore.removeConfiguredObjects(objects); @@ -211,7 +211,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore } @Override - public void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException + public void update(UUID id, String type, Map<String, Object> attributes) throws StoreException { doPreDelay("update"); _durableConfigurationStore.update(id, type, attributes); @@ -219,7 +219,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore } @Override - public void update(ConfiguredObjectRecord... records) throws AMQStoreException + public void update(ConfiguredObjectRecord... records) throws StoreException { doPreDelay("update"); _durableConfigurationStore.update(records); @@ -227,7 +227,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore } @Override - public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException + public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException { doPreDelay("update"); _durableConfigurationStore.update(createIfNecessary, records); |
