Return-Path: Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: (qmail 34990 invoked from network); 2 Apr 2009 11:20:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Apr 2009 11:20:59 -0000 Received: (qmail 91587 invoked by uid 500); 2 Apr 2009 11:20:59 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 91562 invoked by uid 500); 2 Apr 2009 11:20:59 -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 91553 invoked by uid 99); 2 Apr 2009 11:20:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2009 11:20:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Thu, 02 Apr 2009 11:20:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 989E82388A04; Thu, 2 Apr 2009 11:20:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r761251 - in /qpid/branches/0.5-release/qpid/java/broker/src: main/java/org/apache/qpid/server/queue/MessageFactory.java test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java Date: Thu, 02 Apr 2009 11:20:36 -0000 To: commits@qpid.apache.org From: ritchiem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090402112036.989E82388A04@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ritchiem Date: Thu Apr 2 11:20:36 2009 New Revision: 761251 URL: http://svn.apache.org/viewvc?rev=761251&view=rev Log: QPID-1783 : Relax MessageFactory to allow out of order recovery Relax MessageFactory to allow out of order. Updated test Merging trunk r760952 Modified: qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java qpid/branches/0.5-release/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java Modified: qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java?rev=761251&r1=761250&r2=761251&view=diff ============================================================================== --- qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java (original) +++ qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java Thu Apr 2 11:20:36 2009 @@ -85,17 +85,13 @@ throw new RuntimeException("Unable to create message by ID when not recovering"); } - long currentID = _messageId.get(); - if (messageId <= currentID) + if (messageId < 0L) { - throw new RuntimeException("Message IDs can only increase current id is:" - + currentID + ". Requested:" + messageId); - } - else - { - _messageId.set(messageId); + throw new RuntimeException("Message IDs can only be positive. Requested:" + messageId); } + _messageId.set((int)Math.max(messageId, _messageId.get())); + return createNextMessage(messageId, transactionLog, true); } Modified: qpid/branches/0.5-release/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java?rev=761251&r1=761250&r2=761251&view=diff ============================================================================== --- qpid/branches/0.5-release/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java (original) +++ qpid/branches/0.5-release/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java Thu Apr 2 11:20:36 2009 @@ -41,29 +41,41 @@ try { - _factory.createMessage(messasgeID, null); - fail("Cannot recreate message with an existing id"); + _factory.createMessage(-1L, null); + fail("Cannot recreate message with a negative id"); } catch (RuntimeException re) { assertEquals("Incorrect exception thrown ", - "Message IDs can only increase current id is:" + messasgeID + ". Requested:" + messasgeID, re.getMessage()); + "Message IDs can only be positive. Requested:-1", re.getMessage()); } - //Check we cannot go backwords with ids. + //Check we CAN go backwords with ids. try { - _factory.createMessage(messasgeID - 1, null); - fail("Cannot recreate message with an old id"); + _factory.createMessage(messasgeID - 1, null); } catch (RuntimeException re) { - assertEquals("Incorrect exception thrown ", - "Message IDs can only increase current id is:" + messasgeID + ". Requested:" + (messasgeID - 1), re.getMessage()); + fail(re.getMessage()); } //Check that we can jump forward in ids during recovery. messasgeID += 100; + Long highestID=messasgeID; + try + { + AMQMessage message = _factory.createMessage(messasgeID, null); + assertEquals("Factory assigned incorrect id.", messasgeID, message.getMessageId()); + } + catch (Exception re) + { + fail("Message with a much higher value should be created"); + } + + + //Check that we can jump backwards in ids during recovery. + messasgeID -= 75; try { AMQMessage message = _factory.createMessage(messasgeID, null); @@ -91,12 +103,12 @@ // Check that the next message created has the next available id - messasgeID++; + highestID++; try { AMQMessage message = _factory.createMessage(null, false); - assertEquals("Factory assigned incorrect id.", messasgeID, message.getMessageId()); + assertEquals("Factory assigned incorrect id.", highestID, message.getMessageId()); } catch (Exception re) { --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscribe@qpid.apache.org