You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ol...@apache.org on 2014/04/28 01:47:40 UTC
svn commit: r1590527 [2/2] - in /commons/proper/jcs/trunk: ./ src/conf/
src/java/org/apache/commons/jcs/ src/java/org/apache/commons/jcs/jcache/
src/java/org/apache/commons/jcs/jcache/jmx/ src/resources/
src/resources/META-INF/ src/resources/META-INF/s...
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/TempStateCacheView.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/TempStateCacheView.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/TempStateCacheView.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/TempStateCacheView.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,240 @@
+package org.apache.commons.jcs.jcache;
+
+import javax.cache.Cache;
+import javax.cache.CacheManager;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
+import javax.cache.configuration.Configuration;
+import javax.cache.integration.CompletionListener;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.EntryProcessorResult;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.commons.jcs.jcache.Asserts.assertNotNull;
+
+public class TempStateCacheView<K, V> implements Cache<K, V> {
+ private final Cache<K, V> cache;
+ private final Map<K, V> put = new HashMap<K, V>();
+ private final Collection<K> remove = new LinkedList<K>();
+ private boolean removeAll = false;
+ private boolean clear = false;
+
+ public TempStateCacheView(final Cache<K, V> entries) {
+ this.cache = entries;
+ }
+
+ public V get(final K key) {
+ if (ignoreKey(key)) {
+ return null;
+ }
+
+ final V v = put.get(key);
+ if (v != null) {
+ return v;
+ }
+ return cache.get(key);
+ }
+
+ private boolean ignoreKey(final K key) {
+ return removeAll || clear || remove.contains(key);
+ }
+
+ public Map<K, V> getAll(final Set<? extends K> keys) {
+ final Map<K, V> v = new HashMap<K, V>(keys.size());
+ final Set<K> missing = new HashSet<K>();
+ for (final K k : keys) {
+ final V value = put.get(k);
+ if (value != null) {
+ v.put(k, value);
+ } else if (!ignoreKey(k)) {
+ missing.add(k);
+ }
+ }
+ if (!missing.isEmpty()) {
+ v.putAll(cache.getAll(missing));
+ }
+ return v;
+ }
+
+ public boolean containsKey(final K key) {
+ return !ignoreKey(key) && put.containsKey(key) || cache.containsKey(key);
+ }
+
+ public void loadAll(final Set<? extends K> keys, final boolean replaceExistingValues, final CompletionListener completionListener) {
+ cache.loadAll(keys, replaceExistingValues, completionListener);
+ }
+
+ public void put(final K key, final V value) {
+ assertNotNull(key, "key");
+ assertNotNull(value, "value");
+ put.put(key, value);
+ remove.remove(key);
+ }
+
+ public V getAndPut(final K key, final V value) {
+ final V v = get(key);
+ put(key, value);
+ return v;
+ }
+
+ public void putAll(final Map<? extends K, ? extends V> map) {
+ put.putAll(map);
+ for (final K k : map.keySet()) {
+ remove.remove(k);
+ }
+ }
+
+ public boolean putIfAbsent(final K key, final V value) {
+ if (!put.containsKey(key)) {
+ put.put(key, value);
+ remove.remove(key);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean remove(final K key) {
+ put.remove(key);
+ if (!ignoreKey(key) && cache.containsKey(key)) {
+ remove.add(key);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean remove(final K key, final V oldValue) {
+ put.remove(key);
+ if (!ignoreKey(key) && oldValue.equals(cache.get(key))) {
+ remove.add(key);
+ return true;
+ }
+ return false;
+ }
+
+ public V getAndRemove(final K key) {
+ final V v = get(key);
+ remove.add(key);
+ put.remove(key);
+ return v;
+ }
+
+ public boolean replace(final K key, final V oldValue, final V newValue) {
+ if (oldValue.equals(get(key))) {
+ put(key, newValue);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean replace(final K key, final V value) {
+ if (containsKey(key)) {
+ remove(key);
+ return true;
+ }
+ return false;
+ }
+
+ public V getAndReplace(final K key, final V value) {
+ if (containsKey(key)) {
+ final V oldValue = get(key);
+ put(key, value);
+ return oldValue;
+ }
+ return null;
+ }
+
+ public void removeAll(final Set<? extends K> keys) {
+ remove.addAll(keys);
+ for (final K k : keys) {
+ put.remove(keys);
+ }
+ }
+
+ @Override
+ public void removeAll() {
+ removeAll = true;
+ put.clear();
+ remove.clear();
+ }
+
+ @Override
+ public void clear() {
+ clear = true;
+ put.clear();
+ remove.clear();
+ }
+
+ public <C extends Configuration<K, V>> C getConfiguration(final Class<C> clazz) {
+ return cache.getConfiguration(clazz);
+ }
+
+ public <T> T invoke(final K key, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments) throws EntryProcessorException {
+ return cache.invoke(key, entryProcessor, arguments);
+ }
+
+ public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
+ return cache.invokeAll(keys, entryProcessor, arguments);
+ }
+
+ @Override
+ public String getName() {
+ return cache.getName();
+ }
+
+ @Override
+ public CacheManager getCacheManager() {
+ return cache.getCacheManager();
+ }
+
+ @Override
+ public void close() {
+ cache.close();
+ }
+
+ @Override
+ public boolean isClosed() {
+ return cache.isClosed();
+ }
+
+ @Override
+ public <T> T unwrap(final Class<T> clazz) {
+ return cache.unwrap(clazz);
+ }
+
+ public void registerCacheEntryListener(final CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+ cache.registerCacheEntryListener(cacheEntryListenerConfiguration);
+ }
+
+ public void deregisterCacheEntryListener(final CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+ cache.deregisterCacheEntryListener(cacheEntryListenerConfiguration);
+ }
+
+ @Override
+ public Iterator<Entry<K, V>> iterator() {
+ return cache.iterator();
+ }
+
+ public void merge() {
+ if (removeAll) {
+ cache.removeAll();
+ }
+ if (clear) {
+ cache.clear();
+ }
+
+ for (final Map.Entry<K, V> entry : put.entrySet()) {
+ cache.put(entry.getKey(), entry.getValue());
+ }
+ put.clear();
+ for (final K entry : remove) {
+ cache.remove(entry);
+ }
+ remove.clear();
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/TempStateCacheView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/TempStateCacheView.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/ConfigurableMBeanServerIdBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/ConfigurableMBeanServerIdBuilder.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/ConfigurableMBeanServerIdBuilder.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/ConfigurableMBeanServerIdBuilder.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,127 @@
+package org.apache.commons.jcs.jcache.jmx;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerBuilder;
+import javax.management.MBeanServerDelegate;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public class ConfigurableMBeanServerIdBuilder extends MBeanServerBuilder {
+ private static ConcurrentMap<Key, MBeanServer> JVM_SINGLETONS = new ConcurrentHashMap<Key, MBeanServer>();
+
+ private static class Key {
+ private final String domain;
+ private final MBeanServer outer;
+
+ private Key(final String domain, final MBeanServer outer) {
+ this.domain = domain;
+ this.outer = outer;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final Key key = Key.class.cast(o);
+ return !(domain != null ? !domain.equals(key.domain) : key.domain != null)
+ && !(outer != null ? !outer.equals(key.outer) : key.outer != null);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = domain != null ? domain.hashCode() : 0;
+ result = 31 * result + (outer != null ? outer.hashCode() : 0);
+ return result;
+ }
+ }
+
+ @Override
+ public MBeanServer newMBeanServer(final String defaultDomain, final MBeanServer outer,
+ final MBeanServerDelegate delegate) {
+ final Key key = new Key(defaultDomain, outer);
+ MBeanServer server = JVM_SINGLETONS.get(key);
+ if (server == null) {
+ server = super.newMBeanServer(defaultDomain, outer, new ForceIdMBeanServerDelegate(delegate));
+ final MBeanServer existing = JVM_SINGLETONS.putIfAbsent(key, server);
+ if (existing != null) {
+ server = existing;
+ }
+ }
+ return server;
+ }
+
+ private class ForceIdMBeanServerDelegate extends MBeanServerDelegate {
+ private final MBeanServerDelegate delegate;
+
+ public ForceIdMBeanServerDelegate(final MBeanServerDelegate delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String getMBeanServerId() {
+ return System.getProperty("org.jsr107.tck.management.agentId", delegate.getMBeanServerId());
+ }
+
+ @Override
+ public String getSpecificationName() {
+ return delegate.getSpecificationName();
+ }
+
+ @Override
+ public String getSpecificationVersion() {
+ return delegate.getSpecificationVersion();
+ }
+
+ @Override
+ public String getSpecificationVendor() {
+ return delegate.getSpecificationVendor();
+ }
+
+ @Override
+ public String getImplementationName() {
+ return delegate.getImplementationName();
+ }
+
+ @Override
+ public String getImplementationVersion() {
+ return delegate.getImplementationVersion();
+ }
+
+ @Override
+ public String getImplementationVendor() {
+ return delegate.getImplementationVendor();
+ }
+
+ @Override
+ public MBeanNotificationInfo[] getNotificationInfo() {
+ return delegate.getNotificationInfo();
+ }
+
+ @Override
+ public void addNotificationListener(final NotificationListener listener, final NotificationFilter filter, final Object handback) throws IllegalArgumentException {
+ delegate.addNotificationListener(listener, filter, handback);
+ }
+
+ @Override
+ public void removeNotificationListener(final NotificationListener listener, final NotificationFilter filter, final Object handback) throws ListenerNotFoundException {
+ delegate.removeNotificationListener(listener, filter, handback);
+ }
+
+ @Override
+ public void removeNotificationListener(final NotificationListener listener) throws ListenerNotFoundException {
+ delegate.removeNotificationListener(listener);
+ }
+
+ @Override
+ public void sendNotification(final Notification notification) {
+ delegate.sendNotification(notification);
+ }
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/ConfigurableMBeanServerIdBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/ConfigurableMBeanServerIdBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheMXBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheMXBean.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheMXBean.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheMXBean.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,73 @@
+package org.apache.commons.jcs.jcache.jmx;
+
+import javax.cache.Cache;
+import javax.cache.configuration.CompleteConfiguration;
+import javax.cache.configuration.Configuration;
+import javax.cache.management.CacheMXBean;
+
+public class JCSCacheMXBean<K, V > implements CacheMXBean {
+ private final Cache<K, V> delegate;
+
+ public JCSCacheMXBean(final Cache<K, V> delegate) {
+ this.delegate = delegate;
+ }
+
+ private Configuration config() {
+ return delegate.getConfiguration(Configuration.class);
+ }
+
+ private CompleteConfiguration completeConfig() {
+ return delegate.getConfiguration(CompleteConfiguration.class);
+ }
+
+ @Override
+ public String getKeyType() {
+ return config().getKeyType().getName();
+ }
+
+ @Override
+ public String getValueType() {
+ return config().getValueType().getName();
+ }
+
+ @Override
+ public boolean isReadThrough() {
+ try {
+ return completeConfig().isReadThrough();
+ } catch (final Exception e) {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isWriteThrough() {
+ try {
+ return completeConfig().isWriteThrough();
+ } catch (final Exception e) {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isStoreByValue() {
+ return config().isStoreByValue();
+ }
+
+ @Override
+ public boolean isStatisticsEnabled() {
+ try {
+ return completeConfig().isStatisticsEnabled();
+ } catch (final Exception e) {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isManagementEnabled() {
+ try {
+ return completeConfig().isManagementEnabled();
+ } catch (final Exception e) {
+ return false;
+ }
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheMXBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheMXBean.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheStatisticsMXBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheStatisticsMXBean.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheStatisticsMXBean.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheStatisticsMXBean.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,89 @@
+package org.apache.commons.jcs.jcache.jmx;
+
+import org.apache.commons.jcs.jcache.Statistics;
+
+import javax.cache.management.CacheStatisticsMXBean;
+
+public class JCSCacheStatisticsMXBean implements CacheStatisticsMXBean {
+ private final Statistics statistics;
+
+ public JCSCacheStatisticsMXBean(final Statistics stats) {
+ this.statistics = stats;
+ }
+
+ @Override
+ public void clear() {
+ statistics.reset();
+ }
+
+ @Override
+ public long getCacheHits() {
+ return statistics.getHits();
+ }
+
+ @Override
+ public float getCacheHitPercentage() {
+ final long hits = getCacheHits();
+ if (hits == 0) {
+ return 0;
+ }
+ return (float) hits / getCacheGets() * 100.0f;
+ }
+
+ @Override
+ public long getCacheMisses() {
+ return statistics.getMisses();
+ }
+
+ @Override
+ public float getCacheMissPercentage() {
+ final long misses = getCacheMisses();
+ if (misses == 0) {
+ return 0;
+ }
+ return (float) misses / getCacheGets() * 100.0f;
+ }
+
+ @Override
+ public long getCacheGets() {
+ return getCacheHits() + getCacheMisses();
+ }
+
+ @Override
+ public long getCachePuts() {
+ return statistics.getPuts();
+ }
+
+ @Override
+ public long getCacheRemovals() {
+ return statistics.getRemovals();
+ }
+
+ @Override
+ public long getCacheEvictions() {
+ return statistics.getEvictions();
+ }
+
+ @Override
+ public float getAverageGetTime() {
+ return averageTime(statistics.getTimeTakenForGets());
+ }
+
+ @Override
+ public float getAveragePutTime() {
+ return averageTime(statistics.getTimeTakenForPuts());
+ }
+
+ @Override
+ public float getAverageRemoveTime() {
+ return averageTime(statistics.getTimeTakenForRemovals());
+ }
+
+ private float averageTime(final long timeTaken) {
+ final long gets = getCacheGets();
+ if (timeTaken == 0 || gets == 0) {
+ return 0;
+ }
+ return timeTaken / gets;
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheStatisticsMXBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JCSCacheStatisticsMXBean.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JMXs.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JMXs.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JMXs.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JMXs.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,47 @@
+package org.apache.commons.jcs.jcache.jmx;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+
+import static com.sun.jmx.defaults.JmxProperties.JMX_INITIAL_BUILDER;
+
+public class JMXs {
+ private static final MBeanServer SERVER = findMBeanServer();
+
+ public static MBeanServer server() {
+ return SERVER;
+ }
+
+ public static void register(final ObjectName on, final Object bean) {
+ if (!SERVER.isRegistered(on)) {
+ try {
+ SERVER.registerMBean(bean, on);
+ } catch (final Exception e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+ }
+
+ public static void unregister(final ObjectName on) {
+ if (SERVER.isRegistered(on)) {
+ try {
+ SERVER.unregisterMBean(on);
+ } catch (final Exception e) {
+ // no-op
+ }
+ }
+ }
+
+ private static MBeanServer findMBeanServer() {
+ if (System.getProperty(JMX_INITIAL_BUILDER) != null) {
+ return MBeanServerFactory.createMBeanServer();
+ }
+ return ManagementFactory.getPlatformMBeanServer();
+ }
+
+ private JMXs() {
+ // no-op
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JMXs.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/jmx/JMXs.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/resources/META-INF/services/javax.cache.spi.CachingProvider
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/resources/META-INF/services/javax.cache.spi.CachingProvider?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/resources/META-INF/services/javax.cache.spi.CachingProvider (added)
+++ commons/proper/jcs/trunk/src/resources/META-INF/services/javax.cache.spi.CachingProvider Sun Apr 27 23:47:39 2014
@@ -0,0 +1 @@
+org.apache.commons.jcs.jcache.JCSCachingProvider
Added: commons/proper/jcs/trunk/src/resources/cache.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/resources/cache.ccf?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/resources/cache.ccf (added)
+++ commons/proper/jcs/trunk/src/resources/cache.ccf Sun Apr 27 23:47:39 2014
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# #############################################################
+# ################# DEFAULT CACHE REGION #####################
+# sets the default aux value for any non configured caches
+jcs.default=DC
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=200001
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=false
+jcs.default.elementattributes.MaxLifeSeconds=700
+jcs.default.elementattributes.IdleTime=1800
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsRemote=true
+jcs.default.elementattributes.IsLateral=true
+
+
+# #############################################################
+# ################# OPTIONAL THREAD POOL CONFIGURATION ###################
+# Default thread pool config
+thread_pool.default.boundarySize=2000
+thread_pool.default.maximumPoolSize=150
+thread_pool.default.minimumPoolSize=4
+thread_pool.default.keepAliveTime=350000
+# RUN ABORT WAIT BLOCK DISCARDOLDEST
+thread_pool.default.whenBlockedPolicy=RUN
+thread_pool.default.startUpSize=4
+
+# Default Cache Event Queue thread pool config, used by auxiliaries
+# since it doesn't use a boundary, some of the options are unnecessary
+thread_pool.cache_event_queue.useBoundary=false
+thread_pool.cache_event_queue.minimumPoolSize=5
+thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.startUpSize=5
+
+# Disk Cache pool
+thread_pool.disk_cache_event_queue.useBoundary=false
+thread_pool.remote_cache_client.maximumPoolSize=15
+thread_pool.disk_cache_event_queue.minimumPoolSize=1
+thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.startUpSize=1
+
+# Remote cache client thread pool config
+thread_pool.remote_cache_client.boundarySize=75
+thread_pool.remote_cache_client.maximumPoolSize=150
+thread_pool.remote_cache_client.minimumPoolSize=4
+thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.whenBlockedPolicy=RUN
+thread_pool.remote_cache_client.startUpSize=4
+
+
Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/SystemPropertyUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/SystemPropertyUnitTest.java?rev=1590527&r1=1590526&r2=1590527&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/SystemPropertyUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/SystemPropertyUnitTest.java Sun Apr 27 23:47:39 2014
@@ -23,6 +23,8 @@ import junit.framework.TestCase;
import org.apache.commons.jcs.JCS;
import org.apache.commons.jcs.engine.control.CompositeCacheManager;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
/**
* This test is for the system property usage in configuration values.
@@ -30,6 +32,7 @@ import org.apache.commons.jcs.engine.con
* @author Aaron Smuts
*
*/
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SystemPropertyUnitTest
extends TestCase
{
@@ -40,7 +43,7 @@ public class SystemPropertyUnitTest
* @throws Exception
*
*/
- public void testSystemPropertyInValueDelimiter()
+ public void test1SystemPropertyInValueDelimiter()
throws Exception
{
@@ -54,6 +57,8 @@ public class SystemPropertyUnitTest
assertEquals( "We should have used the system property for the memory size", maxMemory, cache
.getCacheAttributes().getMaxObjects() );
+ System.clearProperty("MY_SYSTEM_PROPERTY_DISK_DIR");
+ System.clearProperty("MY_SYSTEM_PROPERTY_MAX_SIZE");
}
/**
@@ -64,7 +69,7 @@ public class SystemPropertyUnitTest
* @throws Exception
*
*/
- public void testSystemPropertyMissingInValueDelimeter()
+ public void test2SystemPropertyMissingInValueDelimeter()
throws Exception
{
System.getProperties().setProperty( "MY_SYSTEM_PROPERTY_DISK_DIR", "system_set" );
@@ -77,6 +82,8 @@ public class SystemPropertyUnitTest
assertEquals( "We should have used the default property for the memory size", 100, cache.getCacheAttributes()
.getMaxObjects() );
+ System.clearProperty("MY_SYSTEM_PROPERTY_DISK_DIR");
+
}
}
Added: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CacheTest.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CacheTest.java (added)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CacheTest.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,242 @@
+package org.apache.commons.jcs.jcache;
+
+import org.junit.Test;
+
+import javax.cache.Cache;
+import javax.cache.CacheManager;
+import javax.cache.Caching;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
+import javax.cache.configuration.CompleteConfiguration;
+import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryCreatedListener;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListener;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryRemovedListener;
+import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.integration.CacheLoader;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriter;
+import javax.cache.spi.CachingProvider;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class CacheTest {
+ @Test
+ public void getPut() {
+ final CachingProvider cachingProvider = Caching.getCachingProvider();
+ final CacheManager cacheManager = cachingProvider.getCacheManager();
+ cacheManager.createCache("default", null);
+ final Cache<String, String> cache = cacheManager.getCache("default");
+ assertFalse(cache.containsKey("foo"));
+ cache.put("foo", "bar");
+ assertTrue(cache.containsKey("foo"));
+ assertEquals("bar", cache.get("foo"));
+ cache.remove("foo");
+ assertFalse(cache.containsKey("foo"));
+ cachingProvider.close();
+ }
+
+ @Test
+ public void listeners() {
+ final CachingProvider cachingProvider = Caching.getCachingProvider();
+ final CacheManager cacheManager = cachingProvider.getCacheManager();
+ cacheManager.createCache("default", null);
+ final Cache<String, String> cache = cacheManager.getCache("default");
+ final Set<String> event = new HashSet<String>();
+ cache.registerCacheEntryListener(new CacheEntryListenerConfiguration<String, String>() {
+ @Override
+ public Factory<CacheEntryListener<? super String, ? super String>> getCacheEntryListenerFactory() {
+ return new Factory<CacheEntryListener<? super String, ? super String>>() {
+ @Override
+ public CacheEntryListener<? super String, ? super String> create() {
+ return new CacheEntryCreatedListener<String, String>() {
+ @Override
+ public void onCreated(Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents) throws CacheEntryListenerException {
+ event.add(cacheEntryEvents.iterator().next().getKey());
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public boolean isOldValueRequired() {
+ return false;
+ }
+
+ @Override
+ public Factory<CacheEntryEventFilter<? super String, ? super String>> getCacheEntryEventFilterFactory() {
+ return null;
+ }
+
+ @Override
+ public boolean isSynchronous() {
+ return false;
+ }
+ });
+ cache.registerCacheEntryListener(new CacheEntryListenerConfiguration<String, String>() {
+ @Override
+ public Factory<CacheEntryListener<? super String, ? super String>> getCacheEntryListenerFactory() {
+ return new Factory<CacheEntryListener<? super String, ? super String>>() {
+ @Override
+ public CacheEntryListener<? super String, ? super String> create() {
+ return new CacheEntryUpdatedListener<String, String>() {
+ @Override
+ public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents) throws CacheEntryListenerException {
+ event.add(cacheEntryEvents.iterator().next().getKey());
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public boolean isOldValueRequired() {
+ return false;
+ }
+
+ @Override
+ public Factory<CacheEntryEventFilter<? super String, ? super String>> getCacheEntryEventFilterFactory() {
+ return null;
+ }
+
+ @Override
+ public boolean isSynchronous() {
+ return false;
+ }
+ });
+ cache.registerCacheEntryListener(new CacheEntryListenerConfiguration<String, String>() {
+ @Override
+ public Factory<CacheEntryListener<? super String, ? super String>> getCacheEntryListenerFactory() {
+ return new Factory<CacheEntryListener<? super String, ? super String>>() {
+ @Override
+ public CacheEntryListener<? super String, ? super String> create() {
+ return new CacheEntryRemovedListener<String, String>() {
+ @Override
+ public void onRemoved(Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents) throws CacheEntryListenerException {
+ event.add(cacheEntryEvents.iterator().next().getKey());
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public boolean isOldValueRequired() {
+ return false;
+ }
+
+ @Override
+ public Factory<CacheEntryEventFilter<? super String, ? super String>> getCacheEntryEventFilterFactory() {
+ return null;
+ }
+
+ @Override
+ public boolean isSynchronous() {
+ return false;
+ }
+ });
+
+ cache.put("foo", "bar");
+ assertEquals(1, event.size());
+ assertEquals("foo", event.iterator().next());
+ event.clear();
+ cache.put("foo", "new");
+ assertEquals(1, event.size());
+ assertEquals("foo", event.iterator().next());
+ event.clear();
+ cache.remove("foo");
+ assertEquals(1, event.size());
+ assertEquals("foo", event.iterator().next());
+
+ cachingProvider.close();
+ }
+
+ @Test
+ public void loader() {
+ final CachingProvider cachingProvider = Caching.getCachingProvider();
+ final CacheManager cacheManager = cachingProvider.getCacheManager();
+ cacheManager.createCache("default", new CompleteConfiguration<Object, Object>() {
+ @Override
+ public boolean isReadThrough() {
+ return true;
+ }
+
+ @Override
+ public boolean isWriteThrough() {
+ return false;
+ }
+
+ @Override
+ public boolean isStatisticsEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isManagementEnabled() {
+ return false;
+ }
+
+ @Override
+ public Iterable<CacheEntryListenerConfiguration<Object, Object>> getCacheEntryListenerConfigurations() {
+ return null;
+ }
+
+ @Override
+ public Factory<CacheLoader<Object, Object>> getCacheLoaderFactory() {
+ return new Factory<CacheLoader<Object, Object>>() {
+ @Override
+ public CacheLoader<Object, Object> create() {
+ return new CacheLoader<Object, Object>() {
+ @Override
+ public Object load(Object key) throws CacheLoaderException {
+ return "super";
+ }
+
+ @Override
+ public Map<Object, Object> loadAll(Iterable<?> keys) throws CacheLoaderException {
+ return null;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public Factory<CacheWriter<? super Object, ? super Object>> getCacheWriterFactory() {
+ return null;
+ }
+
+ @Override
+ public Factory<ExpiryPolicy> getExpiryPolicyFactory() {
+ return null;
+ }
+
+ @Override
+ public Class<Object> getKeyType() {
+ return null;
+ }
+
+ @Override
+ public Class<Object> getValueType() {
+ return null;
+ }
+
+ @Override
+ public boolean isStoreByValue() {
+ return false;
+ }
+ });
+ final Cache<String, String> cache = cacheManager.getCache("default");
+ assertEquals("super", cache.get("lazilyLoaded"));
+ cachingProvider.close();
+ }
+}
Propchange: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CacheTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CacheTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CachingProviderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CachingProviderTest.java?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CachingProviderTest.java (added)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CachingProviderTest.java Sun Apr 27 23:47:39 2014
@@ -0,0 +1,22 @@
+package org.apache.commons.jcs.jcache;
+
+import org.junit.Test;
+
+import javax.cache.Caching;
+import javax.cache.spi.CachingProvider;
+
+import static org.junit.Assert.assertNotNull;
+
+public class CachingProviderTest {
+ @Test
+ public void findProvider() {
+ assertNotNull(Caching.getCachingProvider());
+ }
+
+ @Test
+ public void createCacheMgr() {
+ final CachingProvider cachingProvider = Caching.getCachingProvider();
+ assertNotNull(cachingProvider.getCacheManager());
+ cachingProvider.close();
+ }
+}
Propchange: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CachingProviderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/jcache/CachingProviderTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/tck.sh
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/tck.sh?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/tck.sh (added)
+++ commons/proper/jcs/trunk/tck.sh Sun Apr 27 23:47:39 2014
@@ -0,0 +1,3 @@
+#! /bin/bash
+mvn clean -f tck.xml test $@
+
Propchange: commons/proper/jcs/trunk/tck.sh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/tck.sh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/tck.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/tck.xml?rev=1590527&view=auto
==============================================================================
--- commons/proper/jcs/trunk/tck.xml (added)
+++ commons/proper/jcs/trunk/tck.xml Sun Apr 27 23:47:39 2014
@@ -0,0 +1,214 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <!--
+ TO RUN TCKs CALL:
+
+ $ mvn -f tck.xml test
+
+ or one of the following profiles:
+ -P test-optional-cache
+ -P test-basic-cache
+
+ -->
+
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jcs-jcache-tck</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>JCache TCK</name>
+
+ <properties>
+ <jsr107.api.version>1.0.0</jsr107.api.version>
+
+ <implementation-groupId>${project.groupId}</implementation-groupId>
+ <implementation-artifactId>commons-jcs</implementation-artifactId>
+ <implementation-version>${project.version}</implementation-version>
+
+ <CacheManagerImpl>org.apache.commons.jcs.jcache.JCSCachingManager</CacheManagerImpl>
+ <CacheImpl>org.apache.commons.jcs.jcache.JCSCache</CacheImpl>
+ <CacheEntryImpl>org.apache.commons.jcs.jcache.JCSEntry</CacheEntryImpl>
+
+ <javax.management.builder.initial>org.apache.commons.jcs.jcache.jmx.ConfigurableMBeanServerIdBuilder</javax.management.builder.initial>
+ <org.jsr107.tck.management.agentId>MBeanServerJCS</org.jsr107.tck.management.agentId>
+
+ <domain-lib-dir>${project.build.directory}/domainlib</domain-lib-dir>
+ <domain-jar>domain.jar</domain-jar>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>commons-jcs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>test-domain</artifactId>
+ <version>${jsr107.api.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>app-domain</artifactId>
+ <version>${jsr107.api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>${jsr107.api.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-tests</artifactId>
+ <version>${jsr107.api.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-tests</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ <version>${jsr107.api.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-cache-tests</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.testOutputDirectory}
+ </outputDirectory>
+ <includeArtifactIds>cache-tests</includeArtifactIds>
+ <includeScope>test</includeScope>
+ <excludes>**/unwrap.properties</excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-domain</id>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.cache</groupId>
+ <artifactId>app-domain</artifactId>
+ <version>${jsr107.api.version}</version>
+ <outputDirectory>${domain-lib-dir}</outputDirectory>
+ <destFileName>${domain-jar}</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.0.3</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.9</version>
+ <configuration>
+ <systemPropertyVariables>
+ <domainJar>${domain-lib-dir}/${domain-jar}</domainJar>
+ <javax.management.builder.initial>${javax.management.builder.initial}</javax.management.builder.initial>
+ <org.jsr107.tck.management.agentId>${org.jsr107.tck.management.agentId}</org.jsr107.tck.management.agentId>
+ <javax.cache.CacheManager>${CacheManagerImpl}</javax.cache.CacheManager>
+ <javax.cache.Cache>${CacheImpl}</javax.cache.Cache>
+ <javax.cache.Cache.Entry>${CacheEntryImpl}</javax.cache.Cache.Entry>
+ <javax.cache.annotation.CacheInvocationContext>${CacheInvocationContextImpl}</javax.cache.annotation.CacheInvocationContext>
+ </systemPropertyVariables>
+ <excludes>
+ <exclude>**/annotation/*Test.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>test-basic-cache</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>false</skipTests>
+ <excludes>
+ <include>**/interceptor/*Test.java</include>
+ </excludes>
+ <systemPropertyVariables>
+ <domainJar>${domain-lib-dir}/${domain-jar}
+ </domainJar>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>test-optional-cache</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/interceptor/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
+
Propchange: commons/proper/jcs/trunk/tck.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/tck.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision