[rhmessaging-commits] rhmessaging commits: r3789 - store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Tue Jan 12 06:36:03 EST 2010
Author: rgemmell
Date: 2010-01-12 06:36:02 -0500 (Tue, 12 Jan 2010)
New Revision: 3789
Modified:
store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java
Log:
Updated error handling to cease the process at first issue and ensure clear appearance of success/failure
Modified: store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java
===================================================================
--- store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java 2010-01-11 22:17:57 UTC (rev 3788)
+++ store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java 2010-01-12 11:36:02 UTC (rev 3789)
@@ -59,7 +59,17 @@
{
BDBStoreBindingsWorkaround tool = new BDBStoreBindingsWorkaround(args);
- tool.start();
+ try
+ {
+ tool.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ _logger.error("Error during workaround process");
+ //Shut down the JVM, the ShutdownHook will stop the VirtualHosts if initialised.
+ System.exit(1);
+ }
//Shut down the JVM gracefully, the ShutdownHook will stop the VirtualHosts.
System.exit(0);
@@ -116,24 +126,19 @@
}
}
- protected void start()
+ protected void start() throws Exception
{
_initialised = false;
_logger.info("BDBStore BindingsWorkaround process commencing");
loadVirtualHosts();
-
- if (!_initialised)
- {
- System.exit(1);
- }
addDurableExchangesToStoreIfRequired();
_logger.info("Workaround process complete");
}
- private void loadVirtualHosts()
+ private void loadVirtualHosts() throws Exception
{
final File configFile = _config.getConfigFile();
@@ -141,7 +146,7 @@
{
_logger.error("Config file not found:" + configFile.getAbsolutePath());
_logger.error("Options: [-c <broker config file>] : Defaults to \"$QPID_HOME/etc/config.xml\"");
- return;
+ System.exit(1);
}
else
{
@@ -165,14 +170,12 @@
catch (ConfigurationException e)
{
_logger.error("Unable to load configuration due to configuration error: " + e.getMessage());
- e.printStackTrace();
- System.exit(1);
+ throw e;
}
catch (Exception e)
{
- _logger.error("Unable to load configuration due to: " + e.getMessage());
- e.printStackTrace();
- System.exit(1);
+ _logger.error("Unable to load VirtualHosts due to: " + e.getMessage());
+ throw e;
}
}
@@ -214,7 +217,7 @@
}
}
- private static List<AMQShortString> getBDBStoreExchangeNames(final VirtualHost vhost, final BDBMessageStore store)
+ private static List<AMQShortString> getBDBStoreExchangeNames(final VirtualHost vhost, final BDBMessageStore store) throws AMQException, DatabaseException
{
final List<AMQShortString> exchanges = new ArrayList<AMQShortString>();
@@ -245,16 +248,21 @@
{
store.visitExchanges(exchangeVisitor);
}
- catch (Exception e)
+ catch (AMQException e)
{
_logger.error("Error retrieving exiting Exchange names from the store: " + e.getMessage());
- e.printStackTrace();
+ throw e;
}
+ catch (DatabaseException e)
+ {
+ _logger.error("Error retrieving exiting Exchange names from the store: " + e.getMessage());
+ throw e;
+ }
return exchanges;
}
- private static void addDurableExchangesToStoreIfRequired()
+ private static void addDurableExchangesToStoreIfRequired() throws AMQException, DatabaseException
{
Collection<VirtualHost> vhosts = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts();
@@ -299,7 +307,7 @@
catch (AMQException e)
{
_logger.error("Error adding entry to store for Exchange '" + exchangeName + "':" + e.getMessage());
- e.printStackTrace();
+ throw e;
}
}
}
More information about the rhmessaging-commits
mailing list