@Test public void testInitialiseFailures() { try { Cache cache = new Cache("testInitialiseFailures2", 1, false, false, 5, 1); cache.initialise(); cache.initialise(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalStateException e) { } }
public void initialise() { synchronized (this) { if (!status.equals(Status.STATUS_UNINITIALISED)) { throw new IllegalStateException("Cannot initialise the " + configuration.getName() + " cache because its status is not STATUS_UNINITIALISED"); } if (configuration.getMaxElementsInMemory() == 0) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " has a maxElementsInMemory of 0. It is strongly recommended to " + "have a maximumSize of at least 1. Performance is halved by not using a MemoryStore."); } } this.diskStore = createDiskStore(); if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) { memoryStore = new LruMemoryStore(this, diskStore); } else { memoryStore = MemoryStore.create(this, diskStore); } changeStatus(Status.STATUS_ALIVE); initialiseRegisteredCacheExtensions(); initialiseRegisteredCacheLoaders(); } if (LOG.isDebugEnabled()) { LOG.debug("Initialised cache: " + configuration.getName()); } if (disabled) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " is disabled because the " + NET_SF_EHCACHE_DISABLED + " property was set to true. No elements will be added to the cache."); } } }
Cache implements Ehcache { public void initialise() { synchronized (this) { if (!status.equals(Status.STATUS_UNINITIALISED)) { throw new IllegalStateException("Cannot initialise the " + configuration.getName() + " cache because its status is not STATUS_UNINITIALISED"); } if (configuration.getMaxElementsInMemory() == 0) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " has a maxElementsInMemory of 0. It is strongly recommended to " + "have a maximumSize of at least 1. Performance is halved by not using a MemoryStore."); } } this.diskStore = createDiskStore(); if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) { memoryStore = new LruMemoryStore(this, diskStore); } else { memoryStore = MemoryStore.create(this, diskStore); } changeStatus(Status.STATUS_ALIVE); initialiseRegisteredCacheExtensions(); initialiseRegisteredCacheLoaders(); } if (LOG.isDebugEnabled()) { LOG.debug("Initialised cache: " + configuration.getName()); } if (disabled) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " is disabled because the " + NET_SF_EHCACHE_DISABLED + " property was set to true. No elements will be added to the cache."); } } } }
Cache implements Ehcache { public void initialise() { synchronized (this) { if (!status.equals(Status.STATUS_UNINITIALISED)) { throw new IllegalStateException("Cannot initialise the " + configuration.getName() + " cache because its status is not STATUS_UNINITIALISED"); } if (configuration.getMaxElementsInMemory() == 0) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " has a maxElementsInMemory of 0. It is strongly recommended to " + "have a maximumSize of at least 1. Performance is halved by not using a MemoryStore."); } } this.diskStore = createDiskStore(); if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) { memoryStore = new LruMemoryStore(this, diskStore); } else { memoryStore = MemoryStore.create(this, diskStore); } changeStatus(Status.STATUS_ALIVE); initialiseRegisteredCacheExtensions(); initialiseRegisteredCacheLoaders(); } if (LOG.isDebugEnabled()) { LOG.debug("Initialised cache: " + configuration.getName()); } if (disabled) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " is disabled because the " + NET_SF_EHCACHE_DISABLED + " property was set to true. No elements will be added to the cache."); } } } Cache(String name, int maxElementsInMemory, boolean overflowToDisk,
                 boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds);  Cache(String name,
                 int maxElementsInMemory,
                 boolean overflowToDisk,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk,
                 int diskSpoolBufferSizeMB);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk,
                 int diskSpoolBufferSizeMB,
                 boolean clearOnFlush); }
Cache implements Ehcache { public void initialise() { synchronized (this) { if (!status.equals(Status.STATUS_UNINITIALISED)) { throw new IllegalStateException("Cannot initialise the " + configuration.getName() + " cache because its status is not STATUS_UNINITIALISED"); } if (configuration.getMaxElementsInMemory() == 0) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " has a maxElementsInMemory of 0. It is strongly recommended to " + "have a maximumSize of at least 1. Performance is halved by not using a MemoryStore."); } } this.diskStore = createDiskStore(); if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) { memoryStore = new LruMemoryStore(this, diskStore); } else { memoryStore = MemoryStore.create(this, diskStore); } changeStatus(Status.STATUS_ALIVE); initialiseRegisteredCacheExtensions(); initialiseRegisteredCacheLoaders(); } if (LOG.isDebugEnabled()) { LOG.debug("Initialised cache: " + configuration.getName()); } if (disabled) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " is disabled because the " + NET_SF_EHCACHE_DISABLED + " property was set to true. No elements will be added to the cache."); } } } Cache(String name, int maxElementsInMemory, boolean overflowToDisk,
                 boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds);  Cache(String name,
                 int maxElementsInMemory,
                 boolean overflowToDisk,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk,
                 int diskSpoolBufferSizeMB);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk,
                 int diskSpoolBufferSizeMB,
                 boolean clearOnFlush); void initialise(); void bootstrap(); final void put(Element element); final void put(Element element, boolean doNotNotifyCacheReplicators); final void putQuiet(Element element); final Element get(Serializable key); final Element get(Object key); Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument); void load(final Object key); Map getAllWithLoader(Collection keys, Object loaderArgument); void loadAll(final Collection keys, final Object argument); final Element getQuiet(Serializable key); final Element getQuiet(Object key); final List getKeys(); final List getKeysWithExpiryCheck(); final List getKeysNoDuplicateCheck(); final boolean remove(Serializable key); final boolean remove(Object key); final boolean remove(Serializable key, boolean doNotNotifyCacheReplicators); final boolean remove(Object key, boolean doNotNotifyCacheReplicators); final boolean removeQuiet(Serializable key); final boolean removeQuiet(Object key); void removeAll(); void removeAll(boolean doNotNotifyCacheReplicators); synchronized void dispose(); CacheConfiguration getCacheConfiguration(); final synchronized void flush(); final int getSize(); final long calculateInMemorySize(); final long getMemoryStoreSize(); final int getDiskStoreSize(); final Status getStatus(); final String getName(); final void setName(String name); final String toString(); final boolean isExpired(Element element); final Object clone(); final RegisteredEventListeners getCacheEventNotificationService(); final boolean isElementInMemory(Serializable key); final boolean isElementInMemory(Object key); final boolean isElementOnDisk(Serializable key); final boolean isElementOnDisk(Object key); final String getGuid(); final CacheManager getCacheManager(); void clearStatistics(); int getStatisticsAccuracy(); void setStatisticsAccuracy(int statisticsAccuracy); void evictExpiredElements(); boolean isKeyInCache(Object key); boolean isValueInCache(Object value); Statistics getStatistics(); void setCacheManager(CacheManager cacheManager); BootstrapCacheLoader getBootstrapCacheLoader(); void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader); void setDiskStorePath(String diskStorePath); boolean equals(Object object); int hashCode(); void registerCacheExtension(CacheExtension cacheExtension); List<CacheExtension> getRegisteredCacheExtensions(); void unregisterCacheExtension(CacheExtension cacheExtension); float getAverageGetTime(); void setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler); CacheExceptionHandler getCacheExceptionHandler(); void registerCacheLoader(CacheLoader cacheLoader); void unregisterCacheLoader(CacheLoader cacheLoader); List<CacheLoader> getRegisteredCacheLoaders(); boolean isDisabled(); void setDisabled(boolean disabled); Policy getMemoryStoreEvictionPolicy(); void setMemoryStoreEvictionPolicy(Policy policy); }
Cache implements Ehcache { public void initialise() { synchronized (this) { if (!status.equals(Status.STATUS_UNINITIALISED)) { throw new IllegalStateException("Cannot initialise the " + configuration.getName() + " cache because its status is not STATUS_UNINITIALISED"); } if (configuration.getMaxElementsInMemory() == 0) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " has a maxElementsInMemory of 0. It is strongly recommended to " + "have a maximumSize of at least 1. Performance is halved by not using a MemoryStore."); } } this.diskStore = createDiskStore(); if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) { memoryStore = new LruMemoryStore(this, diskStore); } else { memoryStore = MemoryStore.create(this, diskStore); } changeStatus(Status.STATUS_ALIVE); initialiseRegisteredCacheExtensions(); initialiseRegisteredCacheLoaders(); } if (LOG.isDebugEnabled()) { LOG.debug("Initialised cache: " + configuration.getName()); } if (disabled) { if (LOG.isWarnEnabled()) { LOG.warn("Cache: " + configuration.getName() + " is disabled because the " + NET_SF_EHCACHE_DISABLED + " property was set to true. No elements will be added to the cache."); } } } Cache(String name, int maxElementsInMemory, boolean overflowToDisk,
                 boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds);  Cache(String name,
                 int maxElementsInMemory,
                 boolean overflowToDisk,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk,
                 int diskSpoolBufferSizeMB);  Cache(String name,
                 int maxElementsInMemory,
                 MemoryStoreEvictionPolicy memoryStoreEvictionPolicy,
                 boolean overflowToDisk,
                 String diskStorePath,
                 boolean eternal,
                 long timeToLiveSeconds,
                 long timeToIdleSeconds,
                 boolean diskPersistent,
                 long diskExpiryThreadIntervalSeconds,
                 RegisteredEventListeners registeredEventListeners,
                 BootstrapCacheLoader bootstrapCacheLoader,
                 int maxElementsOnDisk,
                 int diskSpoolBufferSizeMB,
                 boolean clearOnFlush); void initialise(); void bootstrap(); final void put(Element element); final void put(Element element, boolean doNotNotifyCacheReplicators); final void putQuiet(Element element); final Element get(Serializable key); final Element get(Object key); Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument); void load(final Object key); Map getAllWithLoader(Collection keys, Object loaderArgument); void loadAll(final Collection keys, final Object argument); final Element getQuiet(Serializable key); final Element getQuiet(Object key); final List getKeys(); final List getKeysWithExpiryCheck(); final List getKeysNoDuplicateCheck(); final boolean remove(Serializable key); final boolean remove(Object key); final boolean remove(Serializable key, boolean doNotNotifyCacheReplicators); final boolean remove(Object key, boolean doNotNotifyCacheReplicators); final boolean removeQuiet(Serializable key); final boolean removeQuiet(Object key); void removeAll(); void removeAll(boolean doNotNotifyCacheReplicators); synchronized void dispose(); CacheConfiguration getCacheConfiguration(); final synchronized void flush(); final int getSize(); final long calculateInMemorySize(); final long getMemoryStoreSize(); final int getDiskStoreSize(); final Status getStatus(); final String getName(); final void setName(String name); final String toString(); final boolean isExpired(Element element); final Object clone(); final RegisteredEventListeners getCacheEventNotificationService(); final boolean isElementInMemory(Serializable key); final boolean isElementInMemory(Object key); final boolean isElementOnDisk(Serializable key); final boolean isElementOnDisk(Object key); final String getGuid(); final CacheManager getCacheManager(); void clearStatistics(); int getStatisticsAccuracy(); void setStatisticsAccuracy(int statisticsAccuracy); void evictExpiredElements(); boolean isKeyInCache(Object key); boolean isValueInCache(Object value); Statistics getStatistics(); void setCacheManager(CacheManager cacheManager); BootstrapCacheLoader getBootstrapCacheLoader(); void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader); void setDiskStorePath(String diskStorePath); boolean equals(Object object); int hashCode(); void registerCacheExtension(CacheExtension cacheExtension); List<CacheExtension> getRegisteredCacheExtensions(); void unregisterCacheExtension(CacheExtension cacheExtension); float getAverageGetTime(); void setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler); CacheExceptionHandler getCacheExceptionHandler(); void registerCacheLoader(CacheLoader cacheLoader); void unregisterCacheLoader(CacheLoader cacheLoader); List<CacheLoader> getRegisteredCacheLoaders(); boolean isDisabled(); void setDisabled(boolean disabled); Policy getMemoryStoreEvictionPolicy(); void setMemoryStoreEvictionPolicy(Policy policy); static final String DEFAULT_CACHE_NAME; static final String NET_SF_EHCACHE_DISABLED; static final String NET_SF_EHCACHE_USE_CLASSIC_LRU; static final long DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS; }