/** * @param maximumNumberOfProducersToTrack the maximumNumberOfProducersToTrack to set */ public void setMaximumNumberOfProducersToTrack(int maximumNumberOfProducersToTrack) { if (maximumNumberOfProducersToTrack < this.maximumNumberOfProducersToTrack){ LRUCache<String, BitArrayBin> newMap = new LRUCache<String, BitArrayBin>(0,maximumNumberOfProducersToTrack,0.75f,true); /** * As putAll will access the entries in the right order, * this shouldn't result in wrong cache entries being removed */ newMap.putAll(this.map); this.map.clear(); this.map.putAll(newMap); } this.map.setMaxCacheSize(maximumNumberOfProducersToTrack); this.maximumNumberOfProducersToTrack = maximumNumberOfProducersToTrack; this.modified = true; }
protected boolean removeEldestEntry(Map.Entry<K,V> eldest) { if( size() > maxCacheSize ) { onCacheEviction(eldest); return true; } return false; }
public long getLastSeqId(ProducerId id) { long result = -1; BitArrayBin bab = map.get(id.toString()); if (bab != null) { result = bab.getLastSetIndex(); } return result; }
/** * Construct a MessageAudit * * @param auditDepth range of ids to track * @param maximumNumberOfProducersToTrack number of producers expected in the system */ public ActiveMQMessageAuditNoSync(int auditDepth, final int maximumNumberOfProducersToTrack) { this.auditDepth = auditDepth; this.maximumNumberOfProducersToTrack=maximumNumberOfProducersToTrack; this.map = new LRUCache<String, BitArrayBin>(0, maximumNumberOfProducersToTrack, 0.75f, true); }
public void clear() { map.clear(); }
this.c = new LRUCache(2); assertEquals(c.get(1), -1); c.set(1, 1); assertEquals(c.get(1), 1); assertEquals(c.get(2), -1); c.set(2, 4); assertEquals(c.get(1), 1); assertEquals(c.get(2), 4); c.set(1, 1); c.set(2, 4); c.set(3, 9); assertEquals(c.get(1), -1); assertEquals(c.get(2), 4); assertEquals(c.get(3), 9); c.set(1, 1); c.set(2, 4); assertEquals(c.get(1), 1); c.set(3, 9); assertEquals(c.get(1), 1); assertEquals(c.get(2), -1); assertEquals(c.get(3), 9);
public boolean init() { boolean result = initialized.compareAndSet(false, true); if (result) { if (jndiLocalTemplate == null) { jndiLocalTemplate = new JndiLookupFactory(); } if (jndiOutboundTemplate == null) { jndiOutboundTemplate = new JndiLookupFactory(); } if (inboundMessageConvertor == null) { inboundMessageConvertor = new SimpleJmsMessageConvertor(); } if (outboundMessageConvertor == null) { outboundMessageConvertor = new SimpleJmsMessageConvertor(); } replyToBridges.setMaxCacheSize(getReplyToDestinationCacheSize()); connectionService = createExecutor(); // Subclasses can override this to customize their own it. result = doConnectorInit(); } return result; }
public boolean add(E o) { return cache.put(o, IGNORE)==null; }
protected boolean removeEldestEntry(Map.Entry<K,V> eldest) { return size() > maxCacheSize; } }
public void rollback(final String id) { String seed = IdGenerator.getSeedFromId(id); if (seed != null) { BitArrayBin bab = map.get(seed); if (bab != null) { long index = IdGenerator.getSequenceFromId(id); bab.setBit(index, false); modified = true; } } }
pageCache = Collections.synchronizedMap(new LFUCache<Long, Page>(pageCacheSize, getLFUEvictionFactor())); } else { pageCache = Collections.synchronizedMap(new LRUCache<Long, Page>(pageCacheSize, pageCacheSize, 0.75f, true));
public void clearBridges() { inboundBridges.clear(); outboundBridges.clear(); replyToBridges.clear(); }
/** * @param pageCacheSize the pageCacheSize to set */ public void setPageCacheSize(int pageCacheSize) { this.pageCacheSize = pageCacheSize; pageCache.setMaxCacheSize(pageCacheSize); }
private void addToCache(TreePage page) { if (enablePageCaching) { pageCache.put(page.getId(), page); } }
public int size() { return cache.size(); }
/** * @param maximumNumberOfProducersToTrack the maximumNumberOfProducersToTrack to set */ public void setMaximumNumberOfProducersToTrack(int maximumNumberOfProducersToTrack) { if (maximumNumberOfProducersToTrack < this.maximumNumberOfProducersToTrack){ LRUCache<String, BitArrayBin> newMap = new LRUCache<String, BitArrayBin>(0,maximumNumberOfProducersToTrack,0.75f,true); /** * As putAll will access the entries in the right order, * this shouldn't result in wrong cache entries being removed */ newMap.putAll(this.map); this.map.clear(); this.map.putAll(newMap); } this.map.setMaxCacheSize(maximumNumberOfProducersToTrack); this.maximumNumberOfProducersToTrack = maximumNumberOfProducersToTrack; this.modified = true; }
/** * Check the message id is in order * * @param id * * @return true if the id is in order */ public boolean isInOrder(final String id) { boolean answer = true; if (id != null) { String seed = IdGenerator.getSeedFromId(id); if (seed != null) { BitArrayBin bab = map.get(seed); if (bab != null) { long index = IdGenerator.getSequenceFromId(id); answer = bab.isInOrder(index); modified = true; } } } return answer; }