qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r561794 - in /incubator/qpid/branches/M2/java/broker: bin/ src/main/java/org/apache/qpid/tools/messagestore/ src/main/java/org/apache/qpid/tools/messagestore/commands/
Date Wed, 01 Aug 2007 13:34:12 GMT
Author: ritchiem
Date: Wed Aug  1 06:34:11 2007
New Revision: 561794

URL: http://svn.apache.org/viewvc?view=rev&rev=561794
Log:
Fix for a bug in the Broker Tools, preventing them working.

Modified:
    incubator/qpid/branches/M2/java/broker/bin/msTool.sh
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Copy.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Move.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Purge.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java

Modified: incubator/qpid/branches/M2/java/broker/bin/msTool.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/bin/msTool.sh?view=diff&rev=561794&r1=561793&r2=561794
==============================================================================
--- incubator/qpid/branches/M2/java/broker/bin/msTool.sh (original)
+++ incubator/qpid/branches/M2/java/broker/bin/msTool.sh Wed Aug  1 06:34:11 2007
@@ -18,9 +18,6 @@
 # under the License.
 #
 
-# Set classpath to include Qpid jar with all required jars in manifest
-QPID_LIBS=$QPID_TOOLS/lib/qpid-incubating.jar
-
 die() {
   if [[ $1 = -usage ]]; then
     shift
@@ -39,18 +36,25 @@
   cygwin=true
 fi
 
+if [ -z "$QPID_TOOLS" ]; then
+    if [ -z "$QPID_HOME" ]; then
+        die "QPID_TOOLS must be set"
+    else
+        QPID_TOOLS=$QPID_HOME
+    fi
+fi
+
 if $cygwin; then
   QPID_TOOLS=$(cygpath -w $QPID_TOOLS)
 fi
 
+# Set classpath to include Qpid jar with all required jars in manifest
+QPID_LIBS=$QPID_TOOLS/lib/qpid-incubating.jar
+
 # Set other variables used by the qpid-run script before calling
 export JAVA=java \
        JAVA_VM=-server \
        JAVA_OPTS=-Dlog4j.configuration=file:$QPID_TOOLS/etc/mstool-log4j.xml \
        QPID_CLASSPATH=$QPID_LIBS
-
-if [ -z "$QPID_TOOLS" ]; then
-  die "QPID_TOOLS be set"
-fi
 
 . qpid-run org.apache.qpid.tools.messagestore.MessageStoreTool "$@"

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java?view=diff&rev=561794&r1=561793&r2=561794
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java
Wed Aug  1 06:34:11 2007
@@ -40,6 +40,8 @@
 import org.apache.qpid.tools.messagestore.commands.Quit;
 import org.apache.qpid.tools.messagestore.commands.Select;
 import org.apache.qpid.tools.messagestore.commands.Show;
+import org.apache.qpid.tools.messagestore.commands.Move;
+import org.apache.qpid.tools.messagestore.commands.Purge;
 import org.apache.qpid.tools.utils.CommandParser;
 import org.apache.qpid.tools.utils.Console;
 import org.apache.qpid.tools.utils.SimpleCommandParser;
@@ -241,6 +243,8 @@
         _commands.put("help", new Help(this));
         _commands.put("list", new List(this));
         _commands.put("load", new Load(this));
+        _commands.put("move", new Move(this));
+        _commands.put("purge", new Purge(this));
         _commands.put("quit", new Quit(this));
         _commands.put("select", new Select(this));
         _commands.put("show", new Show(this));

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Copy.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Copy.java?view=diff&rev=561794&r1=561793&r2=561794
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Copy.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Copy.java
Wed Aug  1 06:34:11 2007
@@ -21,7 +21,6 @@
 package org.apache.qpid.tools.messagestore.commands;
 
 import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.store.StoreContext;
 import org.apache.qpid.tools.messagestore.MessageStoreTool;
 
 public class Copy extends Move
@@ -33,9 +32,9 @@
 
     public String help()
     {
-        return "Copy messages between queues.\n" +
+        return "Copy messages between queues.";/*\n" +
                "The currently selected message set will be copied to the specifed queue.\n"
+
-               "Alternatively the values can be provided on the command line.";
+               "Alternatively the values can be provided on the command line."; */
     }
 
     public String usage()
@@ -48,9 +47,9 @@
         return "copy";
     }
 
-    protected void doCommand(AMQQueue fromQueue, long start, long end, AMQQueue toQueue,
StoreContext storeContext)
+    protected void doCommand(AMQQueue fromQueue, long start, long end, AMQQueue toQueue)
     {
-        fromQueue.copyMessagesToAnotherQueue(start, end, toQueue.getName().toString(), storeContext);
+        fromQueue.copyMessagesToAnotherQueue(start, end, toQueue.getName().toString(), _storeContext);
     }
 
 }

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Move.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Move.java?view=diff&rev=561794&r1=561793&r2=561794
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Move.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Move.java
Wed Aug  1 06:34:11 2007
@@ -21,10 +21,12 @@
 package org.apache.qpid.tools.messagestore.commands;
 
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.queue.AMQMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.store.StoreContext;
 import org.apache.qpid.tools.messagestore.MessageStoreTool;
 
+import java.util.LinkedList;
 import java.util.List;
 
 public class Move extends AbstractCommand
@@ -34,7 +36,7 @@
      * Since the Coopy command is not associated with a real channel we can safely create
our own store context
      * for use in the few methods that require one.
      */
-    private StoreContext _storeContext = new StoreContext();
+    protected StoreContext _storeContext = new StoreContext();
 
     public Move(MessageStoreTool tool)
     {
@@ -43,9 +45,9 @@
 
     public String help()
     {
-        return "Move messages between queues.\n" +
+        return "Move messages between queues.";/*\n" +
                "The currently selected message set will be moved to the specifed queue.\n"
+
-               "Alternatively the values can be provided on the command line.";
+               "Alternatively the values can be provided on the command line.";*/
     }
 
     public String usage()
@@ -110,6 +112,17 @@
         Long previous = null;
         Long start = null;
 
+        if (msgids == null)
+        {
+            msgids = allMessageIDs(fromQueue);
+        }
+
+        if (msgids == null || msgids.size() == 0)
+        {
+            _console.println("No Messages to move.");
+            return;
+        }
+
         for (long id : msgids)
         {
             if (previous != null)
@@ -126,18 +139,44 @@
                     if (start != null)
                     {
                         //move a range of ids
-                        doCommand(fromQueue, start, id, toQueue, _storeContext);
+                        doCommand(fromQueue, start, id, toQueue);
+                        start = null;
                     }
                     else
                     {
                         //move a single id
-                        doCommand(fromQueue, id, id, toQueue, _storeContext);
+                        doCommand(fromQueue, id, id, toQueue);
                     }
                 }
             }
 
             previous = id;
         }
+
+        if (start != null)
+        {
+            //move a range of ids
+            doCommand(fromQueue, start, previous, toQueue);
+        }
+    }
+
+    private List<Long> allMessageIDs(AMQQueue fromQueue)
+    {
+        List<Long> ids = new LinkedList<Long>();
+
+        if (fromQueue != null)
+        {
+            List<AMQMessage> messages = fromQueue.getMessagesOnTheQueue();
+            if (messages != null)
+            {
+                for (AMQMessage msg : messages)
+                {
+                    ids.add(msg.getMessageId());
+                }
+            }
+        }
+
+        return ids;
     }
 
     protected boolean checkRequirements(AMQQueue fromQueue, AMQQueue toQueue, List<Long>
msgids)
@@ -159,7 +198,7 @@
         return true;
     }
 
-    protected void doCommand(AMQQueue fromQueue, long start, long id, AMQQueue toQueue, StoreContext
storeContext)
+    protected void doCommand(AMQQueue fromQueue, long start, long id, AMQQueue toQueue)
     {
         fromQueue.moveMessagesToAnotherQueue(start, id, toQueue.getName().toString(), _storeContext);
     }

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Purge.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Purge.java?view=diff&rev=561794&r1=561793&r2=561794
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Purge.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Purge.java
Wed Aug  1 06:34:11 2007
@@ -61,8 +61,8 @@
         return true;
     }
 
-    protected void doCommand(AMQQueue fromQueue, long start, long end, AMQQueue toQueue,
StoreContext storeContext)
+    protected void doCommand(AMQQueue fromQueue, long start, long end, AMQQueue toQueue)
     {
-        fromQueue.removeMessagesFromQueue(start, end, storeContext);
+        fromQueue.removeMessagesFromQueue(start, end, _storeContext);
     }
 }

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java?view=diff&rev=561794&r1=561793&r2=561794
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java
Wed Aug  1 06:34:11 2007
@@ -45,7 +45,7 @@
 
     public String usage()
     {
-        return "select virtualhost <name> |exchange <name> |queue <name>
| msgs id=<msgids eg. 1,2,4-10>";
+        return "select virtualhost <name> |exchange <name> |queue <name>
| msg id=<msgids eg. 1,2,4-10>";
     }
 
     public String getCommand()



Mime
View raw message