Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D75AF18AA2 for ; Sun, 7 Feb 2016 18:23:42 +0000 (UTC) Received: (qmail 31825 invoked by uid 500); 7 Feb 2016 18:23:37 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 31752 invoked by uid 500); 7 Feb 2016 18:23:37 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 31742 invoked by uid 99); 7 Feb 2016 18:23:37 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2016 18:23:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 4A4191A0455 for ; Sun, 7 Feb 2016 18:23:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.571 X-Spam-Level: X-Spam-Status: No, score=0.571 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.429] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id M_jQg_aewC1d for ; Sun, 7 Feb 2016 18:23:36 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 0CE0224D8F for ; Sun, 7 Feb 2016 18:23:35 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EB09EE00AF for ; Sun, 7 Feb 2016 18:23:33 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id C16483A05ED for ; Sun, 7 Feb 2016 18:23:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1729001 - in /commons/proper/jcs/trunk/commons-jcs-core/src: main/java/org/apache/commons/jcs/engine/ main/java/org/apache/commons/jcs/utils/struct/ test/java/org/apache/commons/jcs/utils/struct/ Date: Sun, 07 Feb 2016 18:23:33 -0000 To: commits@commons.apache.org From: tv@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160207182333.C16483A05ED@svn01-us-west.apache.org> Author: tv Date: Sun Feb 7 18:23:33 2016 New Revision: 1729001 URL: http://svn.apache.org/viewvc?rev=1729001&view=rev Log: Replace BoundedQueue with JDK implementation Removed: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/BoundedQueue.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/BoundedQueueUnitTest.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java?rev=1729001&r1=1729000&r2=1729001&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java Sun Feb 7 18:23:33 2016 @@ -19,18 +19,18 @@ package org.apache.commons.jcs.engine; * under the License. */ -import org.apache.commons.jcs.engine.behavior.ICacheElement; -import org.apache.commons.jcs.engine.behavior.ICacheServiceNonLocal; -import org.apache.commons.jcs.utils.struct.BoundedQueue; -import org.apache.commons.jcs.utils.timing.ElapsedTimer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentLinkedQueue; + +import org.apache.commons.jcs.engine.behavior.ICacheElement; +import org.apache.commons.jcs.engine.behavior.ICacheServiceNonLocal; +import org.apache.commons.jcs.utils.timing.ElapsedTimer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * Zombie adapter for the non local cache services. It just balks if there is no queue configured. @@ -52,14 +52,14 @@ public class ZombieCacheServiceNonLocal< private int maxQueueSize = 0; /** The queue */ - private final BoundedQueue queue; + private final ConcurrentLinkedQueue queue; /** * Default. */ public ZombieCacheServiceNonLocal() { - queue = new BoundedQueue( 0 ); + queue = new ConcurrentLinkedQueue(); } /** @@ -70,7 +70,7 @@ public class ZombieCacheServiceNonLocal< public ZombieCacheServiceNonLocal( int maxQueueSize ) { this.maxQueueSize = maxQueueSize; - queue = new BoundedQueue( maxQueueSize ); + queue = new ConcurrentLinkedQueue(); } /** @@ -83,6 +83,15 @@ public class ZombieCacheServiceNonLocal< return queue.size(); } + private void addQueue(ZombieEvent event) + { + queue.add(event); + if (queue.size() > maxQueueSize) + { + queue.poll(); // drop oldest entry + } + } + /** * Adds an update event to the queue if the maxSize is greater than 0; *

@@ -95,7 +104,7 @@ public class ZombieCacheServiceNonLocal< if ( maxQueueSize > 0 ) { PutEvent event = new PutEvent( item, listenerId ); - queue.add( event ); + addQueue( event ); } // Zombies have no inner life } @@ -113,7 +122,7 @@ public class ZombieCacheServiceNonLocal< if ( maxQueueSize > 0 ) { RemoveEvent event = new RemoveEvent( cacheName, key, listenerId ); - queue.add( event ); + addQueue( event ); } // Zombies have no inner life } @@ -130,7 +139,7 @@ public class ZombieCacheServiceNonLocal< if ( maxQueueSize > 0 ) { RemoveAllEvent event = new RemoveAllEvent( cacheName, listenerId ); - queue.add( event ); + addQueue( event ); } // Zombies have no inner life } @@ -212,7 +221,7 @@ public class ZombieCacheServiceNonLocal< cnt++; // for each item, call the appropriate service method - ZombieEvent event = queue.take(); + ZombieEvent event = queue.poll(); if ( event instanceof PutEvent ) {