Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 28BC610E14 for ; Tue, 21 Jan 2014 18:28:05 +0000 (UTC) Received: (qmail 34201 invoked by uid 500); 21 Jan 2014 18:28:04 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 34178 invoked by uid 500); 21 Jan 2014 18:28:04 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 34171 invoked by uid 99); 21 Jan 2014 18:28:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jan 2014 18:28:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jan 2014 18:28:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 99DE323889D5; Tue, 21 Jan 2014 18:27:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@qpid.apache.org From: gsim@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140121182739.99DE323889D5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 >::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 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) { qpid::framing::Buffer metadata(const_cast(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(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 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) { 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); ~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); void unload(qpid::sys::MemoryMappedFile&); void clear(qpid::sys::MemoryMappedFile&); size_t available() const; @@ -87,6 +89,7 @@ class PagedQueue : public Messages { std::list free; uint loaded; uint32_t version; + boost::intrusive_ptr 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 QueueFactory::c queue->messages = std::auto_ptr(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(new MessageDeque()); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org