method2testcases
stringlengths
118
6.63k
### Question: SelfPopulatingCache extends BlockingCache { protected void refreshElement(final Element element, Ehcache backingCache) throws Exception { refreshElement(element, backingCache, true); } SelfPopulatingCache(final Ehcache cache, final CacheEntryFactory factory); Element get(final Object key); void refresh();...
### Question: BlockingCache implements Ehcache { protected Ehcache getCache() { return cache; } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); @Override Object clone(); RegisteredEventListener...
### Question: BlockingCache implements Ehcache { public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { throw new CacheException("This method is not appropriate for a Blocking Cache"); } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Eh...
### Question: CacheWriterConfiguration implements Cloneable { public CacheWriterConfiguration writeMode(String writeMode) { setWriteMode(writeMode); return this; } @Override CacheWriterConfiguration clone(); void setWriteMode(String writeMode); CacheWriterConfiguration writeMode(String writeMode); CacheWriterConfigura...
### Question: UpdateChecker extends TimerTask { public void checkForUpdate() { try { if (!Boolean.getBoolean("net.sf.ehcache.skipUpdateCheck")) { doCheck(); } } catch (Throwable t) { LOG.debug("Update check failed: " + t.toString()); } } @Override void run(); void checkForUpdate(); }### Answer: @Test public void test...
### Question: SlewClock { static long timeMillis() { boolean interrupted = false; try { while (true) { long mono = CURRENT.get(); long wall = getCurrentTime(); if (wall == mono) { OFFSET.remove(); return wall; } else if (wall >= mono) { if (CURRENT.compareAndSet(mono, wall)) { OFFSET.remove(); return wall; } } else { l...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { LOG.debug("Creating new CacheManager with default config"); singleton = new CacheManager(); } else { LOG.debug("Attempting to...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return (Cache) caches.get(name); } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL configurationURL); CacheManager(InputStream conf...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = (Ehcache) ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); ...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: Statistics implements Serializable { public void clearStatistics() { if (cache == null) { throw new IllegalStateException("This statistics object no longer references a Cache."); } cache.clearStatistics(); } Statistics(Ehcache cache, int statisticsAccuracy, long cacheHits, long onDiskHits, long inMemoryHi...
### Question: BlockingCache implements Ehcache { protected Ehcache getCache() { return cache; } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); @Override Object clone(); RegisteredEventListener...
### Question: BlockingCache implements Ehcache { public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { throw new CacheException("This method is not appropriate for a Blocking Cache"); } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Eh...
### Question: XATransactionalStore extends AbstractStore { public Element removeElement(Element element) throws NullPointerException { TransactionContext context = getOrCreateTransactionContext(); Element previous = getCurrentElement(element.getKey(), context); if (previous != null && previous.getValue().equals(element...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { LOG.debug("Creating new CacheManager with default config"); singleton = new CacheManager(); } else { LOG.debug("Attempting to...
### Question: UpdatingSelfPopulatingCache extends SelfPopulatingCache { public void refresh() throws CacheException { throw new CacheException("UpdatingSelfPopulatingCache objects should not be refreshed."); } UpdatingSelfPopulatingCache(Ehcache cache, final UpdatingCacheEntryFactory factory); Element get(final Object ...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return ehcaches.get(name) instanceof Cache ? (Cache) ehcaches.get(name) : null; } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL co...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); cacheManag...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: CacheManager { public Ehcache addCacheIfAbsent(final Ehcache cache) { checkStatus(); return cache == null ? null : addCacheNoCheck(cache, false); } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL configurationURL); CacheManager(InputStream configu...
### Question: EhcacheStatsImpl extends BaseEmitterBean implements EhcacheStats { public boolean isRegionCacheOrphanEvictionEnabled(String region) { Cache cache = this.cacheManager.getCache(region); if (cache != null && cache.isTerracottaClustered()) { return cache.getCacheConfiguration().getTerracottaConfiguration().ge...
### Question: EhcacheStatsImpl extends BaseEmitterBean implements EhcacheStats { public int getRegionCacheOrphanEvictionPeriod(String region) { Cache cache = this.cacheManager.getCache(region); if (cache != null && cache.isTerracottaClustered()) { return cache.getCacheConfiguration().getTerracottaConfiguration().getOrp...
### Question: Statistics implements Serializable { public void clearStatistics() { if (cache == null) { throw new IllegalStateException("This statistics object no longer references a Cache."); } cache.clearStatistics(); } Statistics(Ehcache cache, int statisticsAccuracy, long cacheHits, long onDiskHits, long inMemoryHi...
### Question: BlockingCache extends EhcacheDecoratorAdapter { @Override public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { throw new CacheException("This method is not appropriate for a Blocking Cache"); } BlockingCache(final Ehcache cache, int numberOfStripes); ...
### Question: DeleteOperation implements SingleOperation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final DeleteOperation that = (DeleteOperation) o; return entry.getKey().equals(that.getKey()); } DeleteOperation(CacheEntry ...
### Question: DeleteOperation implements SingleOperation { @Override public int hashCode() { return entry.getKey().hashCode(); } DeleteOperation(CacheEntry entry); DeleteOperation(CacheEntry entry, long creationTime); void performSingleOperation(CacheWriter cacheWriter); BatchOperation createBatchOperation(List<Single...
### Question: WriteOperation implements SingleOperation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final WriteOperation that = (WriteOperation) o; return element.getKey().equals(that.element.getKey()) && element.getValue().e...
### Question: WriteOperation implements SingleOperation { @Override public int hashCode() { return element.hashCode(); } WriteOperation(Element element); WriteOperation(Element element, long creationTime); void performSingleOperation(CacheWriter cacheWriter); BatchOperation createBatchOperation(List<SingleOperation> o...
### Question: CacheWriterConfiguration implements Cloneable { public CacheWriterConfiguration writeMode(String writeMode) { setWriteMode(writeMode); return this; } @Override CacheWriterConfiguration clone(); void setWriteMode(String writeMode); CacheWriterConfiguration writeMode(String writeMode); CacheWriterConfigura...
### Question: CachingFilter extends Filter { Integer parseBlockingCacheTimeoutMillis(FilterConfig filterConfig) { String timeout = filterConfig.getInitParameter(BLOCKING_TIMEOUT_MILLIS); try { return Integer.parseInt(timeout); } catch (NumberFormatException e) { return null; } } void doInit(FilterConfig filterConfig);...
### Question: HttpDateFormatter { public synchronized Date parseDateFromHttpDate(String date) { try { return httpDateFormat.parse(date); } catch (ParseException e) { LOG.debug("ParseException on date {}. 1/1/1970 will be returned", date); return new Date(0); } } HttpDateFormatter(); synchronized String formatHttpDate(D...
### Question: PageInfo implements Serializable { public byte[] getUngzippedBody() throws IOException { if (storeGzipped) { return ungzip(gzippedBody); } else { return ungzippedBody; } } PageInfo(final int statusCode, final String contentType, final Collection headers, final Collection cookies, final...
### Question: PageInfo implements Serializable { private byte[] gzip(byte[] ungzipped) throws IOException, AlreadyGzippedException { if (isGzipped(ungzipped)) { throw new AlreadyGzippedException("The byte[] is already gzipped. It should not be gzipped again."); } final ByteArrayOutputStream bytes = new ByteArrayOutputS...
### Question: EhcacheObjectMapperProvider implements ContextResolver<ObjectMapper> { public ObjectMapper getContext(Class<?> arg0) { return om; } EhcacheObjectMapperProvider(); ObjectMapper getContext(Class<?> arg0); }### Answer: @Test public void testObjectMapping() throws IOException { EhcacheObjectMapperProvider pr...
### Question: ResourceClassLoader extends ClassLoader { @Override public synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Class c = findLoadedClass(name); if (c == null) { try { c = findClass(name); } catch (ClassNotFoundException e) { c = super.loadClass(name, resolve); } }...
### Question: SelectableConcurrentHashMap { public Element get(Object key) { int hash = hash(key.hashCode()); return segmentFor(hash).get(key, hash); } SelectableConcurrentHashMap(PoolAccessor poolAccessor, boolean elementPinningEnabled, int initialCapacity, float loadFactor, int concurrency, final long maximumSize, fi...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return ehcaches.get(name) instanceof Cache ? (Cache) ehcaches.get(name) : null; } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL co...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); runtimeCfg...
### Question: ManagementService implements CacheManagerEventListener { public void notifyCacheRemoved(String cacheName) { if (registerCaches) { unregisterMBean(Cache.createObjectName(backingCacheManager.toString(), cacheName)); } if (registerCacheConfigurations) { unregisterMBean(CacheConfiguration.createObjectName(bac...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return ehcaches.get(name) instanceof Cache ? (Cache) ehcaches.get(name) : null; } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL co...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); configurat...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { LOG.debug("Creating new CacheManager with default config"); singleton = new CacheManager(); } else { LOG.debug("Attempting to...
### Question: DelegatingManagementEventSink implements ManagementEventSink { @Override public void sendManagementEvent(Serializable event, String type) { ManagementEventSink sink = get(); if (sink != null) { sink.sendManagementEvent(event, type); } } DelegatingManagementEventSink(TerracottaClient terracottaClient); @Ov...
### Question: EhcacheStatsImpl extends BaseEmitterBean implements EhcacheStats { public boolean isRegionCacheOrphanEvictionEnabled(String region) { Cache cache = this.cacheManager.getCache(region); if (cache != null && cache.isTerracottaClustered()) { return cache.getCacheConfiguration().getTerracottaConfiguration().ge...
### Question: EhcacheStatsImpl extends BaseEmitterBean implements EhcacheStats { public int getRegionCacheOrphanEvictionPeriod(String region) { Cache cache = this.cacheManager.getCache(region); if (cache != null && cache.isTerracottaClustered()) { return cache.getCacheConfiguration().getTerracottaConfiguration().getOrp...
### Question: Element implements Serializable, Cloneable { public final boolean isSerializable() { return isKeySerializable() && (value instanceof Serializable || value == null) && elementEvictionData.canParticipateInSerialization(); } Element(final Serializable key, final Serializable value, final long version); Elem...
### Question: Element implements Serializable, Cloneable { @Override public final boolean equals(final Object object) { if (object == null || !(object instanceof Element)) { return false; } Element element = (Element) object; if (key == null || element.getObjectKey() == null) { return false; } return key.equals(element...
### Question: ApplicationEhCache extends javax.ws.rs.core.Application { public Set<Class<?>> getClasses() { Set<Class<?>> s = new HashSet<Class<?>>(); s.add(net.sf.ehcache.management.resource.services.ElementsResourceServiceImpl.class); s.add(net.sf.ehcache.management.resource.services.CacheStatisticSamplesResourceServ...
### Question: MemorySizeParser { public static long parse(String configuredMemorySize) throws IllegalArgumentException { MemorySize size = parseIncludingUnit(configuredMemorySize); return size.calculateMemorySizeInBytes(); } static long parse(String configuredMemorySize); }### Answer: @Test public void testParse() { ...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public Element putIfAbsent(Element element) throws NullPointerException { if (isEventual) { throw new UnsupportedOperationException( "CAS operations are not supported in eventual consistency mode, consider using a StronglyConsistentCache...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException { if (isEventual) { throw new UnsupportedOperationException( "CAS operations are not supported ...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException { if (isEventual) { throw new UnsupportedOperationException( "CAS operations are not supported in eventual consistency mode, con...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public void dispose() { dropLeaderStatus(); topology.removeTopologyListener(eventListenersRefresher); backend.removeListener(evictionListener); backend.disposeLocally(); cacheConfigChangeBridge.disconnectConfigs(); toolkitInstanceFactory...
### Question: AsyncWriteBehind implements WriteBehind { @Override public void delete(CacheEntry entry) { async.add(new DeleteAsyncOperation(entry.getKey(), entry.getElement())); } AsyncWriteBehind(AsyncCoordinator async, Ehcache cache); @Override void start(CacheWriter writer); @Override void write(Element element); @O...
### Question: AsyncWriteBehind implements WriteBehind { @Override public void write(Element element) { async.add(new WriteAsyncOperation(element)); } AsyncWriteBehind(AsyncCoordinator async, Ehcache cache); @Override void start(CacheWriter writer); @Override void write(Element element); @Override void delete(CacheEntry...
### Question: UpdateChecker extends TimerTask { public void checkForUpdate() { try { if (!Boolean.getBoolean("net.sf.ehcache.skipUpdateCheck")) { doCheck(); } } catch (Throwable t) { LOG.debug("Update check failed: ", t); } } UpdateChecker(); @Override void run(); void checkForUpdate(); }### Answer: @Test public void ...
### Question: TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable { public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootst...
### Question: MemoryEfficientByteArrayOutputStream extends ByteArrayOutputStream { public synchronized byte getBytes()[] { if (buf.length == size()) { return buf; } else { byte[] copy = new byte[size()]; System.arraycopy(buf, 0, copy, 0, size()); return copy; } } MemoryEfficientByteArrayOutputStream(int size); synchron...
### Question: BlockingCache implements Ehcache { public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { throw new CacheException("This method is not appropriate for a Blocking Cache"); } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Eh...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: ConcurrentHashMap implements ConcurrentMap<K, V> { @SuppressWarnings("unchecked") public V put(K key, V value) { if (key == null || value == null) throw new NullPointerException(); return (V)internalPut(key, value); } ConcurrentHashMap(); ConcurrentHashMap(int initialCapacity); ConcurrentHashMap(Map<? e...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { LOG.debug("Creating new CacheManager with default config"); singleton = new CacheManager(); } else { LOG.debug("Attempting to...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return (Cache) caches.get(name); } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL configurationURL); CacheManager(InputStream conf...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = (Ehcache) ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); ...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: Element implements Serializable, Cloneable { public final boolean isSerializable() { return isKeySerializable() && (value instanceof Serializable || value == null) && elementEvictionData.canParticipateInSerialization(); } Element(final Serializable key, final Serializable value, final long version); Elem...
### Question: Element implements Serializable, Cloneable { @Override public final boolean equals(final Object object) { if (object == null || !(object instanceof Element)) { return false; } Element element = (Element) object; if (key == null || element.getObjectKey() == null) { return false; } return key.equals(element...
### Question: UpdatingSelfPopulatingCache extends SelfPopulatingCache { public Element get(final Object key) throws LockTimeoutException { try { Ehcache backingCache = getCache(); Element element = backingCache.get(key); if (element == null) { element = super.get(key); } else { Mutex lock = stripedMutex.getMutexForKey(...
### Question: BlockingCache implements Ehcache { protected Ehcache getCache() { return cache; } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); Object clone(); RegisteredEventListeners getCache...
### Question: BlockingCache implements Ehcache { public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { throw new CacheException("This method is not appropriate for a Blocking Cache"); } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Eh...
### Question: LargeCollection extends AbstractCollection < E > { public final int size() { return Math.max(0, sourceSize() + addSet.size() - removeSet.size()); } LargeCollection(); @Override final boolean add(final E obj); @Override final boolean contains(final Object obj); @Override final boolean remove(final Object o...
### Question: SelfPopulatingCache extends BlockingCache { @Override public Element get(final Object key) throws LockTimeoutException { try { Element element = super.get(key); if (element == null) { Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); put(element); } return element; } catc...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: ReadThroughCache extends EhcacheDecoratorAdapter { @Override public Element get(Object key) throws IllegalStateException, CacheException { if (isModeGet) { return super.getWithLoader(key, null, null); } return super.get(key); } ReadThroughCache(Ehcache underlyingCache, ReadThroughCacheConfiguration config...
### Question: StronglyConsistentCacheAccessor extends EhcacheDecoratorAdapter { @Override public Element putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException { Object objectKey = element.getObjectKey(); if (objectKey == null) { throw new NullPointerException(); } acquireWriteLoc...
### Question: StronglyConsistentCacheAccessor extends EhcacheDecoratorAdapter { @Override public boolean removeElement(Element element) throws NullPointerException { Object objectKey = element.getObjectKey(); if (objectKey == null) { throw new NullPointerException(); } acquireWriteLockOnKey(objectKey); try { Element cu...
### Question: ApplicationEhCacheV2 extends DefaultApplicationV2 implements ApplicationEhCacheService { @Override public Set<Class<?>> getRestResourceClasses() { Set<Class<?>> s = new HashSet<Class<?>>(super.getClasses()); s.add(net.sf.ehcache.management.resource.services.ElementsResourceServiceImplV2.class); s.add(net....
### Question: SelfPopulatingCache extends BlockingCache { @Override public Element get(final Object key) throws LockTimeoutException { Element element = super.get(key); if (element == null) { try { Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); } catch (final Throwable throwable) { ...
### Question: SelfPopulatingCache extends BlockingCache { public void refresh() throws CacheException { Exception exception = null; Object keyWithException = null; final Collection keys = getKeys(); if (LOG.isTraceEnabled()) { LOG.trace(getName() + ": found " + keys.size() + " keys to refresh"); } for (Iterator iterato...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { if (LOG.isDebugEnabled()) { LOG.debug("CacheManager already shutdown"); } return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (ca...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isDebugEnabled()) { LOG.debug("Creating new CacheManager with default config"); } singleton = new CacheManager(); } e...
### Question: Element implements Serializable, Cloneable { public final long getSerializedSize() { if (!isSerializable()) { return 0; } long size = 0; ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(bout); oos.writeObject(this); size = bout.siz...
### Question: PayloadUtil { public static byte[] gzip(byte[] ungzipped) { final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); try { final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bytes); gzipOutputStream.write(ungzipped); gzipOutputStream.close(); } catch (IOException e) { LOG.error("Could ...
### Question: SelfPopulatingCache extends BlockingCache { public void refresh() throws CacheException { refresh(true); } SelfPopulatingCache(final Ehcache cache, final CacheEntryFactory factory); SelfPopulatingCache(Ehcache cache, int numberOfStripes, CacheEntryFactory factory); @Override Element get(final Object key)...
### Question: SelfPopulatingCache extends BlockingCache { protected void refreshElement(final Element element, Ehcache backingCache) throws Exception { refreshElement(element, backingCache, true); } SelfPopulatingCache(final Ehcache cache, final CacheEntryFactory factory); SelfPopulatingCache(Ehcache cache, int number...
### Question: EhcacheWebServiceEndpoint { @WebMethod public String ping() { return "pong"; } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(String cacheName); @WebMethod void removeCache(String cacheName); @WebMethod String[] cacheNames(); @WebMethod Status getStatus(St...
### Question: EhcacheWebServiceEndpoint { @WebMethod public Cache getCache(String cacheName) throws CacheException { Ehcache ehcache = manager.getCache(cacheName); if (ehcache != null) { return new Cache(ehcache); } else { return null; } } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMeth...
### Question: EhcacheWebServiceEndpoint { @WebMethod public String[] cacheNames() throws IllegalStateException { return manager.getCacheNames(); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(String cacheName); @WebMethod void removeCache(String cacheName); @WebMethod...
### Question: EhcacheWebServiceEndpoint { @WebMethod public Status getStatus(String cacheName) { net.sf.ehcache.Cache cache = lookupCache(cacheName); return Status.fromCode(cache.getStatus().intValue()); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(String cacheName)...
### Question: EhcacheWebServiceEndpoint { @WebMethod public List getKeys(String cacheName) throws IllegalStateException, CacheException { net.sf.ehcache.Cache cache = lookupCache(cacheName); return cache.getKeys(); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(String...
### Question: EhcacheWebServiceEndpoint { @WebMethod public boolean remove(String cacheName, String key) throws CacheException { net.sf.ehcache.Cache cache = lookupCache(cacheName); return cache.remove(key); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(String cacheN...
### Question: EhcacheWebServiceEndpoint { @WebMethod public StatisticsAccuracy getStatisticsAccuracy(String cacheName) { net.sf.ehcache.Cache cache = lookupCache(cacheName); return StatisticsAccuracy.fromCode(cache.getStatisticsAccuracy()); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebM...
### Question: EhcacheWebServiceEndpoint { @WebMethod public void load(String cacheName, String key) throws CacheException { net.sf.ehcache.Cache cache = lookupCache(cacheName); cache.load(key); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(String cacheName); @WebMeth...
### Question: EhcacheWebServiceEndpoint { @WebMethod public void loadAll(String cacheName, Collection<String> keys) throws CacheException { net.sf.ehcache.Cache cache = lookupCache(cacheName); cache.loadAll(keys, null); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheName); @WebMethod void addCache(S...
### Question: EhcacheWebServiceEndpoint { @WebMethod public Element getWithLoader(String cacheName, String key) { net.sf.ehcache.Cache cache = lookupCache(cacheName); net.sf.ehcache.Element element = cache.getWithLoader(key, null, null); if (element != null) { return new Element(element); } else { return null; } } @We...
### Question: EhcacheWebServiceEndpoint { @WebMethod public HashMap getAllWithLoader(String cacheName, Collection keys) throws CacheException { net.sf.ehcache.Cache cache = lookupCache(cacheName); return (HashMap) cache.getAllWithLoader(keys, null); } @WebMethod String ping(); @WebMethod Cache getCache(String cacheNam...
### Question: ExplicitLockingCache implements Ehcache { public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } } ExplicitLockingCache(Ehcach...