qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1560126 - in /qpid/trunk/qpid/cpp/src/qpid/broker: Exchange.cpp PagedQueue.cpp PagedQueue.h QueueFactory.cpp
Date Tue, 21 Jan 2014 18:27:39 GMT
Author: gsim
Date: Tue Jan 21 18:27:39 2014
New Revision: 1560126

URL: http://svn.apache.org/r1560126
Log:
QPID-5498: restore expiration on paged messages

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.h
    qpid/trunk/qpid/cpp/src/qpid/broker/QueueFactory.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp?rev=1560126&r1=1560125&r2=1560126&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp Tue Jan 21 18:27:39 2014
@@ -476,7 +476,7 @@ void Exchange::destroy()
         deletionListeners.swap(copy);
     }
     for (std::map<std::string, boost::function0<void> >::iterator i = copy.begin();
i != copy.end(); ++i) {
-        QPID_LOG(notice, "Exchange::destroy() notifying " << i->first);
+        QPID_LOG(debug, "Exchange::destroy() notifying " << i->first);
         if (i->second) i->second();
     }
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp?rev=1560126&r1=1560125&r2=1560126&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp Tue Jan 21 18:27:39 2014
@@ -24,13 +24,18 @@
 #include "qpid/broker/Message.h"
 #include "qpid/log/Statement.h"
 #include "qpid/framing/reply_exceptions.h"
+#include "qpid/sys/Time.h"
 #include <string.h>
 
 namespace qpid {
 namespace broker {
 namespace {
+using qpid::sys::AbsTime;
+using qpid::sys::Duration;
+using qpid::sys::EPOCH;
+using qpid::sys::FAR_FUTURE;
 using qpid::sys::MemoryMappedFile;
-const uint32_t OVERHEAD(4/*content-size*/ + 4/*sequence-number*/ + 8/*persistence-id*/);
+const uint32_t OVERHEAD(4/*content-size*/ + 4/*sequence-number*/ + 8/*persistence-id*/ +
8/*expiration*/);
 
 size_t encodedSize(const Message& msg)
 {
@@ -46,30 +51,45 @@ size_t encode(const Message& msg, char* 
     buffer.putLong(encoded);
     buffer.putLong(msg.getSequence());
     buffer.putLongLong(msg.getPersistentContext()->getPersistenceId());
+    sys::AbsTime expiration = msg.getExpiration();
+    int64_t t(0);
+    if (expiration < FAR_FUTURE) {
+        t = Duration(EPOCH, expiration);
+    }
+    buffer.putLongLong(t);
     msg.getPersistentContext()->encode(buffer);
     assert(buffer.getPosition() == required);
     return required;
 }
 
-size_t decode(ProtocolRegistry& protocols, Message& msg, const char* data, size_t
size)
+size_t decode(ProtocolRegistry& protocols, Message& msg, const char* data, size_t
size,
+              boost::intrusive_ptr<ExpiryPolicy> expiryPolicy)
 {
     qpid::framing::Buffer metadata(const_cast<char*>(data), size);
     uint32_t encoded = metadata.getLong();
     uint32_t sequence = metadata.getLong();
     uint64_t persistenceId = metadata.getLongLong();
+    int64_t t = metadata.getLongLong();
     assert(metadata.available() >= encoded);
     qpid::framing::Buffer buffer(const_cast<char*>(data) + metadata.getPosition(),
encoded);
     msg = protocols.decode(buffer);
     assert(buffer.getPosition() == encoded);
     msg.setSequence(qpid::framing::SequenceNumber(sequence));
     msg.getPersistentContext()->setPersistenceId(persistenceId);
+    if (t) {
+        sys::AbsTime expiration(EPOCH, t);
+        msg.setExpiryPolicy(expiryPolicy);
+        msg.setExpiration(expiration);
+    }
     return encoded + metadata.getPosition();
 }
 
 }
 
-PagedQueue::PagedQueue(const std::string& name_, const std::string& directory, uint
m, uint factor, ProtocolRegistry& p)
-    : name(name_), pageSize(file.getPageSize()*factor), maxLoaded(m), protocols(p), offset(0),
loaded(0), version(0)
+PagedQueue::PagedQueue(const std::string& name_, const std::string& directory, uint
m, uint factor, ProtocolRegistry& p,
+                       boost::intrusive_ptr<ExpiryPolicy> e)
+    : name(name_), pageSize(file.getPageSize()*factor), maxLoaded(m), protocols(p), offset(0),
loaded(0), version(0),
+      expiryPolicy(e)
 {
     path = file.open(name, directory);
     QPID_LOG(debug, "PagedQueue[" << path << "]");
@@ -299,7 +319,7 @@ Message* PagedQueue::Page::find(qpid::fr
     //if it is the last in the page, decrement the hint count of the page
 }
 
-void PagedQueue::Page::load(MemoryMappedFile& file, ProtocolRegistry& protocols)
+void PagedQueue::Page::load(MemoryMappedFile& file, ProtocolRegistry& protocols,
boost::intrusive_ptr<ExpiryPolicy> expiryPolicy)
 {
     QPID_LOG(debug, "Page[" << offset << "]::load" << " used=" <<
used << ", size=" << size);
     assert(region == 0);
@@ -313,7 +333,7 @@ void PagedQueue::Page::load(MemoryMapped
         //decode messages into Page::messages
         for (size_t i = 0; i < count; ++i) {
             Message message;
-            used += decode(protocols, message, region + used, size - used);
+            used += decode(protocols, message, region + used, size - used, expiryPolicy);
             if (!contents.contains(message.getSequence())) {
                 message.setState(DELETED);
                 QPID_LOG(debug, "Setting state to deleted for message loaded at " <<
message.getSequence());
@@ -366,7 +386,7 @@ void PagedQueue::load(Page& page)
         assert(i != used.rend());
         unload(i->second);
     }
-    page.load(file, protocols);
+    page.load(file, protocols, expiryPolicy);
     ++loaded;
     QPID_LOG(debug, "PagedQueue[" << path << "] loaded page, " << loaded
<< " pages now loaded");
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.h?rev=1560126&r1=1560125&r2=1560126&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.h Tue Jan 21 18:27:39 2014
@@ -31,13 +31,15 @@
 
 namespace qpid {
 namespace broker {
+class ExpiryPolicy;
 class ProtocolRegistry;
 /**
  *
  */
 class PagedQueue : public Messages {
   public:
-    PagedQueue(const std::string& name, const std::string& directory, uint maxLoaded,
uint pageFactor, ProtocolRegistry& protocols);
+    PagedQueue(const std::string& name, const std::string& directory, uint maxLoaded,
uint pageFactor, ProtocolRegistry& protocols,
+               boost::intrusive_ptr<ExpiryPolicy>);
     ~PagedQueue();
     size_t size();
     bool deleted(const QueueCursor&);
@@ -60,7 +62,7 @@ class PagedQueue : public Messages {
         bool add(const Message&);
         Message* next(uint32_t version, QueueCursor&);
         Message* find(qpid::framing::SequenceNumber);
-        void load(qpid::sys::MemoryMappedFile&,ProtocolRegistry&);
+        void load(qpid::sys::MemoryMappedFile&,ProtocolRegistry&, boost::intrusive_ptr<ExpiryPolicy>);
         void unload(qpid::sys::MemoryMappedFile&);
         void clear(qpid::sys::MemoryMappedFile&);
         size_t available() const;
@@ -87,6 +89,7 @@ class PagedQueue : public Messages {
     std::list<Page> free;
     uint loaded;
     uint32_t version;
+    boost::intrusive_ptr<ExpiryPolicy> expiryPolicy;//needed on reload
 
     void addPages(size_t count);
     Page& newPage(qpid::framing::SequenceNumber);

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/QueueFactory.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/QueueFactory.cpp?rev=1560126&r1=1560125&r2=1560126&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/QueueFactory.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/QueueFactory.cpp Tue Jan 21 18:27:39 2014
@@ -80,7 +80,7 @@ boost::shared_ptr<Queue> QueueFactory::c
             queue->messages = std::auto_ptr<Messages>(new PagedQueue(name, broker->getPagingDirectoryPath(),
                                                                      settings.maxPages ?
settings.maxPages : 4,
                                                                      settings.pageFactor
? settings.pageFactor : 1,
-                                                                     broker->getProtocolRegistry()));
+                                                                     broker->getProtocolRegistry(),
broker->getExpiryPolicy()));
         }
     } else if (settings.lvqKey.empty()) {//LVQ already handled above
         queue->messages = std::auto_ptr<Messages>(new MessageDeque());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message