activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r567647 [3/3] - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/ main/java/org/apache/activemq/broker/ main/java/org/apache/activemq/broker/jmx/ main/java/org/apache/activemq/broker/region/ main/java/org/apache/activemq/...
Date Mon, 20 Aug 2007 10:37:34 GMT
Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/TempUsage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/TempUsage.java?rev=567647&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/TempUsage.java (added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/TempUsage.java Mon
Aug 20 03:37:29 2007
@@ -0,0 +1,49 @@
+/**
+ * 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.usage;
+
+import org.apache.activemq.kaha.Store;
+
+/**
+ * Used to keep track of how much of something is being used so that a
+ * productive working set usage can be controlled.
+ * 
+ * Main use case is manage memory usage.
+ * 
+ * @org.apache.xbean.XBean
+ * 
+ * @version $Revision: 1.3 $
+ */
+public class TempUsage extends Usage{
+
+    final private Store store;
+
+        
+    public TempUsage(String name,Store store){
+        super(null,name,1.0f);
+        this.store=store;
+    }
+    
+    public TempUsage(TempUsage parent,String name){
+        super(parent,name,1.0f);
+        this.store=parent.store;
+    }
+
+    protected long retrieveUsage(){
+        return store.size();
+    }
+}
\ No newline at end of file

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/TempUsage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/TempUsage.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java?rev=567647&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java (added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java Mon Aug
20 03:37:29 2007
@@ -0,0 +1,358 @@
+/**
+ * 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.usage;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.activemq.Service;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Used to keep track of how much of something is being used so that a
+ * productive working set usage can be controlled.
+ * 
+ * Main use case is manage memory usage.
+ * 
+ * @org.apache.xbean.XBean
+ * 
+ * @version $Revision: 1.3 $
+ */
+public abstract class Usage implements Service{
+
+    private static final Log LOG=LogFactory.getLog(Usage.class);
+    protected final Object usageMutex=new Object();
+    protected int percentUsage;
+    private final Usage parent;
+    private UsageCapacity limiter = new DefaultUsageCapacity();
+    private int percentUsageMinDelta=1;
+    private final List<UsageListener> listeners=new CopyOnWriteArrayList<UsageListener>();
+    private final boolean debug=LOG.isDebugEnabled();
+    private String name="";
+    private float usagePortion=1.0f;
+    private List<Usage> children=new CopyOnWriteArrayList<Usage>();
+    private final List<Runnable> callbacks=new LinkedList<Runnable>();
+    private int pollingTime = 100;
+   
+    public Usage(Usage parent,String name,float portion){
+        this.parent=parent;
+        this.usagePortion=portion;
+        if(parent!=null){
+            this.limiter.setLimit((long)(parent.getLimit()*portion));
+            this.name=parent.name+":";
+        }
+        this.name+=name;
+    }
+
+    protected abstract long retrieveUsage();
+
+    /**
+     * @throws InterruptedException
+     */
+    public void waitForSpace() throws InterruptedException{
+        waitForSpace(0);
+    }
+
+    /**
+     * @param timeout 
+     * @throws InterruptedException
+     * 
+     * @return true if space
+     */
+    public boolean waitForSpace(long timeout) throws InterruptedException{
+        if(parent!=null){
+            if(!parent.waitForSpace(timeout)){
+                return false;
+            }
+        }
+        synchronized(usageMutex){
+            caclPercentUsage();
+            if(percentUsage>=100){
+                long deadline=timeout>0?System.currentTimeMillis()+timeout:Long.MAX_VALUE;
+                long timeleft=deadline;
+                while(timeleft>0){
+                    caclPercentUsage();
+                    if(percentUsage>=100){
+                        usageMutex.wait(pollingTime);
+                        timeleft=deadline-System.currentTimeMillis();
+                    }else{
+                        break;
+                    }
+                }
+            }
+            return percentUsage<100;
+        }
+    }
+
+    
+
+    public boolean isFull(){
+        if(parent!=null&&parent.isFull()){
+            return true;
+        }
+        synchronized(usageMutex){
+            caclPercentUsage();
+            return percentUsage>=100;
+        }
+    }
+
+    public void addUsageListener(UsageListener listener){
+        listeners.add(listener);
+    }
+
+    public void removeUsageListener(UsageListener listener){
+        listeners.remove(listener);
+    }
+
+    public long getLimit(){
+        synchronized(usageMutex){
+            return limiter.getLimit();
+        }
+    }
+
+    /**
+     * Sets the memory limit in bytes. Setting the limit in bytes will set the
+     * usagePortion to 0 since the UsageManager is not going to be portion based
+     * off the parent.
+     * 
+     * When set using XBean, you can use values such as: "20 mb", "1024 kb", or
+     * "1 gb"
+     * 
+     * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor"
+     */
+    public void setLimit(long limit){
+        if(percentUsageMinDelta<0){
+            throw new IllegalArgumentException("percentUsageMinDelta must be greater or equal
to 0");
+        }
+        synchronized(usageMutex){
+            this.limiter.setLimit(limit);
+            this.usagePortion=0;
+        }
+        onLimitChange();
+    }
+
+    private void onLimitChange(){
+        // We may need to calculate the limit
+        if(usagePortion>0&&parent!=null){
+            synchronized(usageMutex){
+                this.limiter.setLimit((long)(parent.getLimit()*usagePortion));
+            }
+        }
+        // Reset the percent currently being used.
+        int percentUsage;
+        synchronized(usageMutex){
+            percentUsage=caclPercentUsage();
+        }
+        setPercentUsage(percentUsage);
+        // Let the children know that the limit has changed. They may need to
+        // set
+        // their limits based on ours.
+        for(Usage child:children){
+            child.onLimitChange();
+        }
+    }
+
+    public float getUsagePortion(){
+        synchronized(usageMutex){
+            return usagePortion;
+        }
+    }
+
+    public void setUsagePortion(float usagePortion){
+        synchronized(usageMutex){
+            this.usagePortion=usagePortion;
+        }
+        onLimitChange();
+    }
+
+    /*
+     * Sets the minimum number of percentage points the usage has to change
+     * before a UsageListener event is fired by the manager.
+     */
+    public int getPercentUsage(){
+        synchronized(usageMutex){
+            return percentUsage;
+        }
+    }
+
+    public int getPercentUsageMinDelta(){
+        synchronized(usageMutex){
+            return percentUsageMinDelta;
+        }
+    }
+
+    /**
+     * Sets the minimum number of percentage points the usage has to change
+     * before a UsageListener event is fired by the manager.
+     * 
+     * @param percentUsageMinDelta
+     */
+    public void setPercentUsageMinDelta(int percentUsageMinDelta){
+        if(percentUsageMinDelta<1){
+            throw new IllegalArgumentException("percentUsageMinDelta must be greater than
0");
+        }
+        int percentUsage;
+        synchronized(usageMutex){
+            this.percentUsageMinDelta=percentUsageMinDelta;
+            percentUsage=caclPercentUsage();
+        }
+        setPercentUsage(percentUsage);
+    }
+
+    public long getUsage(){
+        synchronized(usageMutex){
+            return retrieveUsage();
+        }
+    }
+
+    protected void setPercentUsage(int value){
+        synchronized(usageMutex){
+            int oldValue=percentUsage;
+            percentUsage=value;
+            if(oldValue!=value){
+                fireEvent(oldValue,value);
+            }
+        }
+    }
+
+    protected int caclPercentUsage(){
+        if(limiter.getLimit()==0){
+            return 0;
+        }
+        return (int)((((retrieveUsage()*100)/limiter.getLimit())/percentUsageMinDelta)*percentUsageMinDelta);
+    }
+
+    private void fireEvent(int oldPercentUsage,int newPercentUsage){
+        if(debug){
+            LOG.debug("Memory usage change.  from: "+oldPercentUsage+", to: "+newPercentUsage);
+        }
+        // Switching from being full to not being full..
+        if(oldPercentUsage>=100&&newPercentUsage<100){
+            synchronized(usageMutex){
+                usageMutex.notifyAll();
+                for(Iterator<Runnable> iter=new ArrayList<Runnable>(callbacks).iterator();iter.hasNext();){
+                    Runnable callback=iter.next();
+                    callback.run();
+                }
+                callbacks.clear();
+            }
+        }
+        // Let the listeners know
+        for(Iterator<UsageListener> iter=listeners.iterator();iter.hasNext();){
+            UsageListener l=iter.next();
+            l.onUsageChanged(this,oldPercentUsage,newPercentUsage);
+        }
+    }
+
+    public String getName(){
+        return name;
+    }
+
+    public String toString(){
+        return "Usage("+getName()+") percentUsage="+percentUsage+"%, usage="+retrieveUsage()+"
limit="+limiter.getLimit()
+                +" percentUsageMinDelta="+percentUsageMinDelta+"%";
+    }
+
+    public void start(){
+        if(parent!=null){
+            parent.addChild(this);
+        }
+    }
+
+    public void stop(){
+        if(parent!=null){
+            parent.removeChild(this);
+        }
+    }
+
+    private void addChild(Usage child){
+        children.add(child);
+    }
+
+    private void removeChild(Usage child){
+        children.remove(child);
+    }
+
+    /**
+     * @param callback
+     * @return true if the UsageManager was full. The callback will only be
+     *         called if this method returns true.
+     */
+    public boolean notifyCallbackWhenNotFull(final Runnable callback){
+        if(parent!=null){
+            Runnable r=new Runnable(){
+
+                public void run(){
+                    synchronized(usageMutex){
+                        if(percentUsage>=100){
+                            callbacks.add(callback);
+                        }else{
+                            callback.run();
+                        }
+                    }
+                }
+            };
+            if(parent.notifyCallbackWhenNotFull(r)){
+                return true;
+            }
+        }
+        synchronized(usageMutex){
+            if(percentUsage>=100){
+                callbacks.add(callback);
+                return true;
+            }else{
+                return false;
+            }
+        }
+    }
+
+    
+    /**
+     * @return the limiter
+     */
+    public UsageCapacity getLimiter(){
+        return this.limiter;
+    }
+
+    
+    /**
+     * @param limiter the limiter to set
+     */
+    public void setLimiter(UsageCapacity limiter){
+        this.limiter=limiter;
+    }
+
+    
+    /**
+     * @return the pollingTime
+     */
+    public int getPollingTime(){
+        return this.pollingTime;
+    }
+
+    
+    /**
+     * @param pollingTime the pollingTime to set
+     */
+    public void setPollingTime(int pollingTime){
+        this.pollingTime=pollingTime;
+    }
+}

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageCapacity.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageCapacity.java?rev=567647&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageCapacity.java
(added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageCapacity.java
Mon Aug 20 03:37:29 2007
@@ -0,0 +1,48 @@
+/**
+ * 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.usage;
+
+
+
+/**
+ Identify if a limit has been reached
+ * 
+ * @org.apache.xbean.XBean
+ * 
+ * @version $Revision: 1.3 $
+ */
+public interface UsageCapacity{
+
+    /**
+     * Has the limit been reached ?
+     * 
+     * @param size
+     * @return true if it has
+     */
+    boolean isLimit(long size);
+    
+    
+    /**
+     * @return the limit
+     */
+    long getLimit();
+    
+    /**
+     * @param limit the limit to set
+     */
+    void setLimit(long limit);
+}

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageCapacity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageCapacity.java
------------------------------------------------------------------------------
    svn:executable = *

Copied: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageListener.java
(from r565381, activemq/trunk/activemq-core/src/main/java/org/apache/activemq/memory/UsageListener.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageListener.java?p2=activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageListener.java&p1=activemq/trunk/activemq-core/src/main/java/org/apache/activemq/memory/UsageListener.java&r1=565381&r2=567647&rev=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/memory/UsageListener.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/UsageListener.java
Mon Aug 20 03:37:29 2007
@@ -14,8 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.memory;
+package org.apache.activemq.usage;
 
 public interface UsageListener {
-    void onMemoryUseChanged(UsageManager memoryManager, int oldPercentUsage, int newPercentUsage);
+    void onUsageChanged(Usage usage, int oldPercentUsage, int newPercentUsage);
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java Mon
Aug 20 03:37:29 2007
@@ -41,10 +41,10 @@
 import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.activemq.usage.SystemUsage;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.jms.core.JmsTemplate;
@@ -238,9 +238,9 @@
         brokerService.setPersistent(false);
         brokerService.setUseJmx(true);
 
-        final UsageManager memoryManager = new UsageManager();
-        memoryManager.setLimit(5000000);
-        brokerService.setMemoryManager(memoryManager);
+        final SystemUsage memoryManager = new SystemUsage();
+        memoryManager.getMemoryUsage().setLimit(5000000);
+        brokerService.setUsageManager(memoryManager);
 
         final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
Mon Aug 20 03:37:29 2007
@@ -51,8 +51,8 @@
 import org.apache.activemq.command.TransactionId;
 import org.apache.activemq.command.TransactionInfo;
 import org.apache.activemq.command.XATransactionId;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.usage.SystemUsage;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -74,7 +74,7 @@
 
     protected int maxWait = 4000;
 
-    protected UsageManager memoryManager;
+    protected SystemUsage memoryManager;
 
     protected void setUp() throws Exception {
         super.setUp();

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java
Mon Aug 20 03:37:29 2007
@@ -91,7 +91,7 @@
 
         // Reduce the limit so that only 1 message can flow through the broker
         // at a time.
-        broker.getMemoryManager().setLimit(1);
+        broker.getUsageManager().getMemoryUsage().setLimit(1);
 
         final Message m1 = createMessage(producerInfo, destination, deliveryMode);
         final Message m2 = createMessage(producerInfo, destination, deliveryMode, 1000);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
Mon Aug 20 03:37:29 2007
@@ -32,12 +32,12 @@
 import org.apache.activemq.broker.region.policy.SubscriptionRecoveryPolicy;
 import org.apache.activemq.broker.region.policy.TimedSubscriptionRecoveryPolicy;
 import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
 import org.apache.activemq.store.journal.JournalPersistenceAdapter;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
 import org.apache.activemq.transport.tcp.TcpTransportServer;
+import org.apache.activemq.usage.SystemUsage;
 import org.apache.activemq.wireformat.ObjectStreamWireFormat;
 import org.apache.activemq.xbean.BrokerFactoryBean;
 import org.apache.commons.logging.Log;
@@ -233,10 +233,10 @@
 
             // Check usage manager
             // System.out.print("Checking memory manager configurations... ");
-            UsageManager memMgr = broker.getMemoryManager();
+            SystemUsage memMgr = broker.getUsageManager();
             assertTrue("Should have a memory manager", memMgr != null);
-            assertEquals("UsageManager Config Error (limit)", 200000, memMgr.getLimit());
-            assertEquals("UsageManager Config Error (percentUsageMinDelta)", 20, memMgr.getPercentUsageMinDelta());
+            assertEquals("UsageManager Config Error (limit)", 200000, memMgr.getMemoryUsage().getLimit());
+            assertEquals("UsageManager Config Error (percentUsageMinDelta)", 20, memMgr.getMemoryUsage().getPercentUsageMinDelta());
             LOG.info("Success");
 
             LOG.info("Success");

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/hash/HashTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/hash/HashTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/hash/HashTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/hash/HashTest.java
Mon Aug 20 03:37:29 2007
@@ -18,12 +18,14 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
 import junit.framework.TestCase;
 import org.apache.activemq.kaha.Store;
 import org.apache.activemq.kaha.impl.index.IndexItem;
 import org.apache.activemq.kaha.impl.index.IndexManager;
 import org.apache.activemq.util.IOHelper;
 
+
 /**
  * Test a HashIndex
  */
@@ -42,7 +44,7 @@
         super.setUp();
         directory = new File(IOHelper.getDefaultDataDirectory());
         directory.mkdirs();
-        indexManager = new IndexManager(directory, "im-hash-test", "rw", null);
+        indexManager = new IndexManager(directory, "im-hash-test", "rw", null, new AtomicLong());
         this.hashIndex = new HashIndex(directory, "testHash", indexManager);
         this.hashIndex.setKeyMarshaller(Store.STRING_MARSHALLER);
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/tree/TreeTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/tree/TreeTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/tree/TreeTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/tree/TreeTest.java
Mon Aug 20 03:37:29 2007
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
 
 import junit.framework.TestCase;
 import org.apache.activemq.kaha.Store;
@@ -43,7 +44,7 @@
         super.setUp();
         directory = new File("activemq-data");
         directory.mkdirs();
-        indexManager = new IndexManager(directory, "im-test", "rw", null);
+        indexManager = new IndexManager(directory, "im-test", "rw", null,new AtomicLong());
         this.tree = new TreeIndex(directory, "testTree", indexManager);
         this.tree.setKeyMarshaller(Store.STRING_MARSHALLER);
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java
Mon Aug 20 03:37:29 2007
@@ -19,6 +19,8 @@
 import junit.framework.TestCase;
 
 import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.memory.buffer.MessageBuffer;
+import org.apache.activemq.memory.buffer.MessageQueue;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java
Mon Aug 20 03:37:29 2007
@@ -16,6 +16,9 @@
  */
 package org.apache.activemq.memory.buffer;
 
+import org.apache.activemq.memory.buffer.MessageBuffer;
+import org.apache.activemq.memory.buffer.OrderBasedMessageBuffer;
+
 
 /**
  *

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java
Mon Aug 20 03:37:29 2007
@@ -16,6 +16,9 @@
  */
 package org.apache.activemq.memory.buffer;
 
+import org.apache.activemq.memory.buffer.MessageBuffer;
+import org.apache.activemq.memory.buffer.SizeBasedMessageBuffer;
+
 
 /**
  *

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkTestSupport.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkTestSupport.java
Mon Aug 20 03:37:29 2007
@@ -28,11 +28,11 @@
 import org.apache.activemq.broker.BrokerTestSupport;
 import org.apache.activemq.broker.StubConnection;
 import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.usage.SystemUsage;
 
 public class NetworkTestSupport extends BrokerTestSupport {
 
@@ -42,7 +42,7 @@
 
     protected PersistenceAdapter remotePersistenceAdapter;
     protected BrokerService remoteBroker;
-    protected UsageManager remoteMemoryManager;
+    protected SystemUsage remoteMemoryManager;
     protected TransportConnector remoteConnector;
 
     protected void setUp() throws Exception {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java
Mon Aug 20 03:37:29 2007
@@ -24,10 +24,10 @@
 import org.apache.activemq.broker.BrokerTestSupport;
 import org.apache.activemq.broker.StubConnection;
 import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.usage.SystemUsage;
 
 public class ProxyTestSupport extends BrokerTestSupport {
 
@@ -37,7 +37,7 @@
 
     protected PersistenceAdapter remotePersistenceAdapter;
     protected BrokerService remoteBroker;
-    protected UsageManager remoteMemoryManager;
+    protected SystemUsage remoteMemoryManager;
     protected TransportConnector remoteConnector;
     private ProxyConnector proxyConnector;
     private ProxyConnector remoteProxyConnector;

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQDeadlockTestW4Brokers.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQDeadlockTestW4Brokers.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQDeadlockTestW4Brokers.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQDeadlockTestW4Brokers.java
Mon Aug 20 03:37:29 2007
@@ -40,10 +40,10 @@
 import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.activemq.usage.SystemUsage;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.jms.core.JmsTemplate;
@@ -173,9 +173,9 @@
         brokerService.setPersistent(false);
         brokerService.setUseJmx(true);
 
-        final UsageManager memoryManager = new UsageManager();
-        memoryManager.setLimit(100000000);
-        brokerService.setMemoryManager(memoryManager);
+        final SystemUsage memoryManager = new SystemUsage();
+        memoryManager.getMemoryUsage().setLimit(100000000);
+        brokerService.setUsageManager(memoryManager);
 
         final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQFailoverIssue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQFailoverIssue.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQFailoverIssue.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQFailoverIssue.java
Mon Aug 20 03:37:29 2007
@@ -39,10 +39,10 @@
 import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.activemq.usage.SystemUsage;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.core.MessageCreator;
 import org.springframework.jms.listener.DefaultMessageListenerContainer;
@@ -106,9 +106,9 @@
         brokerService.setBrokerName(brokerName);
         brokerService.setPersistent(false);
         brokerService.setUseJmx(true);
-        final UsageManager memoryManager = new UsageManager();
-        memoryManager.setLimit(5000000);
-        brokerService.setMemoryManager(memoryManager);
+        final SystemUsage memoryManager = new SystemUsage();
+        memoryManager.getMemoryUsage().setLimit(5000000);
+        brokerService.setUsageManager(memoryManager);
         final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
         final PolicyEntry entry = new PolicyEntry();
         entry.setQueue(">");

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java?rev=567647&r1=567646&r2=567647&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java
Mon Aug 20 03:37:29 2007
@@ -33,9 +33,9 @@
 import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.activemq.network.NetworkConnector;
+import org.apache.activemq.usage.SystemUsage;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.core.MessageCreator;
 
@@ -117,9 +117,9 @@
         brokerService.setPersistent(false);
         brokerService.setUseJmx(true);
 
-        final UsageManager memoryManager = new UsageManager();
-        memoryManager.setLimit(10);
-        brokerService.setMemoryManager(memoryManager);
+        final SystemUsage memoryManager = new SystemUsage();
+        memoryManager.getMemoryUsage().setLimit(10);
+        brokerService.setUsageManager(memoryManager);
 
         final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
 



Mime
View raw message