Author: ritchiem
Date: 2008-09-04 10:50:32 -0400 (Thu, 04 Sep 2008)
New Revision: 2403
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
Log:
RHM-6 : Updated usage() and improved command argument parsing.
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
===================================================================
---
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java 2008-09-04
11:35:26 UTC (rev 2402)
+++
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java 2008-09-04
14:50:32 UTC (rev 2403)
@@ -102,7 +102,9 @@
/**
* Upgrade a Store of a specified version to the latest version.
+ *
* @param version the version of the current store
+ *
* @throws Exception
*/
public void upgradeFromVersion(int version) throws Exception
@@ -115,11 +117,11 @@
*
* @param version the version of the current store
* @param fromDir the directory with the old Store
- * @param toDir the directrory to hold the newly Upgraded Store
+ * @param toDir the directrory to hold the newly Upgraded Store
*
- * @throws Exception due to Virtualhost/MessageStore.close() being rather poor at
exception handling
+ * @throws Exception due to Virtualhost/MessageStore.close() being rather
poor at exception handling
* @throws DatabaseException if there is a problem with the store formats
- * @throws AMQException if there is an issue creating Qpid data structures
+ * @throws AMQException if there is an issue creating Qpid data structures
*/
public void upgradeFromVersion(int version, File fromDir, File toDir) throws
Exception
{
@@ -148,7 +150,7 @@
_newVirtualHost.close();
_oldVirtualHost.close();
-
+
//Shutdown the AR that the Vhosts will have created.
ApplicationRegistry.remove(1);
}
@@ -220,9 +222,25 @@
private static void usage()
{
- System.out.println("usage: -fromDir <path-to-store-to-upgrade> -toDir
<path-to-location-to-write-upgraded-db>");
+ System.out.println("usage: " + FROM_DIR + "
<path-to-store-to-upgrade> " + TO_DIR + "
<path-to-location-to-write-upgraded-db>");
}
+ private static String getArg(String[] args, String arg)
+ {
+ if (args[0].equals(arg))
+ {
+ return args[1];
+ }
+ else if (args[2].equals(arg))
+ {
+ return args[3];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public static void main(String[] args) throws Exception
{
String fromDir, toDir;
@@ -234,9 +252,16 @@
System.exit(1);
}
- fromDir = args[1];
- toDir = args[3];
+ fromDir = getArg(args, FROM_DIR);
+ toDir = getArg(args, TO_DIR);
+
+ if (fromDir == null || toDir == null)
+ {
+ usage();
+ System.exit(1);
+ }
+
new BDBStoreUpgrade(fromDir, toDir).upgradeFromVersion(1);
System.out.println("Upgrade complete");