You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/02/14 20:23:18 UTC
svn commit: r1568495 [4/8] - in
/qpid/branches/java-broker-amqp-1-0-management/java: ./
amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/
bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/
bdbstore/jmx/src/test/java...
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java Fri Feb 14 19:23:14 2014
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.security.auth.sasl.crammd5;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
+
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslException;
@@ -60,7 +62,7 @@ public class CRAMMD5HashedSaslServer imp
}
}
- throw new RuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
+ throw new ServerScopedRuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
}
public String getMechanismName()
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java Fri Feb 14 19:23:14 2014
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.security.auth.sasl.crammd5;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
+
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslException;
@@ -60,7 +62,7 @@ public class CRAMMD5HexSaslServer implem
}
}
- throw new RuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
+ throw new ServerScopedRuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
}
public String getMechanismName()
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java Fri Feb 14 19:23:14 2014
@@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentSk
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
/**
* A group database that reads/writes the following file format:
@@ -181,7 +182,7 @@ public class FileGroupDatabase implement
}
catch (IOException e)
{
- throw new RuntimeException("Unable to persist change to file " + _groupFile);
+ throw new ServerScopedRuntimeException("Unable to persist change to file " + _groupFile);
}
}
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java Fri Feb 14 19:23:14 2014
@@ -43,8 +43,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.MessageMetaDataType;
@@ -177,7 +175,7 @@ abstract public class AbstractJDBCMessag
}
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler configRecoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler configRecoveryHandler)
{
_stateManager.attainState(State.INITIALISING);
_configRecoveryHandler = configRecoveryHandler;
@@ -187,7 +185,7 @@ abstract public class AbstractJDBCMessag
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
if(_stateManager.isInState(State.INITIAL))
{
@@ -201,7 +199,7 @@ abstract public class AbstractJDBCMessag
completeInitialisation();
}
- private void completeInitialisation() throws ClassNotFoundException, SQLException, AMQStoreException
+ private void completeInitialisation()
{
commonConfiguration();
@@ -209,7 +207,7 @@ abstract public class AbstractJDBCMessag
}
@Override
- public void activate() throws Exception
+ public void activate()
{
if(_stateManager.isInState(State.INITIALISING))
{
@@ -224,12 +222,28 @@ abstract public class AbstractJDBCMessag
}
if(_messageRecoveryHandler != null)
{
- recoverMessages(_messageRecoveryHandler);
+ try
+ {
+ recoverMessages(_messageRecoveryHandler);
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Error encountered when restoring message data from " +
+ "persistent store ", e);
+ }
}
if(_tlogRecoveryHandler != null)
{
- TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(_tlogRecoveryHandler);
- recoverXids(dtxrh);
+ try
+ {
+ TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(_tlogRecoveryHandler);
+ recoverXids(dtxrh);
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Error encountered when restoring distributed transaction " +
+ "data from persistent store ", e);
+ }
}
@@ -237,14 +251,24 @@ abstract public class AbstractJDBCMessag
}
private void commonConfiguration()
- throws ClassNotFoundException, SQLException, AMQStoreException
{
- implementationSpecificConfiguration(_virtualHost.getName(), _virtualHost);
- createOrOpenDatabase();
- upgradeIfNecessary();
+ try
+ {
+ implementationSpecificConfiguration(_virtualHost.getName(), _virtualHost);
+ createOrOpenDatabase();
+ upgradeIfNecessary();
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new StoreException("Unable to configure message store ", e);
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Unable to configure message store ", e);
+ }
}
- protected void upgradeIfNecessary() throws SQLException, AMQStoreException
+ protected void upgradeIfNecessary() throws SQLException
{
Connection conn = newAutoCommitConnection();
try
@@ -258,7 +282,7 @@ abstract public class AbstractJDBCMessag
{
if(!rs.next())
{
- throw new AMQStoreException(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)
@@ -268,7 +292,7 @@ abstract public class AbstractJDBCMessag
case DB_VERSION:
return;
default:
- throw new AMQStoreException("Unknown database version: " + version);
+ throw new StoreException("Unknown database version: " + version);
}
}
finally
@@ -591,7 +615,7 @@ abstract public class AbstractJDBCMessag
}
}
- protected void recoverConfiguration(ConfigurationRecoveryHandler recoveryHandler) throws AMQException
+ protected void recoverConfiguration(ConfigurationRecoveryHandler recoveryHandler)
{
try
{
@@ -602,7 +626,7 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e);
+ throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
}
}
@@ -668,7 +692,7 @@ abstract public class AbstractJDBCMessag
}
@Override
- public void close() throws Exception
+ public void close()
{
if (_closed.compareAndSet(false, true))
{
@@ -681,7 +705,7 @@ abstract public class AbstractJDBCMessag
}
- protected abstract void doClose() throws Exception;
+ protected abstract void doClose();
@Override
public StoredMessage addMessage(StorableMessageMetaData metaData)
@@ -756,14 +780,14 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new RuntimeException("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))
{
@@ -773,17 +797,17 @@ abstract public class AbstractJDBCMessag
}
@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))
{
@@ -852,7 +876,7 @@ abstract public class AbstractJDBCMessag
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)
@@ -877,7 +901,7 @@ abstract public class AbstractJDBCMessag
catch (IOException e)
{
// This should never happen
- throw new AMQStoreException(e.getMessage(), e);
+ throw new StoreException(e.getMessage(), e);
}
argumentBytes = bos.toByteArray();
}
@@ -890,7 +914,8 @@ abstract public class AbstractJDBCMessag
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();
@@ -927,13 +952,14 @@ abstract public class AbstractJDBCMessag
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();
@@ -952,7 +978,7 @@ abstract public class AbstractJDBCMessag
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());
}
@@ -973,14 +999,14 @@ abstract public class AbstractJDBCMessag
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();
@@ -999,7 +1025,7 @@ abstract public class AbstractJDBCMessag
if(results != 1)
{
- throw new AMQStoreException("Unable to find message with xid");
+ throw new StoreException("Unable to find message with xid");
}
}
finally
@@ -1025,13 +1051,13 @@ abstract public class AbstractJDBCMessag
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();
@@ -1092,7 +1118,7 @@ abstract public class AbstractJDBCMessag
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);
}
}
@@ -1118,7 +1144,7 @@ abstract public class AbstractJDBCMessag
}
- public void commitTran(ConnectionWrapper connWrapper) throws AMQStoreException
+ public void commitTran(ConnectionWrapper connWrapper) throws StoreException
{
try
@@ -1135,7 +1161,7 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new AMQStoreException("Error commit tx: " + e.getMessage(), e);
+ throw new StoreException("Error commit tx: " + e.getMessage(), e);
}
finally
{
@@ -1143,17 +1169,17 @@ abstract public class AbstractJDBCMessag
}
}
- 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())
@@ -1169,7 +1195,7 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new AMQStoreException("Error aborting transaction: " + e.getMessage(), e);
+ throw new StoreException("Error aborting transaction: " + e.getMessage(), e);
}
}
@@ -1208,7 +1234,7 @@ abstract public class AbstractJDBCMessag
if(result == 0)
{
- throw new RuntimeException("Unable to add meta data for message " +messageId);
+ throw new StoreException("Unable to add meta data for message " +messageId);
}
}
finally
@@ -1533,7 +1559,7 @@ abstract public class AbstractJDBCMessag
}
else
{
- throw new RuntimeException("Meta data not found for message with id " + messageId);
+ throw new StoreException("Meta data not found for message with id " + messageId);
}
}
finally
@@ -1579,7 +1605,7 @@ abstract public class AbstractJDBCMessag
catch (SQLException e)
{
closeConnection(conn);
- throw new RuntimeException("Error adding content for message " + messageId + ": " + e.getMessage(), e);
+ throw new StoreException("Error adding content for message " + messageId + ": " + e.getMessage(), e);
}
finally
{
@@ -1611,7 +1637,7 @@ abstract public class AbstractJDBCMessag
if (offset > size)
{
- throw new RuntimeException("Offset " + offset + " is greater than message size " + size
+ throw new StoreException("Offset " + offset + " is greater than message size " + size
+ " for message id " + messageId + "!");
}
@@ -1630,7 +1656,7 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new RuntimeException("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
{
@@ -1662,12 +1688,12 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
@Override
- public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
final StoredMessage storedMessage = message.getStoredMessage();
if(storedMessage instanceof StoredJDBCMessage)
@@ -1678,50 +1704,49 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new AMQStoreException("Exception on enqueuing message " + _messageId, e);
+ throw new StoreException("Exception on enqueuing message into message store" + _messageId, e);
}
}
_storeSizeIncrease += storedMessage.getMetaData().getContentSize();
AbstractJDBCMessageStore.this.enqueueMessage(_connWrapper, queue, message.getMessageNumber());
+
}
@Override
- public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
AbstractJDBCMessageStore.this.dequeueMessage(_connWrapper, queue, message.getMessageNumber());
-
}
@Override
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
AbstractJDBCMessageStore.this.commitTran(_connWrapper);
storedSizeChange(_storeSizeIncrease);
}
@Override
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
- final StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper);
+ StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper);
storedSizeChange(_storeSizeIncrease);
return storeFuture;
}
@Override
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
AbstractJDBCMessageStore.this.abortTran(_connWrapper);
}
@Override
- public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+ public void removeXid(long format, byte[] globalId, byte[] branchId)
{
AbstractJDBCMessageStore.this.removeXid(_connWrapper, format, globalId, branchId);
}
@Override
public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
- throws AMQStoreException
{
AbstractJDBCMessageStore.this.recordXid(_connWrapper, format, globalId, branchId, enqueues, dequeues);
}
@@ -1770,7 +1795,7 @@ abstract public class AbstractJDBCMessag
}
catch (SQLException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
_metaDataRef = new SoftReference<StorableMessageMetaData>(metaData);
}
@@ -1856,7 +1881,7 @@ abstract public class AbstractJDBCMessag
{
getLogger().debug("Error when trying to flush message " + _messageId + " to store: " + e);
}
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
finally
{
@@ -1938,7 +1963,7 @@ abstract public class AbstractJDBCMessag
_eventManager.addEventListener(eventListener, events);
}
- private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws AMQStoreException
+ private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -1998,24 +2023,24 @@ abstract public class AbstractJDBCMessag
}
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
@@ -2032,12 +2057,12 @@ abstract public class AbstractJDBCMessag
}
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
@@ -2061,7 +2086,7 @@ abstract public class AbstractJDBCMessag
}
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()]);
}
@@ -2081,7 +2106,7 @@ abstract public class AbstractJDBCMessag
return results;
}
- private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws AMQStoreException
+ private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -2099,18 +2124,18 @@ abstract public class AbstractJDBCMessag
}
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))
{
@@ -2132,7 +2157,7 @@ abstract public class AbstractJDBCMessag
}
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);
}
}
@@ -2142,7 +2167,7 @@ abstract public class AbstractJDBCMessag
private void updateConfiguredObject(ConfiguredObjectRecord configuredObject,
boolean createIfNecessary,
Connection conn)
- throws SQLException, AMQStoreException
+ throws SQLException, StoreException
{
PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT);
try
@@ -2209,15 +2234,15 @@ abstract public class AbstractJDBCMessag
}
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
{
@@ -2226,7 +2251,7 @@ abstract public class AbstractJDBCMessag
}
- private ConfiguredObjectRecord loadConfiguredObject(final UUID id) throws AMQStoreException
+ private ConfiguredObjectRecord loadConfiguredObject(final UUID id) throws StoreException
{
ConfiguredObjectRecord result = null;
try
@@ -2266,28 +2291,29 @@ abstract public class AbstractJDBCMessag
}
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();
@@ -2311,15 +2337,15 @@ abstract public class AbstractJDBCMessag
}
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
{
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java Fri Feb 14 19:23:14 2014
@@ -22,7 +22,7 @@ package org.apache.qpid.server.store;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.qpid.AMQStoreException;
+
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.model.VirtualHost;
@@ -35,28 +35,28 @@ abstract public class AbstractMemoryMess
private static final Transaction IN_MEMORY_TRANSACTION = new Transaction()
{
@Override
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
return StoreFuture.IMMEDIATE_FUTURE;
}
@Override
- public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
}
@Override
- public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
}
@Override
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
}
@Override
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
}
@@ -80,14 +80,14 @@ abstract public class AbstractMemoryMess
}
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
{
_stateManager.attainState(State.INITIALISING);
}
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
if(_stateManager.isInState(State.INITIAL))
{
@@ -97,7 +97,7 @@ abstract public class AbstractMemoryMess
}
@Override
- public void activate() throws Exception
+ public void activate()
{
if(_stateManager.isInState(State.INITIALISING))
@@ -131,7 +131,7 @@ abstract public class AbstractMemoryMess
}
@Override
- public void close() throws Exception
+ public void close()
{
if (_closed.compareAndSet(false, true))
{
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java Fri Feb 14 19:23:14 2014
@@ -27,11 +27,11 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import static org.apache.qpid.server.model.VirtualHost.CURRENT_CONFIG_VERSION;
@@ -124,21 +124,13 @@ public class DurableConfigurationRecover
}
}
- 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 RuntimeException("Unable to update config store when upgrading");
+ _store.removeConfiguredObjects(deletes.toArray(new UUID[deletes.size()]));
}
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java Fri Feb 14 19:23:14 2014
@@ -23,7 +23,6 @@ package org.apache.qpid.server.store;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.model.VirtualHost;
public interface DurableConfigurationStore
@@ -44,9 +43,8 @@ public interface DurableConfigurationSto
*
* @param virtualHost
* @param recoveryHandler Handler to be called as the store recovers on start up
- * @throws Exception If any error occurs that means the store is unable to configure itself.
*/
- void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception;
+ void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler);
/**
@@ -56,9 +54,9 @@ public interface DurableConfigurationSto
* @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.
@@ -66,11 +64,11 @@ public interface DurableConfigurationSto
* @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;
/**
@@ -81,13 +79,13 @@ public interface DurableConfigurationSto
* @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;
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java Fri Feb 14 19:23:14 2014
@@ -28,13 +28,13 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.qpid.AMQStoreException;
-import org.apache.qpid.server.consumer.Consumer;
+
import org.apache.qpid.server.model.Binding;
import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class DurableConfigurationStoreHelper
{
@@ -47,7 +47,7 @@ public class DurableConfigurationStoreHe
Queue.EXCLUSIVE,
Queue.ALTERNATE_EXCHANGE));
- public static void updateQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue) throws AMQStoreException
+ public static void updateQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue)
{
Map<String, Object> attributesMap = new LinkedHashMap<String, Object>();
attributesMap.put(Queue.NAME, queue.getName());
@@ -73,7 +73,6 @@ public class DurableConfigurationStoreHe
}
public static void createQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue)
- throws AMQStoreException
{
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Queue.NAME, queue.getName());
@@ -91,35 +90,33 @@ public class DurableConfigurationStoreHe
attributesMap.put(attrName, queue.getAttribute(attrName));
}
}
- store.create(queue.getId(), QUEUE,attributesMap);
+ store.create(queue.getId(), QUEUE, attributesMap);
}
- public static void removeQueue(DurableConfigurationStore store, AMQQueue queue) throws AMQStoreException
+ public static void removeQueue(DurableConfigurationStore store, AMQQueue queue)
{
store.remove(queue.getId(), QUEUE);
}
public static void createExchange(DurableConfigurationStore store, org.apache.qpid.server.exchange.Exchange exchange)
- throws AMQStoreException
{
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Exchange.NAME, exchange.getName());
attributesMap.put(Exchange.TYPE, exchange.getTypeName());
attributesMap.put(Exchange.LIFETIME_POLICY, exchange.isAutoDelete() ? LifetimePolicy.AUTO_DELETE.name()
: LifetimePolicy.PERMANENT.name());
+
store.create(exchange.getId(), EXCHANGE, attributesMap);
}
public static void removeExchange(DurableConfigurationStore store, org.apache.qpid.server.exchange.Exchange exchange)
- throws AMQStoreException
{
store.remove(exchange.getId(), EXCHANGE);
}
public static void createBinding(DurableConfigurationStore store, org.apache.qpid.server.binding.Binding binding)
- throws AMQStoreException
{
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Binding.NAME, binding.getBindingKey());
@@ -130,12 +127,12 @@ public class DurableConfigurationStoreHe
{
attributesMap.put(Binding.ARGUMENTS, arguments);
}
+
store.create(binding.getId(), BINDING, attributesMap);
}
public static void removeBinding(DurableConfigurationStore store, org.apache.qpid.server.binding.Binding binding)
- throws AMQStoreException
{
store.remove(binding.getId(), BINDING);
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java Fri Feb 14 19:23:14 2014
@@ -34,10 +34,12 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.VirtualHost;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
@@ -66,14 +68,13 @@ public class JsonFileConfigStore impleme
@Override
public void configureConfigStore(final VirtualHost virtualHost, final ConfigurationRecoveryHandler recoveryHandler)
- throws Exception
{
_name = virtualHost.getName();
Object storePathAttr = virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH);
if(!(storePathAttr instanceof String))
{
- throw new AMQStoreException("Cannot determine path for configuration storage");
+ throw new StoreException("Cannot determine path for configuration storage");
}
_directoryName = (String) storePathAttr;
_configFileName = _name + ".json";
@@ -86,7 +87,14 @@ public class JsonFileConfigStore impleme
if(!fileExists(_backupFileName))
{
File newFile = new File(_directoryName, _configFileName);
- _objectMapper.writeValue(newFile, Collections.emptyMap());
+ try
+ {
+ _objectMapper.writeValue(newFile, Collections.emptyMap());
+ }
+ catch (IOException e)
+ {
+ throw new StoreException("Could not write configuration file " + newFile, e);
+ }
}
else
{
@@ -110,21 +118,21 @@ public class JsonFileConfigStore impleme
}
}
- private void renameFile(String fromFileName, String toFileName) throws AMQStoreException
+ private void renameFile(String fromFileName, String toFileName)
{
File toFile = new File(_directoryName, toFileName);
if(toFile.exists())
{
if(!toFile.delete())
{
- throw new AMQStoreException("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 AMQStoreException("Cannot rename file " + fromFile.getAbsolutePath() + " to " + toFile.getAbsolutePath());
+ throw new StoreException("Cannot rename file " + fromFile.getAbsolutePath() + " to " + toFile.getAbsolutePath());
}
}
@@ -134,7 +142,7 @@ public class JsonFileConfigStore impleme
return file.exists();
}
- private void getFileLock() throws AMQStoreException
+ private void getFileLock()
{
File lockFile = new File(_directoryName, _name + ".lck");
try
@@ -149,7 +157,7 @@ public class JsonFileConfigStore impleme
}
catch (IOException ioe)
{
- throw new AMQStoreException("Cannot create the lock file " + lockFile.getName(), ioe);
+ throw new StoreException("Cannot create the lock file " + lockFile.getName(), ioe);
}
catch(OverlappingFileLockException e)
{
@@ -158,11 +166,11 @@ public class JsonFileConfigStore impleme
if(_fileLock == null)
{
- throw new AMQStoreException("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?");
}
}
- private void checkDirectoryIsWritable(String directoryName) throws AMQStoreException
+ private void checkDirectoryIsWritable(String directoryName)
{
File dir = new File(directoryName);
if(dir.exists())
@@ -171,51 +179,68 @@ public class JsonFileConfigStore impleme
{
if(!dir.canWrite())
{
- throw new AMQStoreException("Configuration path " + directoryName + " exists, but is not writable");
+ throw new StoreException("Configuration path " + directoryName + " exists, but is not writable");
}
}
else
{
- throw new AMQStoreException("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 AMQStoreException("Cannot create directory " + directoryName);
+ throw new StoreException("Cannot create directory " + directoryName);
}
}
- private void load() throws IOException
+ private void load()
{
- Map data = _objectMapper.readValue(new File(_directoryName,_configFileName),Map.class);
- Collection<Class<? extends ConfiguredObject>> childClasses =
- MODEL.getChildTypes(VirtualHost.class);
- data.remove("modelVersion");
- Object configVersion;
- if((configVersion = data.remove("configVersion")) instanceof Integer)
- {
- _configVersion = (Integer) configVersion;
- }
- for(Class<? extends ConfiguredObject> childClass : childClasses)
+ final File configFile = new File(_directoryName, _configFileName);
+ try
{
- final String type = childClass.getSimpleName();
- String attrName = type.toLowerCase() + "s";
- Object children = data.remove(attrName);
- if(children != null)
+ Map data = _objectMapper.readValue(configFile,Map.class);
+ Collection<Class<? extends ConfiguredObject>> childClasses =
+ MODEL.getChildTypes(VirtualHost.class);
+ data.remove("modelVersion");
+ Object configVersion;
+ if((configVersion = data.remove("configVersion")) instanceof Integer)
{
- if(children instanceof Collection)
+ _configVersion = (Integer) configVersion;
+ }
+ for(Class<? extends ConfiguredObject> childClass : childClasses)
+ {
+ final String type = childClass.getSimpleName();
+ String attrName = type.toLowerCase() + "s";
+ Object children = data.remove(attrName);
+ if(children != null)
{
- for(Object child : (Collection)children)
+ if(children instanceof Collection)
{
- if(child instanceof Map)
+ for(Object child : (Collection)children)
{
- loadChild(childClass, (Map)child, VirtualHost.class, null);
+ if(child instanceof Map)
+ {
+ loadChild(childClass, (Map)child, VirtualHost.class, null);
+ }
}
}
}
}
}
+ catch (JsonMappingException e)
+ {
+ throw new StoreException("Cannot parse the configuration file " + configFile, e);
+ }
+ catch (JsonParseException e)
+ {
+ throw new StoreException("Cannot parse the configuration file " + configFile, e);
+ }
+ catch (IOException e)
+ {
+ throw new StoreException("Could not load the configuration file " + configFile, e);
+ }
+
}
private void loadChild(final Class<? extends ConfiguredObject> clazz,
@@ -286,15 +311,16 @@ public class JsonFileConfigStore impleme
}
@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
{
@@ -311,7 +337,7 @@ public class JsonFileConfigStore impleme
}
}
- private void save() throws AMQStoreException
+ private void save()
{
Collection<Class<? extends ConfiguredObject>> childClasses =
MODEL.getChildTypes(VirtualHost.class);
@@ -351,7 +377,7 @@ public class JsonFileConfigStore impleme
}
catch (IOException e)
{
- throw new AMQStoreException("Cannot save to store", e);
+ throw new StoreException("Cannot save to store", e);
}
}
@@ -397,13 +423,13 @@ public class JsonFileConfigStore impleme
}
@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)
@@ -420,20 +446,21 @@ public class JsonFileConfigStore impleme
}
@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)
{
@@ -445,18 +472,18 @@ public class JsonFileConfigStore impleme
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)
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java Fri Feb 14 19:23:14 2014
@@ -41,9 +41,9 @@ public interface MessageStore
* @throws Exception If any error occurs that means the store is unable to configure itself.
*/
void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler messageRecoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception;
+ TransactionLogRecoveryHandler tlogRecoveryHandler);
- void activate() throws Exception;
+ void activate();
public <T extends StorableMessageMetaData> StoredMessage<T> addMessage(T metaData);
@@ -62,7 +62,7 @@ public interface MessageStore
*
* @throws Exception If the close fails.
*/
- void close() throws Exception;
+ void close();
void addEventListener(EventListener eventListener, Event... events);
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java Fri Feb 14 19:23:14 2014
@@ -21,13 +21,13 @@ package org.apache.qpid.server.store;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+
import org.apache.qpid.server.model.VirtualHost;
public abstract class NullMessageStore implements MessageStore, DurableConfigurationStore
{
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
{
}
@@ -37,12 +37,12 @@ public abstract class NullMessageStore i
}
@Override
- public void update(ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(ConfiguredObjectRecord... records)
{
}
@Override
- public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(boolean createIfNecessary, ConfiguredObjectRecord... records)
{
}
@@ -53,7 +53,7 @@ public abstract class NullMessageStore i
}
@Override
- public UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException
+ public UUID[] removeConfiguredObjects(final UUID... objects)
{
return objects;
}
@@ -65,12 +65,12 @@ public abstract class NullMessageStore i
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
}
@Override
- public void close() throws Exception
+ public void close()
{
}
@@ -93,7 +93,7 @@ public abstract class NullMessageStore i
}
@Override
- public void activate() throws Exception
+ public void activate()
{
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java Fri Feb 14 19:23:14 2014
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.store;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
public interface Transaction
@@ -32,40 +31,35 @@ public interface Transaction
*
* @param queue The queue to place the message on.
* @param message
- * @throws org.apache.qpid.AMQStoreException If the operation fails for any reason.
*/
- void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException;
+ void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message);
/**
* Extracts a message from a specified queue, in a given transactional context.
*
* @param queue The queue to place the message on.
* @param message The message to dequeue.
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
*/
- void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException;
+ void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message);
/**
* Commits all operations performed within a given transactional context.
*
- * @throws AMQStoreException If the operation fails for any reason.
*/
- void commitTran() throws AMQStoreException;
+ void commitTran();
/**
* Commits all operations performed within a given transactional context.
*
- * @throws AMQStoreException If the operation fails for any reason.
*/
- StoreFuture commitTranAsync() throws AMQStoreException;
+ StoreFuture commitTranAsync();
/**
* Abandons all operations performed within a given transactional context.
*
- * @throws AMQStoreException If the operation fails for any reason.
*/
- void abortTran() throws AMQStoreException;
+ void abortTran();
public static interface Record
@@ -74,8 +68,8 @@ public interface Transaction
EnqueueableMessage getMessage();
}
- void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException;
+ void removeXid(long format, byte[] globalId, byte[] branchId);
- void recordXid(long format, byte[] globalId, byte[] branchId, Transaction.Record[] enqueues, Transaction.Record[] dequeues)
- throws AMQStoreException;
+ void recordXid(long format, byte[] globalId, byte[] branchId, Transaction.Record[] enqueues,
+ Transaction.Record[] dequeues);
}
\ No newline at end of file
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java Fri Feb 14 19:23:14 2014
@@ -22,13 +22,10 @@ package org.apache.qpid.server.txn;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.StoreFuture;
import org.apache.qpid.server.store.Transaction;
@@ -116,11 +113,6 @@ public class AsyncAutoCommitTransaction
addFuture(future, postTransactionAction);
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message dequeue", e);
- throw new RuntimeException("Error during message dequeue", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -199,11 +191,6 @@ public class AsyncAutoCommitTransaction
addFuture(future, postTransactionAction);
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message dequeues", e);
- throw new RuntimeException("Error during message dequeues", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -236,13 +223,7 @@ public class AsyncAutoCommitTransaction
}
addEnqueueFuture(future, postTransactionAction, message.isPersistent());
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message enqueue", e);
- throw new RuntimeException("Error during message enqueue", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -292,13 +273,7 @@ public class AsyncAutoCommitTransaction
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message enqueues", e);
- throw new RuntimeException("Error during message enqueues", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -341,17 +316,7 @@ public class AsyncAutoCommitTransaction
{
if (txn != null)
{
- try
- {
- txn.abortTran();
- }
- catch (AMQStoreException e)
- {
- _logger.error("Abort transaction failed", e);
- // Deliberate decision not to re-throw this exception. Rationale: we can only reach here if a previous
- // TransactionLog method has ended in Exception. If we were to re-throw here, we would prevent
- // our caller from receiving the original exception (which is likely to be more revealing of the underlying error).
- }
+ txn.abortTran();
}
if (postTransactionAction != null)
{
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java Fri Feb 14 19:23:14 2014
@@ -22,13 +22,10 @@ package org.apache.qpid.server.txn;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.Transaction;
import org.apache.qpid.server.store.TransactionLogResource;
@@ -95,11 +92,6 @@ public class AutoCommitTransaction imple
postTransactionAction.postCommit();
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message dequeue", e);
- throw new RuntimeException("Error during message dequeue", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -140,13 +132,7 @@ public class AutoCommitTransaction imple
}
postTransactionAction.postCommit();
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message dequeues", e);
- throw new RuntimeException("Error during message dequeues", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -174,11 +160,6 @@ public class AutoCommitTransaction imple
postTransactionAction.postCommit();
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message enqueue", e);
- throw new RuntimeException("Error during message enqueue", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -225,13 +206,7 @@ public class AutoCommitTransaction imple
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message enqueues", e);
- throw new RuntimeException("Error during message enqueues", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -261,17 +236,7 @@ public class AutoCommitTransaction imple
{
if (txn != null)
{
- try
- {
- txn.abortTran();
- }
- catch (AMQStoreException e)
- {
- _logger.error("Abort transaction failed", e);
- // Deliberate decision not to re-throw this exception. Rationale: we can only reach here if a previous
- // TransactionLog method has ended in Exception. If we were to re-throw here, we would prevent
- // our caller from receiving the original exception (which is likely to be more revealing of the underlying error).
- }
+ txn.abortTran();
}
if (postTransactionAction != null)
{
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java Fri Feb 14 19:23:14 2014
@@ -28,10 +28,9 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import org.apache.log4j.Logger;
-import org.apache.qpid.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.queue.BaseQueue;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.Transaction;
import org.apache.qpid.server.store.TransactionLogResource;
@@ -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 RuntimeException(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();
@@ -400,15 +391,8 @@ public class DtxBranch
{
if(_transaction != null)
{
- try
- {
- _state = null;
- _transaction.abortTran();
- }
- catch(AMQStoreException e)
- {
- _logger.error("Error while closing DtxBranch " + _xid, e);
- }
+ _state = null;
+ _transaction.abortTran();
}
}
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java Fri Feb 14 19:23:14 2014
@@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.qpid.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);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org