qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r682710 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/broker/Queue.cpp cpp/src/qpid/broker/Queue.h specs/management-schema.xml
Date Tue, 05 Aug 2008 13:39:05 GMT
Author: tross
Date: Tue Aug  5 06:39:04 2008
New Revision: 682710

URL: http://svn.apache.org/viewvc?rev=682710&view=rev
Log:
QPID-1214 - Committed William's patch

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h
    incubator/qpid/trunk/qpid/specs/management-schema.xml

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp?rev=682710&r1=682709&r2=682710&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp Tue Aug  5 06:39:04 2008
@@ -31,6 +31,7 @@
 #include "qpid/framing/reply_exceptions.h"
 #include "qpid/sys/Monitor.h"
 #include "qpid/sys/Time.h"
+#include "qpid/management/ArgsQueuePurge.h"
 
 #include <iostream>
 #include <algorithm>
@@ -372,11 +373,24 @@
     return msg;
 }
 
-uint32_t Queue::purge(){
+/**
+ * purge - for purging all or some messages on a queue
+ *         depending on the purge_request
+ *
+ * purge_request == 0 then purge all messages
+ *               == N then purge N messages from queue
+ * Sometimes purge_request == 1 to unblock the top of queue
+ */
+uint32_t Queue::purge(const uint32_t purge_request){
     Mutex::ScopedLock locker(messageLock);
-    int count = messages.size();
-    while(!messages.empty()) {
+    uint32_t purge_count = purge_request; // only comes into play if  >0 
+
+    uint32_t count = 0;
+    // Either purge them all or just the some (purge_count) while the queue isn't empty.
+    while((!purge_request || purge_count--) && !messages.empty()) 
+    {
         popAndDequeue();
+	count++;
     }
     return count;
 }
@@ -710,7 +724,7 @@
 }
 
 Manageable::status_t Queue::ManagementMethod (uint32_t methodId,
-                                              Args&    /*args*/)
+                                              Args&    args)
 {
     Manageable::status_t status = Manageable::STATUS_UNKNOWN_METHOD;
 
@@ -719,7 +733,8 @@
     switch (methodId)
     {
     case management::Queue::METHOD_PURGE :
-        purge ();
+      management::ArgsQueuePurge iargs = dynamic_cast<const management::ArgsQueuePurge&>(args);
+        purge (iargs.i_request);
         status = Manageable::STATUS_OK;
         break;
     }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h?rev=682710&r1=682709&r2=682710&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h Tue Aug  5 06:39:04 2008
@@ -161,7 +161,8 @@
             void consume(Consumer& c, bool exclusive = false);
             void cancel(Consumer& c);
 
-            uint32_t purge();
+            uint32_t purge(const uint32_t purge_request = 0); //defaults to all messages

+
             uint32_t getMessageCount() const;
             uint32_t getConsumerCount() const;
             inline const string& getName() const { return name; }

Modified: incubator/qpid/trunk/qpid/specs/management-schema.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/specs/management-schema.xml?rev=682710&r1=682709&r2=682710&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/specs/management-schema.xml (original)
+++ incubator/qpid/trunk/qpid/specs/management-schema.xml Tue Aug  5 06:39:04 2008
@@ -160,7 +160,9 @@
     <statistic name="unackedMessages"     type="hilo32"   unit="message"     desc="Messages
consumed but not yet acked"/>
     <statistic name="messageLatency"      type="mmaTime"  unit="nanosecond"  desc="Broker
latency through this queue"/>
 
-    <method name="purge" desc="Discard all messages on queue"/>
+    <method name="purge" desc="Discard all or some messages on a queue">
+      <arg name="request"          dir="I" type="uint32" desc="0 for all messages or n>0
for n messages"/>
+    </method>
   </class>
 
   <!--



Mime
View raw message