activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r656574 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/kaha/ main/java/org/apache/activemq/kaha/impl/container/ main/java/org/apache/activemq/kaha/impl/index/hash/ main/java/org/apache/activemq/store/amq/ main/java/or...
Date Thu, 15 May 2008 09:42:36 GMT
Author: rajdavies
Date: Thu May 15 02:42:35 2008
New Revision: 656574

URL: http://svn.apache.org/viewvc?rev=656574&view=rev
Log:
Expose load factor for HashIndex in Kaha

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/MapContainerImpl.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java?rev=656574&r1=656573&r2=656574&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java
Thu May 15 02:42:35 2008
@@ -262,13 +262,22 @@
     /**
      * set the meximum bin size
      */
-    void setMaxBinSize(int size);
+    void setIndexMaxBinSize(int size);
     
     /**
      * @return the maximum bin size
      * @return
      */
-    int getMaxBinSize();
+    int getIndexMaxBinSize();
+    
+    /**
+     * @return the loadFactor
+     */
+    public int getIndexLoadFactor();
+    /**
+     * @param loadFactor the loadFactor to set
+     */
+    public void setIndexLoadFactor(int loadFactor);
     
     /**
      * @return the Index MBean

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/MapContainerImpl.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/MapContainerImpl.java?rev=656574&r1=656573&r2=656574&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/MapContainerImpl.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/MapContainerImpl.java
Thu May 15 02:42:35 2008
@@ -58,7 +58,8 @@
     private int indexBinSize = HashIndex.DEFAULT_BIN_SIZE;
     private int indexKeySize = HashIndex.DEFAULT_KEY_SIZE;
     private int indexPageSize = HashIndex.DEFAULT_PAGE_SIZE;
-    private int maxBinSize = HashIndex.MAXIMUM_CAPACITY;
+    private int indexMaxBinSize = HashIndex.MAXIMUM_CAPACITY;
+    private int indexLoadFactor = HashIndex.DEFAULT_LOAD_FACTOR;
 
     public MapContainerImpl(File directory, ContainerId id, IndexItem root, IndexManager
indexManager,
                             DataManager dataManager, boolean persistentIndex) {
@@ -77,7 +78,8 @@
                     hashIndex.setNumberOfBins(getIndexBinSize());
                     hashIndex.setKeySize(getIndexKeySize());
                     hashIndex.setPageSize(getIndexPageSize());
-                    hashIndex.setMaximumCapacity(getMaxBinSize());
+                    hashIndex.setMaximumCapacity(getIndexMaxBinSize());
+                    hashIndex.setLoadFactor(getIndexLoadFactor());
                     this.index = hashIndex;
                 } catch (IOException e) {
                     LOG.error("Failed to create HashIndex", e);
@@ -563,18 +565,26 @@
     public void setIndexPageSize(int indexPageSize) {
         this.indexPageSize = indexPageSize;
     }
+    
+    public int getIndexLoadFactor() {
+        return indexLoadFactor;
+    }
+
+    public void setIndexLoadFactor(int loadFactor) {
+        this.indexLoadFactor = loadFactor;
+    }
 
   
     public IndexMBean getIndexMBean() {
       return (IndexMBean) index;
     }
   
-    public int getMaxBinSize() {
-        return maxBinSize;
+    public int getIndexMaxBinSize() {
+        return indexMaxBinSize;
     }
 
-    public void setMaxBinSize(int maxBinSize) {
-        this.maxBinSize = maxBinSize;
+    public void setIndexMaxBinSize(int maxBinSize) {
+        this.indexMaxBinSize = maxBinSize;
     }
    
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java?rev=656574&r1=656573&r2=656574&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
Thu May 15 02:42:35 2008
@@ -42,11 +42,8 @@
     public static final int DEFAULT_PAGE_SIZE;
     public static final int DEFAULT_KEY_SIZE;
     public static final int DEFAULT_BIN_SIZE;
-    public static final int MAXIMUM_CAPACITY = 16384;
-    /**
-     * The load factor used when none specified in constructor.
-     **/
-    static final float DEFAULT_LOAD_FACTOR;
+    public static final int MAXIMUM_CAPACITY;
+    public static final int DEFAULT_LOAD_FACTOR;
     private static final String NAME_PREFIX = "hash-index-";
     private static final Log LOG = LogFactory.getLog(HashIndex.class);
     private final String name;
@@ -73,7 +70,7 @@
     private int activeBins;
     private int threshold;
     private int maximumCapacity=MAXIMUM_CAPACITY;
-    private float loadFactor=0.75f;
+    private int loadFactor=DEFAULT_LOAD_FACTOR;
     
     
     /**
@@ -203,14 +200,14 @@
     /**
      * @return the loadFactor
      */
-    public float getLoadFactor() {
+    public int getLoadFactor() {
         return loadFactor;
     }
 
     /**
      * @param loadFactor the loadFactor to set
      */
-    public void setLoadFactor(float loadFactor) {
+    public void setLoadFactor(int loadFactor) {
         this.loadFactor = loadFactor;
     }
     
@@ -565,7 +562,7 @@
     }
     
     private int calculateThreashold() {
-        return (int)(bins.length * 100 * loadFactor);
+        return (int)(bins.length * loadFactor);
     }
     
     
@@ -592,6 +589,7 @@
         DEFAULT_PAGE_SIZE = Integer.parseInt(System.getProperty("defaultPageSize", "16384"));
         DEFAULT_KEY_SIZE = Integer.parseInt(System.getProperty("defaultKeySize", "96"));
         DEFAULT_BIN_SIZE= Integer.parseInt(System.getProperty("defaultBinSize", "1024"));
-        DEFAULT_LOAD_FACTOR=Float.parseFloat(System.getProperty("defaultLoadFactor","1.5f"));
+        MAXIMUM_CAPACITY = Integer.parseInt(System.getProperty("defaultPageSize", "16384"));
+        DEFAULT_LOAD_FACTOR=Integer.parseInt(System.getProperty("defaultLoadFactor","50"));
     }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java?rev=656574&r1=656573&r2=656574&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
Thu May 15 02:42:35 2008
@@ -118,7 +118,8 @@
     private int indexBinSize = HashIndex.DEFAULT_BIN_SIZE;
     private int indexKeySize = HashIndex.DEFAULT_KEY_SIZE;
     private int indexPageSize = HashIndex.DEFAULT_PAGE_SIZE;
-    private int maxBinSize = HashIndex.MAXIMUM_CAPACITY;
+    private int indexMaxBinSize = HashIndex.MAXIMUM_CAPACITY;
+    private int indexLoadFactor = HashIndex.DEFAULT_LOAD_FACTOR;
     private int maxReferenceFileLength=AsyncDataManager.DEFAULT_MAX_FILE_LENGTH;
     private Map<AMQMessageStore,Set<Integer>> dataFilesInProgress = new ConcurrentHashMap<AMQMessageStore,Set<Integer>>
();
     private String directoryPath = "";
@@ -686,7 +687,8 @@
         adaptor.setIndexBinSize(getIndexBinSize());
         adaptor.setIndexKeySize(getIndexKeySize());
         adaptor.setIndexPageSize(getIndexPageSize());
-        adaptor.setMaxBinSize(getMaxBinSize());
+        adaptor.setIndexMaxBinSize(getIndexMaxBinSize());
+        adaptor.setIndexLoadFactor(getIndexLoadFactor());
         return adaptor;
     }
 
@@ -836,12 +838,12 @@
         return indexPageSize;
     }
     
-    public int getMaxBinSize() {
-        return maxBinSize;
+    public int getIndexMaxBinSize() {
+        return indexMaxBinSize;
     }
 
-    public void setMaxBinSize(int maxBinSize) {
-        this.maxBinSize = maxBinSize;
+    public void setIndexMaxBinSize(int maxBinSize) {
+        this.indexMaxBinSize = maxBinSize;
     }
 
     /**
@@ -854,6 +856,14 @@
         this.indexPageSize = indexPageSize;
     }
     
+    public void setIndexLoadFactor(int factor){
+    	this.indexLoadFactor=factor;    
+    }
+    
+    public int getIndexLoadFactor(){
+    	return this.indexLoadFactor;
+    }
+    
     public int getMaxReferenceFileLength() {
         return maxReferenceFileLength;
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java?rev=656574&r1=656573&r2=656574&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java
Thu May 15 02:42:35 2008
@@ -72,7 +72,8 @@
     private int indexBinSize = HashIndex.DEFAULT_BIN_SIZE;
     private int indexKeySize = HashIndex.DEFAULT_KEY_SIZE;
     private int indexPageSize = HashIndex.DEFAULT_PAGE_SIZE;
-    private int maxBinSize = HashIndex.MAXIMUM_CAPACITY;
+    private int indexMaxBinSize = HashIndex.MAXIMUM_CAPACITY;
+    private int indexLoadFactor = HashIndex.DEFAULT_LOAD_FACTOR;
    
 
     public KahaReferenceStoreAdapter(AtomicLong size){
@@ -204,7 +205,8 @@
         container.setIndexBinSize(getIndexBinSize());
         container.setIndexKeySize(getIndexKeySize());
         container.setIndexPageSize(getIndexPageSize());
-        container.setMaxBinSize(getIndexBinSize());
+        container.setIndexMaxBinSize(getIndexMaxBinSize());
+        container.setIndexLoadFactor(getIndexLoadFactor());
         container.setKeyMarshaller(new MessageIdMarshaller());
         container.setValueMarshaller(new ReferenceRecordMarshaller());
         container.load();
@@ -364,11 +366,25 @@
         this.indexPageSize = indexPageSize;
     }
     
-    public int getMaxBinSize() {
-        return maxBinSize;
+    public int getIndexMaxBinSize() {
+        return indexMaxBinSize;
     }
 
-    public void setMaxBinSize(int maxBinSize) {
-        this.maxBinSize = maxBinSize;
+    public void setIndexMaxBinSize(int maxBinSize) {
+        this.indexMaxBinSize = maxBinSize;
+    }
+    
+    /**
+     * @return the loadFactor
+     */
+    public int getIndexLoadFactor() {
+        return indexLoadFactor;
+    }
+
+    /**
+     * @param loadFactor the loadFactor to set
+     */
+    public void setIndexLoadFactor(int loadFactor) {
+        this.indexLoadFactor = loadFactor;
     }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java?rev=656574&r1=656573&r2=656574&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
Thu May 15 02:42:35 2008
@@ -48,7 +48,7 @@
     public PerfConsumer(ConnectionFactory fac, Destination dest, String consumerName) throws
JMSException {
         connection = fac.createConnection();
         connection.setClientID(consumerName);
-        Session s = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+        Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         if (dest instanceof Topic && consumerName != null && consumerName.length()
> 0) {
             consumer = s.createDurableSubscriber((Topic)dest, consumerName);
         } else {



Mime
View raw message