mirror of https://github.com/apache/activemq.git
Expose load factor for HashIndex in Kaha
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@656574 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f12c100805
commit
15709c5673
|
@ -262,13 +262,22 @@ public interface MapContainer<K, V> extends Map<K, V> {
|
|||
/**
|
||||
* 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
|
||||
|
|
|
@ -58,7 +58,8 @@ public final class MapContainerImpl extends BaseContainerImpl implements MapCont
|
|||
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 @@ public final class MapContainerImpl extends BaseContainerImpl implements MapCont
|
|||
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 final class MapContainerImpl extends BaseContainerImpl implements MapCont
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,11 +42,8 @@ public class HashIndex implements Index, HashIndexMBean {
|
|||
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 @@ public class HashIndex implements Index, HashIndexMBean {
|
|||
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 @@ public class HashIndex implements Index, HashIndexMBean {
|
|||
/**
|
||||
* @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 @@ public class HashIndex implements Index, HashIndexMBean {
|
|||
}
|
||||
|
||||
private int calculateThreashold() {
|
||||
return (int)(bins.length * 100 * loadFactor);
|
||||
return (int)(bins.length * loadFactor);
|
||||
}
|
||||
|
||||
|
||||
|
@ -592,6 +589,7 @@ public class HashIndex implements Index, HashIndexMBean {
|
|||
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"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,8 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
|
|||
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 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
|
|||
adaptor.setIndexBinSize(getIndexBinSize());
|
||||
adaptor.setIndexKeySize(getIndexKeySize());
|
||||
adaptor.setIndexPageSize(getIndexPageSize());
|
||||
adaptor.setMaxBinSize(getMaxBinSize());
|
||||
adaptor.setIndexMaxBinSize(getIndexMaxBinSize());
|
||||
adaptor.setIndexLoadFactor(getIndexLoadFactor());
|
||||
return adaptor;
|
||||
}
|
||||
|
||||
|
@ -836,12 +838,12 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
|
|||
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 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
|
|||
this.indexPageSize = indexPageSize;
|
||||
}
|
||||
|
||||
public void setIndexLoadFactor(int factor){
|
||||
this.indexLoadFactor=factor;
|
||||
}
|
||||
|
||||
public int getIndexLoadFactor(){
|
||||
return this.indexLoadFactor;
|
||||
}
|
||||
|
||||
public int getMaxReferenceFileLength() {
|
||||
return maxReferenceFileLength;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,8 @@ public class KahaReferenceStoreAdapter extends KahaPersistenceAdapter implements
|
|||
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 @@ public class KahaReferenceStoreAdapter extends KahaPersistenceAdapter implements
|
|||
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 @@ public class KahaReferenceStoreAdapter extends KahaPersistenceAdapter implements
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PerfConsumer implements MessageListener {
|
|||
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 {
|
||||
|
|
Loading…
Reference in New Issue