Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-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 AC807508C for ; Tue, 10 May 2011 17:15:27 +0000 (UTC) Received: (qmail 58394 invoked by uid 500); 10 May 2011 17:15:27 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 58339 invoked by uid 500); 10 May 2011 17:15:27 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 58331 invoked by uid 99); 10 May 2011 17:15:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 May 2011 17:15:27 +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, 10 May 2011 17:15:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CA1D623888DD; Tue, 10 May 2011 17:15:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1101544 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java Date: Tue, 10 May 2011 17:15:02 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110510171502.CA1D623888DD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gtully Date: Tue May 10 17:15:02 2011 New Revision: 1101544 URL: http://svn.apache.org/viewvc?rev=1101544&view=rev Log: https://issues.apache.org/jira/browse/AMQ-3314 - FilePendingMessageCursor isFull reports full in error when temp store is full, even if not needing the temp store. have cursor report full only if memory exhausted or temp usage exhausted and temp usage is needed Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java (with props) Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java?rev=1101544&r1=1101543&r2=1101544&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java Tue May 10 17:15:02 2011 @@ -357,7 +357,7 @@ public class FilePendingMessageCursor ex @Override public synchronized boolean isFull() { - return super.isFull() || (systemUsage != null && systemUsage.getTempUsage().isFull()); + return super.isFull() || (!isDiskListEmpty() && systemUsage != null && systemUsage.getTempUsage().isFull()); } Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java?rev=1101544&view=auto ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java (added) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java Tue May 10 17:15:02 2011 @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.broker.region.cursors; + +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.QueueMessageReference; +import org.apache.activemq.store.kahadb.plist.PList; +import org.apache.activemq.usage.SystemUsage; +import org.apache.kahadb.util.ByteSequence; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class FilePendingMessageCursorTest { + + BrokerService brokerService; + FilePendingMessageCursor underTest; + + @Before + public void createBrokerWithTempStoreLimit() throws Exception { + brokerService = new BrokerService(); + SystemUsage usage = brokerService.getSystemUsage(); + usage.getTempUsage().setLimit(1025*1024*15); + + // put something in the temp store to on demand initialise it + PList dud = brokerService.getTempDataStore().getPList("dud"); + dud.addFirst("A", new ByteSequence("A".getBytes())); + } + + @Test + public void testAddToEmptyCursorWhenTempStoreIsFull() throws Exception { + + SystemUsage usage = brokerService.getSystemUsage(); + assertTrue("temp store is full: %" + usage.getTempUsage().getPercentUsage(), usage.getTempUsage().isFull()); + + underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false); + underTest.setSystemUsage(usage); + + // ok to add + underTest.addMessageLast(QueueMessageReference.NULL_MESSAGE); + + assertFalse("cursor is not full", underTest.isFull()); + } +} Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date