JBoss Cache SVN: r7726 - core/branches/flat/src/main/java/org/horizon.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 12:40:47 -0500 (Wed, 18 Feb 2009)
New Revision: 7726
Modified:
core/branches/flat/src/main/java/org/horizon/Cache.java
Log:
Javadocs
Modified: core/branches/flat/src/main/java/org/horizon/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/Cache.java 2009-02-18 17:32:24 UTC (rev 7725)
+++ core/branches/flat/src/main/java/org/horizon/Cache.java 2009-02-18 17:40:47 UTC (rev 7726)
@@ -32,7 +32,25 @@
import java.util.concurrent.TimeUnit;
/**
+ * The central interface of Horizon. A Cache provides a highly concurrent, optionally distributed data structure with
+ * additional features such as: <ul> <li>JTA transaction compatibility</li> <li>Eviction support to prevent evicting
+ * entries from memory to prevent {@link OutOfMemoryError}s</li> <li>Persisting entries to a {@link
+ * org.horizon.loader.CacheStore}, either when they are evicted as an overflow, or all the time, to maintain persistent
+ * copies that would withstand server failure or restarts.</li> </ul>
+ * <p/>
+ * For convenience, Cache extends {@link java.util.concurrent.ConcurrentMap} and implements all methods accordingly,
+ * although methods like {@link java.util.concurrent.ConcurrentMap#keySet()}, {@link
+ * java.util.concurrent.ConcurrentMap#values()} and {@link java.util.concurrent.ConcurrentMap#entrySet()} are expensive
+ * (prohibitively so when using a distributed cache) and frequent use of these methods is not recommended.
+ * <p/>
+ * Also, like most {@link java.util.concurrent.ConcurrentMap} implementations, Cache does not support the use of
+ * <tt>null</tt> keys (although <tt>null</tt> values are allowed).
+ * <p/>
+ * Please see the Horizon documentation for more details.
+ * <p/>
+ *
* @author Mircea.Markus(a)jboss.com
+ * @author Manik Surtani
* @since 1.0
*/
public interface Cache<K, V> extends ConcurrentMap<K, V>, Lifecycle, Listenable {
15 years, 11 months
JBoss Cache SVN: r7725 - in core/branches/flat/src: main/java/org/horizon/loader/decorators and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 12:32:24 -0500 (Wed, 18 Feb 2009)
New Revision: 7725
Modified:
core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/ReadOnlyStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java
core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java
Log:
Better naming for streaming API in CacheStore
Modified: core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -26,18 +26,18 @@
/**
* Writes contents of the stream to the store. Implementations should expect that the stream contains data in an
- * implementation-specific format, typically generated using {@link #load(java.io.OutputStream)}. While not a
+ * implementation-specific format, typically generated using {@link #toStream(java.io.OutputStream)}. While not a
* requirement, it is recommended that implementations make use of the {@link org.horizon.marshall.Marshaller} when
* dealing with the stream to make use of efficient marshalling.
*
* @param inputStream stream to read from
* @throws CacheLoaderException in the event of problems writing to the store
*/
- void store(InputStream inputStream) throws CacheLoaderException;
+ void fromStream(InputStream inputStream) throws CacheLoaderException;
/**
* Loads the entire state into a stream, using whichever format is most efficient for the cache loader
- * implementation. Typically read and parsed by {@link #store(java.io.InputStream)}.
+ * implementation. Typically read and parsed by {@link #fromStream(java.io.InputStream)}.
* <p/>
* While not a requirement, it is recommended that implementations make use of the {@link
* org.horizon.marshall.Marshaller} when dealing with the stream to make use of efficient marshalling.
@@ -45,7 +45,7 @@
* @param outputStream stream to write to
* @throws CacheLoaderException in the event of problems reading from the store
*/
- void load(OutputStream outputStream) throws CacheLoaderException;
+ void toStream(OutputStream outputStream) throws CacheLoaderException;
/**
* Clears all entries in the store
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -42,12 +42,12 @@
delegate.store(ed);
}
- public void store(InputStream inputStream) throws CacheLoaderException {
- delegate.store(inputStream);
+ public void fromStream(InputStream inputStream) throws CacheLoaderException {
+ delegate.fromStream(inputStream);
}
- public void load(OutputStream outputStream) throws CacheLoaderException {
- delegate.load(outputStream);
+ public void toStream(OutputStream outputStream) throws CacheLoaderException {
+ delegate.toStream(outputStream);
}
public void clear() throws CacheLoaderException {
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -39,22 +39,22 @@
for (CacheStore s : stores.keySet()) s.store(ed);
}
- public void store(InputStream inputStream) throws CacheLoaderException {
+ public void fromStream(InputStream inputStream) throws CacheLoaderException {
// loading and storing state via streams is *only* supported on the *first* store that has fetchPersistentState set.
for (Map.Entry<CacheStore, CacheLoaderConfig> e : stores.entrySet()) {
if (e.getValue().isFetchPersistentState()) {
- e.getKey().store(inputStream);
+ e.getKey().fromStream(inputStream);
// do NOT continue this for other stores, since the stream will not be in an appropriate state anymore
break;
}
}
}
- public void load(OutputStream outputStream) throws CacheLoaderException {
+ public void toStream(OutputStream outputStream) throws CacheLoaderException {
// loading and storing state via streams is *only* supported on the *first* store that has fetchPersistentState set.
for (Map.Entry<CacheStore, CacheLoaderConfig> e : stores.entrySet()) {
if (e.getValue().isFetchPersistentState()) {
- e.getKey().load(outputStream);
+ e.getKey().toStream(outputStream);
// do NOT continue this for other stores, since the stream will not be in an appropriate state anymore
break;
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/ReadOnlyStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/ReadOnlyStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/ReadOnlyStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -27,7 +27,7 @@
}
@Override
- public void store(InputStream inputStream) {
+ public void fromStream(InputStream inputStream) {
// no-op
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -112,8 +112,8 @@
}
@Override
- public void store(InputStream inputStream) throws CacheLoaderException {
- if (active) super.store(inputStream);
+ public void fromStream(InputStream inputStream) throws CacheLoaderException {
+ if (active) super.fromStream(inputStream);
}
@Override
Modified: core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -177,7 +177,7 @@
}
}
- public void store(InputStream inputStream) throws CacheLoaderException {
+ public void fromStream(InputStream inputStream) throws CacheLoaderException {
ObjectInputStream ois = null;
try {
// first clear all local state
@@ -219,7 +219,7 @@
}
}
- public void load(OutputStream outputStream) throws CacheLoaderException {
+ public void toStream(OutputStream outputStream) throws CacheLoaderException {
ObjectOutputStream oos = null;
try {
acquireGlobalLock(true);
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -21,11 +21,11 @@
// TODO: Manik: Customise this generated block
}
- public void store(InputStream inputStream) {
+ public void fromStream(InputStream inputStream) {
// TODO: Manik: Customise this generated block
}
- public void load(OutputStream outputStream) {
+ public void toStream(OutputStream outputStream) {
// TODO: Manik: Customise this generated block
}
Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -247,11 +247,11 @@
cs.store(new StoredEntry("k3", "v3", -1, -1));
ByteArrayOutputStream out = new ByteArrayOutputStream();
- cs.load(out);
+ cs.toStream(out);
out.flush();
out.close();
cs.clear();
- cs.store(new ByteArrayInputStream(out.toByteArray()));
+ cs.fromStream(new ByteArrayInputStream(out.toByteArray()));
Set<StoredEntry> set = cs.loadAll();
Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -237,7 +237,7 @@
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(byteStream);
- cs.load(oos);
+ cs.toStream(oos);
oos.close();
byteStream.close();
cs.clear();
@@ -249,7 +249,7 @@
assert !s.containsKey("k2");
}
- cs.store(new ObjectInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
+ cs.fromStream(new ObjectInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
assert cs.containsKey("k1");
assert cs.containsKey("k2");
Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -22,7 +22,7 @@
store.purgeExpired();
store.remove("key");
store.store((StoredEntry) null);
- store.store((InputStream) null);
+ store.fromStream((InputStream) null);
store.prepare(null, null, true);
store.commit(null);
store.rollback(null);
Modified: core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
+++ core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java 2009-02-18 17:32:24 UTC (rev 7725)
@@ -36,7 +36,7 @@
}
@SuppressWarnings("unchecked")
- public void store(InputStream inputStream) throws CacheLoaderException {
+ public void fromStream(InputStream inputStream) throws CacheLoaderException {
try {
ObjectInputStream ois = inputStream instanceof ObjectInputStream ? (ObjectInputStream) inputStream :
new ObjectInputStream(inputStream);
@@ -52,7 +52,7 @@
}
}
- public void load(OutputStream outputStream) throws CacheLoaderException {
+ public void toStream(OutputStream outputStream) throws CacheLoaderException {
try {
ObjectOutputStream oos = outputStream instanceof ObjectOutputStream ? (ObjectOutputStream) outputStream :
new ObjectOutputStream(outputStream);
15 years, 11 months
JBoss Cache SVN: r7724 - in core/branches/flat/src: main/java/org/horizon/interceptors and 8 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 12:13:31 -0500 (Wed, 18 Feb 2009)
New Revision: 7724
Added:
core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderException.java
Modified:
core/branches/flat/src/main/java/org/horizon/container/UnsortedDataContainer.java
core/branches/flat/src/main/java/org/horizon/interceptors/ActivationInterceptor.java
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheLoader.java
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/CacheLoader.java
core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManagerImpl.java
core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/AsyncStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java
core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStoreConfig.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java
core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java
core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java
Log:
File cache loader is complete
Modified: core/branches/flat/src/main/java/org/horizon/container/UnsortedDataContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/container/UnsortedDataContainer.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/container/UnsortedDataContainer.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -21,8 +21,10 @@
*/
package org.horizon.container;
+import org.horizon.CacheException;
import org.horizon.factories.annotations.Inject;
import org.horizon.factories.annotations.Stop;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheLoaderManager;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
@@ -59,13 +61,17 @@
private void expire(Object key) {
expirableData.remove(key);
- expireOnCacheLoader(key);
+ expireOnCacheStore(key);
}
- private void expireOnCacheLoader(Object key) {
+ private void expireOnCacheStore(Object key) {
if (cacheStore == null && clm != null) cacheStore = clm.getCacheStore();
if (cacheStore != null) {
- cacheStore.remove(key);
+ try {
+ cacheStore.remove(key);
+ } catch (CacheLoaderException e) {
+ throw new CacheException("Unable to expire entry in cache store", e);
+ }
}
}
@@ -193,7 +199,7 @@
Map.Entry<Object, ExpirableCachedValue> entry = iter.next();
ExpirableCachedValue cv = entry.getValue();
if (cv.isExpired()) {
- expireOnCacheLoader(entry.getKey());
+ expireOnCacheStore(entry.getKey());
purged.add(entry.getKey());
iter.remove();
}
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/ActivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/ActivationInterceptor.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/ActivationInterceptor.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -10,6 +10,7 @@
import org.horizon.factories.annotations.Start;
import org.horizon.jmx.annotations.ManagedAttribute;
import org.horizon.jmx.annotations.ManagedOperation;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import java.util.concurrent.atomic.AtomicLong;
@@ -64,7 +65,7 @@
return retval;
}
- private void removeFromStore(Object... keys) {
+ private void removeFromStore(Object... keys) throws CacheLoaderException {
for (Object k : keys) store.remove(k);
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheLoader.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheLoader.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -1,10 +1,15 @@
package org.horizon.loader;
/**
- * // TODO: Manik: Document this!
+ * An abstract {@link org.horizon.loader.CacheLoader} that holds common implementations for some methods
*
* @author Manik Surtani
* @since 1.0
*/
public abstract class AbstractCacheLoader implements CacheLoader {
+
+ public boolean containsKey(Object key) throws CacheLoaderException {
+ return load(key) != null;
+ }
+
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -5,13 +5,15 @@
import org.horizon.loader.modifications.Store;
import javax.transaction.Transaction;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
- * // TODO: Manik: Document this!
+ * An abstract {@link org.horizon.loader.CacheStore} that holds common implementations for some methods
*
* @author Manik Surtani
* @since 1.0
@@ -20,7 +22,7 @@
private final Map<Transaction, List<? extends Modification>> transactions = new ConcurrentHashMap<Transaction, List<? extends Modification>>();
- protected void applyModifications(List<? extends Modification> mods) {
+ protected void applyModifications(List<? extends Modification> mods) throws CacheLoaderException {
for (Modification m : mods) {
switch (m.getType()) {
case STORE:
@@ -40,7 +42,7 @@
}
}
- public void prepare(List<? extends Modification> mods, Transaction tx, boolean isOnePhase) {
+ public void prepare(List<? extends Modification> mods, Transaction tx, boolean isOnePhase) throws CacheLoaderException {
if (isOnePhase) {
applyModifications(mods);
} else {
@@ -52,18 +54,32 @@
transactions.remove(tx);
}
- public void commit(Transaction tx) {
+ public void commit(Transaction tx) throws CacheLoaderException {
List<? extends Modification> list = transactions.remove(tx);
if (list != null && !list.isEmpty()) applyModifications(list);
}
- public void removeAll(Set<Object> keys) {
+ public void removeAll(Set<Object> keys) throws CacheLoaderException {
if (keys != null && !keys.isEmpty()) {
for (Object key : keys) remove(key);
}
}
- public boolean containsKey(Object key) {
- return load(key) != null;
+ protected final void safeClose(InputStream stream) throws CacheLoaderException {
+ if (stream == null) return;
+ try {
+ stream.close();
+ } catch (Exception e) {
+ throw new CacheLoaderException("Problems closing input stream", e);
+ }
}
+
+ protected final void safeClose(OutputStream stream) throws CacheLoaderException {
+ if (stream == null) return;
+ try {
+ stream.close();
+ } catch (Exception e) {
+ throw new CacheLoaderException("Problems closing output stream", e);
+ }
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/CacheLoader.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/CacheLoader.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -31,21 +31,24 @@
*
* @param key key
* @return an entry
+ * @throws CacheLoaderException in the event of problems reading from source
*/
- StoredEntry load(Object key);
+ StoredEntry load(Object key) throws CacheLoaderException;
/**
* Loads all entries in the loader. Expired entries are not returned.
*
* @return a set of entries, or an empty set if the loader is emptied.
+ * @throws CacheLoaderException in the event of problems reading from source
*/
- Set<StoredEntry> loadAll();
+ Set<StoredEntry> loadAll() throws CacheLoaderException;
/**
* @param key key to test
* @return true if the key exists, false otherwise
+ * @throws CacheLoaderException in the event of problems reading from source
*/
- boolean containsKey(Object key);
+ boolean containsKey(Object key) throws CacheLoaderException;
/**
Added: core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderException.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderException.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderException.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -0,0 +1,24 @@
+package org.horizon.loader;
+
+/**
+ * An exception thrown by a {@link CacheLoader} implementation if there are problems reading from a loader.
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public class CacheLoaderException extends Exception {
+ public CacheLoaderException() {
+ }
+
+ public CacheLoaderException(String message) {
+ super(message);
+ }
+
+ public CacheLoaderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CacheLoaderException(Throwable cause) {
+ super(cause);
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManagerImpl.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManagerImpl.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -53,7 +53,11 @@
public void purge() {
CacheStore cs = getCacheStore();
- if (cs != null) cs.clear();
+ if (cs != null) try {
+ cs.clear();
+ } catch (CacheLoaderException e) {
+ throw new CacheException("Unable to purge cache store", e);
+ }
}
private void purgeLoaders(boolean force) throws Exception {
@@ -106,7 +110,12 @@
log.debug("Preloading transient state from cache loader {0}", loader);
long start = 0, stop = 0, total = 0;
if (log.isDebugEnabled()) start = System.currentTimeMillis();
- Set<StoredEntry> state = loader.loadAll();
+ Set<StoredEntry> state;
+ try {
+ state = loader.loadAll();
+ } catch (CacheLoaderException e) {
+ throw new CacheException("Unable to preload!", e);
+ }
for (StoredEntry se : state)
cache.getAdvancedCache().put(se.getKey(), se.getValue(), se.getLifespan(),
Modified: core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/CacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -3,7 +3,6 @@
import org.horizon.loader.modifications.Modification;
import javax.transaction.Transaction;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@@ -21,8 +20,9 @@
* Stores an entry
*
* @param ed entry to store
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void store(StoredEntry ed);
+ void store(StoredEntry ed) throws CacheLoaderException;
/**
* Writes contents of the stream to the store. Implementations should expect that the stream contains data in an
@@ -31,10 +31,9 @@
* dealing with the stream to make use of efficient marshalling.
*
* @param inputStream stream to read from
- * @throws java.io.IOException in case of IO problems
- * @throws ClassNotFoundException in case of not being able to read the stream
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void store(InputStream inputStream) throws IOException, ClassNotFoundException;
+ void store(InputStream inputStream) throws CacheLoaderException;
/**
* Loads the entire state into a stream, using whichever format is most efficient for the cache loader
@@ -44,34 +43,40 @@
* org.horizon.marshall.Marshaller} when dealing with the stream to make use of efficient marshalling.
*
* @param outputStream stream to write to
- * @throws java.io.IOException in the event of problems writing to the stream
+ * @throws CacheLoaderException in the event of problems reading from the store
*/
- void load(OutputStream outputStream) throws IOException;
+ void load(OutputStream outputStream) throws CacheLoaderException;
/**
* Clears all entries in the store
+ *
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void clear();
+ void clear() throws CacheLoaderException;
/**
* Removes an entry in the store.
*
* @param key key to remove
* @return true if the entry was removed; false if the entry wasn't found.
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- boolean remove(Object key);
+ boolean remove(Object key) throws CacheLoaderException;
/**
* Bulk remove operation
*
* @param keys to remove
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void removeAll(Set<Object> keys);
+ void removeAll(Set<Object> keys) throws CacheLoaderException;
/**
* Purges expired entries from the store.
+ *
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void purgeExpired();
+ void purgeExpired() throws CacheLoaderException;
/**
* Issues a prepare call with a set of modifications to be applied to the cache store
@@ -80,15 +85,17 @@
* @param tx transaction identifier
* @param isOnePhase if true, there will not be a commit or rollback phase and changes should be flushed
* immediately
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void prepare(List<? extends Modification> modifications, Transaction tx, boolean isOnePhase);
+ void prepare(List<? extends Modification> modifications, Transaction tx, boolean isOnePhase) throws CacheLoaderException;
/**
* Commits a transaction that has been previously prepared
*
* @param tx tx to commit
+ * @throws CacheLoaderException in the event of problems writing to the store
*/
- void commit(Transaction tx);
+ void commit(Transaction tx) throws CacheLoaderException;
/**
* Rolls back a transaction that has been previously prepared
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/AbstractDelegatingStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -3,13 +3,13 @@
import org.horizon.Cache;
import org.horizon.loader.AbstractCacheStore;
import org.horizon.loader.CacheLoaderConfig;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
import org.horizon.loader.modifications.Modification;
import org.horizon.marshall.Marshaller;
import javax.transaction.Transaction;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@@ -38,39 +38,42 @@
return delegate;
}
- public void store(StoredEntry ed) {
+ public void store(StoredEntry ed) throws CacheLoaderException {
delegate.store(ed);
}
- public void store(InputStream inputStream) throws IOException, ClassNotFoundException {
+ public void store(InputStream inputStream) throws CacheLoaderException {
delegate.store(inputStream);
}
- public void load(OutputStream outputStream) throws IOException {
+ public void load(OutputStream outputStream) throws CacheLoaderException {
delegate.load(outputStream);
}
- public void clear() {
+ public void clear() throws CacheLoaderException {
delegate.clear();
}
- public boolean remove(Object key) {
+ public boolean remove(Object key) throws CacheLoaderException {
return delegate.remove(key);
}
- public void purgeExpired() {
+ public void purgeExpired() throws CacheLoaderException {
delegate.purgeExpired();
}
- public void commit(Transaction tx) {
+ @Override
+ public void commit(Transaction tx) throws CacheLoaderException {
delegate.commit(tx);
}
+ @Override
public void rollback(Transaction tx) {
delegate.rollback(tx);
}
- public void prepare(List<? extends Modification> list, Transaction tx, boolean isOnePhase) {
+ @Override
+ public void prepare(List<? extends Modification> list, Transaction tx, boolean isOnePhase) throws CacheLoaderException {
delegate.prepare(list, tx, isOnePhase);
}
@@ -78,19 +81,20 @@
delegate.init(config, cache, m);
}
- public StoredEntry load(Object key) {
+ public StoredEntry load(Object key) throws CacheLoaderException {
return delegate.load(key);
}
- public Set loadAll() {
+ public Set<StoredEntry> loadAll() throws CacheLoaderException {
return delegate.loadAll();
}
- public boolean containsKey(Object key) {
+ @Override
+ public boolean containsKey(Object key) throws CacheLoaderException {
return delegate.containsKey(key);
}
- public Class getConfigurationClass() {
+ public Class<? extends CacheLoaderConfig> getConfigurationClass() {
return delegate.getConfigurationClass();
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/AsyncStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/AsyncStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/AsyncStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -1,6 +1,7 @@
package org.horizon.loader.decorators;
import org.horizon.CacheException;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
import org.horizon.loader.modifications.Clear;
@@ -127,7 +128,7 @@
super.stop();
}
- protected void applyModificationsSync(List<Modification> mods) {
+ protected void applyModificationsSync(List<Modification> mods) throws CacheLoaderException {
for (Modification m : mods) {
switch (m.getType()) {
case STORE:
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/ChainingCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -3,13 +3,13 @@
import org.horizon.Cache;
import org.horizon.loader.CacheLoader;
import org.horizon.loader.CacheLoaderConfig;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
import org.horizon.loader.modifications.Modification;
import org.horizon.marshall.Marshaller;
import javax.transaction.Transaction;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashSet;
@@ -35,11 +35,11 @@
LinkedHashMap<CacheLoader, CacheLoaderConfig> loaders = new LinkedHashMap<CacheLoader, CacheLoaderConfig>();
LinkedHashMap<CacheStore, CacheLoaderConfig> stores = new LinkedHashMap<CacheStore, CacheLoaderConfig>();
- public void store(StoredEntry ed) {
+ public void store(StoredEntry ed) throws CacheLoaderException {
for (CacheStore s : stores.keySet()) s.store(ed);
}
- public void store(InputStream inputStream) throws IOException, ClassNotFoundException {
+ public void store(InputStream inputStream) throws CacheLoaderException {
// loading and storing state via streams is *only* supported on the *first* store that has fetchPersistentState set.
for (Map.Entry<CacheStore, CacheLoaderConfig> e : stores.entrySet()) {
if (e.getValue().isFetchPersistentState()) {
@@ -50,7 +50,7 @@
}
}
- public void load(OutputStream outputStream) throws IOException {
+ public void load(OutputStream outputStream) throws CacheLoaderException {
// loading and storing state via streams is *only* supported on the *first* store that has fetchPersistentState set.
for (Map.Entry<CacheStore, CacheLoaderConfig> e : stores.entrySet()) {
if (e.getValue().isFetchPersistentState()) {
@@ -61,25 +61,25 @@
}
}
- public void clear() {
+ public void clear() throws CacheLoaderException {
for (CacheStore s : stores.keySet()) s.clear();
}
- public boolean remove(Object key) {
+ public boolean remove(Object key) throws CacheLoaderException {
boolean r = false;
for (CacheStore s : stores.keySet()) r = s.remove(key) || r;
return r;
}
- public void removeAll(Set<Object> keys) {
+ public void removeAll(Set<Object> keys) throws CacheLoaderException {
for (CacheStore s : stores.keySet()) s.removeAll(keys);
}
- public void purgeExpired() {
+ public void purgeExpired() throws CacheLoaderException {
for (CacheStore s : stores.keySet()) s.purgeExpired();
}
- public void commit(Transaction tx) {
+ public void commit(Transaction tx) throws CacheLoaderException {
for (CacheStore s : stores.keySet()) s.commit(tx);
}
@@ -87,7 +87,7 @@
for (CacheStore s : stores.keySet()) s.rollback(tx);
}
- public void prepare(List<? extends Modification> list, Transaction tx, boolean isOnePhase) {
+ public void prepare(List<? extends Modification> list, Transaction tx, boolean isOnePhase) throws CacheLoaderException {
for (CacheStore s : stores.keySet()) s.prepare(list, tx, isOnePhase);
}
@@ -97,7 +97,7 @@
}
}
- public StoredEntry load(Object key) {
+ public StoredEntry load(Object key) throws CacheLoaderException {
StoredEntry se = null;
for (CacheLoader l : loaders.keySet()) {
se = l.load(key);
@@ -106,13 +106,13 @@
return se;
}
- public Set<StoredEntry> loadAll() {
+ public Set<StoredEntry> loadAll() throws CacheLoaderException {
Set<StoredEntry> set = new HashSet<StoredEntry>();
for (CacheStore s : stores.keySet()) set.addAll(s.loadAll());
return set;
}
- public boolean containsKey(Object key) {
+ public boolean containsKey(Object key) throws CacheLoaderException {
for (CacheLoader l : loaders.keySet()) {
if (l.containsKey(key)) return true;
}
@@ -136,7 +136,7 @@
if (loader instanceof CacheStore) stores.put((CacheStore) loader, config);
}
- public void purgeIfNecessary() {
+ public void purgeIfNecessary() throws CacheLoaderException {
for (Map.Entry<CacheStore, CacheLoaderConfig> e : stores.entrySet()) {
if (e.getValue().isPurgeOnStartup()) e.getKey().clear();
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/decorators/SingletonStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -2,6 +2,7 @@
import org.horizon.Cache;
import org.horizon.container.DataContainer;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
import org.horizon.loader.modifications.Modification;
@@ -16,7 +17,6 @@
import org.horizon.remoting.transport.Address;
import javax.transaction.Transaction;
-import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Set;
@@ -104,7 +104,7 @@
// only delegate if the current instance is active
@Override
- public void store(StoredEntry ed) {
+ public void store(StoredEntry ed) throws CacheLoaderException {
if (active) {
if (trace) log.trace("Storing key {0}. Instance: {1}", ed.getKey(), this);
super.store(ed);
@@ -112,27 +112,27 @@
}
@Override
- public void store(InputStream inputStream) throws IOException, ClassNotFoundException {
+ public void store(InputStream inputStream) throws CacheLoaderException {
if (active) super.store(inputStream);
}
@Override
- public void clear() {
+ public void clear() throws CacheLoaderException {
if (active) super.clear();
}
@Override
- public boolean remove(Object key) {
+ public boolean remove(Object key) throws CacheLoaderException {
return active && super.remove(key);
}
@Override
- public void purgeExpired() {
+ public void purgeExpired() throws CacheLoaderException {
if (active) super.purgeExpired();
}
@Override
- public void commit(Transaction tx) {
+ public void commit(Transaction tx) throws CacheLoaderException {
if (active) super.commit(tx);
}
@@ -142,7 +142,7 @@
}
@Override
- public void prepare(List<? extends Modification> list, Transaction tx, boolean isOnePhase) {
+ public void prepare(List<? extends Modification> list, Transaction tx, boolean isOnePhase) throws CacheLoaderException {
if (active) super.prepare(list, tx, isOnePhase);
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -1,41 +1,68 @@
package org.horizon.loader.file;
import org.horizon.Cache;
-import org.horizon.CacheException;
+import org.horizon.config.ConfigurationException;
import org.horizon.loader.AbstractCacheStore;
import org.horizon.loader.CacheLoaderConfig;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.StoredEntry;
+import org.horizon.lock.StripedLock;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
import org.horizon.marshall.Marshaller;
+import org.horizon.util.concurrent.WithinThreadExecutor;
import java.io.*;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* A filesystem-based implementation of a {@link org.horizon.loader.CacheStore}. This file store stores stuff in the
- * following format: <tt>/location/cache name/bucket.dat</tt>
+ * following format: <tt>/{location}/cache name/bucket_number.bucket</tt>
* <p/>
* A hashing algorithm is used to map keys to buckets, and a bucket consists of a collection of key/value pairs.
* <p/>
* This approach, while adding an overhead of having to search buckets for keys, means that we can use any serializable
- * object we like as keys and not just Strings or objects that translate to something meaningful on a file system.
+ * object we like as keys and not just Strings or objects that translate to something meaningful on a file system. Also,
+ * the implementation uses up to {@link Integer#MAX_VALUE} bucket files, which makes it very unlikely that cached
+ * entries would have to share buckets provided the {@link Object#hashCode()} implementations of keys used is well
+ * spread.
+ * <p/>
+ * Locking is based on a {@link org.horizon.lock.StripedLock}, and granularity is per-bucket to prevent file system
+ * corruption with concurrent writes. You can tune the concurrency level of the striped lock (see the Javadocs of
+ * StripedLock for details on what this is) by using the {@link org.horizon.loader.file.FileCacheStoreConfig#setLockConcurrencyLevel(int)}
+ * setter.
+ * <p/>
*
* @author Manik Surtani
* @since 1.0
*/
public class FileCacheStore extends AbstractCacheStore {
private static final Log log = LogFactory.getLog(FileCacheStore.class);
- // TODO: make bucket size fixed rather than number of buckets, and support resizes
+ // doesn't matter that we have such a large amount of file buckets since they are created on disk on demand and
+ // take up no extra memory
private static final int NUM_BUCKETS = Integer.MAX_VALUE;
+ private int streamBufferSize;
+ ExecutorService purgerService;
+ StripedLock bucketLocks;
+ // This global lock guards against direct file system access via clear() and the stream APIs. These three methods
+ // would need exclusive (write) access to this lock while all others can use shared (read) access to this lock since
+ // other methods will use finer grained bucket locks.
+ final ReentrantReadWriteLock globalLock = new ReentrantReadWriteLock();
- // TODO use read and write locks on buckets!
-
FileCacheStoreConfig cfg;
Cache cache;
Marshaller m;
File root;
+ long lockTimeout;
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
this.cfg = (FileCacheStoreConfig) config;
@@ -43,41 +70,58 @@
this.m = m;
}
- public StoredEntry load(Object key) {
- String bucketName = getBucketName(key);
- File f = new File(root, bucketName);
- if (f.exists()) {
- FileInputStream is = null;
- ObjectInputStream ois = null;
- try {
- is = new FileInputStream(f);
- ois = new ObjectInputStream(is);
- Map data = (Map) ois.readObject();
- if (data.containsKey(key)) return (StoredEntry) data.get(key);
- } catch (FileNotFoundException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
- } catch (ClassNotFoundException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
- } finally {
- if (ois != null) try {
- ois.close();
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
- }
- if (is != null) try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
- }
+ public StoredEntry load(Object key) throws CacheLoaderException {
+ log.trace("Loading entry {0}", key);
+ Bucket b = null;
+ try {
+ b = lockAndGetBucket(key, false, false);
+ if (b == null) return null;
+ StoredEntry se = b.getEntry(key);
+ if (se != null && se.isExpired()) {
+ b.removeEntry(key);
+ saveBucket(b);
+ return null;
+ } else {
+ return se;
}
+ } catch (Exception e) {
+ CacheLoaderException cle = (e instanceof CacheLoaderException) ? (CacheLoaderException) e :
+ new CacheLoaderException("Problems loading key " + key, e);
+ throw cle;
+ } finally {
+ unlockBucket(b);
}
- return null;
}
- public Set<StoredEntry> loadAll() {
- return null; // TODO: Manik: Customise this generated block
+ public Set<StoredEntry> loadAll() throws CacheLoaderException {
+ log.trace("Loading all entries");
+ Set<StoredEntry> set = new HashSet<StoredEntry>();
+ try {
+ for (File f : root.listFiles()) {
+ Bucket b = null;
+ try {
+ b = lockAndGetBucket(f, false, false);
+ if (b != null) {
+ Set<Object> expiredOnBucket = new HashSet<Object>();
+ for (StoredEntry e : b.entries.values()) {
+ if (e.isExpired())
+ expiredOnBucket.add(e.getKey());
+ else
+ set.add(e);
+ }
+ for (Object expired : expiredOnBucket) b.removeEntry(expired);
+ saveBucket(b);
+ }
+ } finally {
+ unlockBucket(b);
+ }
+ }
+ } catch (Exception e) {
+ CacheLoaderException cle = (e instanceof CacheLoaderException) ? (CacheLoaderException) e :
+ new CacheLoaderException("Problems loading keys", e);
+ throw cle;
+ }
+ return set;
}
public Class<? extends CacheLoaderConfig> getConfigurationClass() {
@@ -91,67 +135,176 @@
root = new File(location);
if (!root.exists()) {
if (!root.mkdirs())
- throw new CacheException("Directory " + root.getAbsolutePath() + " does not exist and cannot be created!");
+ throw new ConfigurationException("Directory " + root.getAbsolutePath() + " does not exist and cannot be created!");
}
+
+ if (cfg.isPurgeSynchronously()) {
+ purgerService = new WithinThreadExecutor();
+ } else {
+ purgerService = Executors.newSingleThreadExecutor();
+ }
+
+ streamBufferSize = cfg.getStreamBufferSize();
+ int lockConcurrencyLevel = cfg.getLockConcurrencyLevel();
+ bucketLocks = new StripedLock(lockConcurrencyLevel);
+ lockTimeout = cfg.getLockAcquistionTimeout();
}
public void stop() {
+ purgerService.shutdownNow();
}
- public void store(StoredEntry ed) {
- // TODO: Manik: Customise this generated block
+ public void store(StoredEntry ed) throws CacheLoaderException {
+ if (ed == null) return;
+ if (ed.isExpired()) {
+ log.trace("Entry {0} is expired! Not doing anything.", ed);
+ return;
+ }
+
+ log.trace("Storing entry {0}", ed);
+
+ Bucket b = null;
+ try {
+ b = lockAndGetBucket(ed.getKey(), true, true);
+ b.addEntry(ed);
+ saveBucket(b);
+ } catch (Exception e) {
+ CacheLoaderException cle = (e instanceof CacheLoaderException) ? (CacheLoaderException) e :
+ new CacheLoaderException("Problems storing entry with key " + ed.getKey(), e);
+ throw cle;
+ } finally {
+ unlockBucket(b);
+ }
}
- public void store(InputStream inputStream) throws IOException, ClassNotFoundException {
- clear();
- // TODO: buffer streams!
- // TODO: close streams in a finally block, and close Object stream if an object stream was created
- ObjectInputStream ois =
- (inputStream instanceof ObjectInputStream) ? (ObjectInputStream) inputStream :
- new ObjectInputStream(inputStream);
- int numFiles = ois.readInt();
- for (int i = 0; i < numFiles; i++) {
- String fName = (String) ois.readObject();
- int numBytes = ois.readInt();
- FileOutputStream fos = new FileOutputStream(root.getAbsolutePath() + File.separator + fName);
- for (int bytes = 0; bytes < numBytes; bytes++) fos.write(ois.read());
- fos.close();
+ public void store(InputStream inputStream) throws CacheLoaderException {
+ ObjectInputStream ois = null;
+ try {
+ // first clear all local state
+ acquireGlobalLock(true);
+ clear();
+ ois = (inputStream instanceof ObjectInputStream) ? (ObjectInputStream) inputStream :
+ new ObjectInputStream(inputStream);
+ int numFiles = ois.readInt();
+ byte[] buffer = new byte[streamBufferSize];
+ int bytesRead, totalBytesRead = 0;
+ for (int i = 0; i < numFiles; i++) {
+ String fName = (String) ois.readObject();
+ int numBytes = ois.readInt();
+ FileOutputStream fos = new FileOutputStream(root.getAbsolutePath() + File.separator + fName);
+ BufferedOutputStream bos = new BufferedOutputStream(fos, streamBufferSize);
+
+ while (numBytes > totalBytesRead) {
+ bytesRead = ois.read(buffer, 0, streamBufferSize);
+ if (bytesRead == -1) break;
+ totalBytesRead += bytesRead;
+ bos.write(buffer, 0, bytesRead);
+ }
+ bos.flush();
+ bos.close();
+ fos.flush();
+ fos.close();
+ totalBytesRead = 0;
+ }
}
+ catch (Exception e) {
+ CacheLoaderException cle = (e instanceof CacheLoaderException) ? (CacheLoaderException) e :
+ new CacheLoaderException("Problems reading from stream", e);
+ throw cle;
+ }
+ finally {
+ releaseGlobalLock();
+ // we should close the stream we created!
+ if (inputStream != ois) safeClose(ois);
+ }
}
- public void load(OutputStream outputStream) throws IOException {
- // TODO: buffer streams!
- // TODO: close streams in a finally block, and close Object stream if an object stream was created
- ObjectOutputStream oos = (outputStream instanceof ObjectOutputStream) ? (ObjectOutputStream) outputStream :
- new ObjectOutputStream(outputStream);
- File[] files = root.listFiles();
- oos.writeInt(files.length);
- for (int i = 0; i < files.length; i++) {
- FileInputStream is = new FileInputStream(files[i]);
- int sz = is.available();
- oos.writeObject(files[i].getName());
- oos.writeInt(sz);
- for (int bytes = 0; bytes < sz; bytes++) oos.write(is.read());
- is.close();
+ public void load(OutputStream outputStream) throws CacheLoaderException {
+ ObjectOutputStream oos = null;
+ try {
+ acquireGlobalLock(true);
+ oos = (outputStream instanceof ObjectOutputStream) ? (ObjectOutputStream) outputStream :
+ new ObjectOutputStream(outputStream);
+
+ File[] files = root.listFiles();
+ oos.writeInt(files.length);
+ byte[] buffer = new byte[streamBufferSize];
+ int bytesRead, totalBytesRead = 0;
+ for (File file : files) {
+ FileInputStream is = new FileInputStream(file);
+ int sz = is.available();
+ BufferedInputStream bis = new BufferedInputStream(is);
+ oos.writeObject(file.getName());
+ oos.writeInt(sz);
+
+ while (sz > totalBytesRead) {
+ bytesRead = bis.read(buffer, 0, streamBufferSize);
+ if (bytesRead == -1) break;
+ totalBytesRead += bytesRead;
+ oos.write(buffer, 0, bytesRead);
+ }
+ bis.close();
+ is.close();
+ }
+ } catch (Exception ioe) {
+ throw new CacheLoaderException("Problems handling stream", ioe);
+ } finally {
+ releaseGlobalLock();
+ // we should close the stream we created!
+ if (oos != outputStream) safeClose(oos);
}
}
- public void clear() {
- for (File f : root.listFiles()) f.delete();
+ public void clear() throws CacheLoaderException {
+ log.trace("Clearing store");
+ try {
+ acquireGlobalLock(true);
+ for (File f : root.listFiles()) {
+ if (!f.delete()) log.warn("Had problems removing file {0}", f);
+ }
+ } catch (Exception e) {
+ throw new CacheLoaderException("Problems clearing cache store", e);
+ } finally {
+ releaseGlobalLock();
+ }
}
- public boolean remove(Object key) {
- return false; // TODO: Manik: Customise this generated block
+ public boolean remove(Object key) throws CacheLoaderException {
+ log.trace("Removing key {0}", key);
+ Bucket b = null;
+ try {
+ b = lockAndGetBucket(key, false, true);
+ if (b == null) {
+ return false;
+ } else {
+ boolean success = b.removeEntry(key);
+ if (success) saveBucket(b);
+ return success;
+ }
+ } catch (Exception e) {
+ CacheLoaderException cle = (e instanceof CacheLoaderException) ? (CacheLoaderException) e :
+ new CacheLoaderException("Problems removing key " + key, e);
+ throw cle;
+ } finally {
+ unlockBucket(b);
+ }
}
public void purgeExpired() {
- // TODO: Manik: Customise this generated block
+ purgerService.execute(new Runnable() {
+ public void run() {
+ try {
+ loadAll();
+ } catch (CacheLoaderException e) {
+ log.info("Problems encountered while purging expired", e);
+ }
+ }
+ });
}
- private String getBucketName(Object key) {
- int bucketNumber = index(hash(key));
- return bucketNumber + ".dat";
- }
+ // ------------------------------------------------------------------------------------------------------------------
+ // Buckets and bucket manipulators
+ // ------------------------------------------------------------------------------------------------------------------
private int hash(Object key) {
int h = key.hashCode();
@@ -163,24 +316,119 @@
return h & (NUM_BUCKETS - 1);
}
- private Map<Object, StoredEntry> deserialize(Object key, boolean createIfNeeded) {
- return null;
+ final Bucket lockAndGetBucket(Object key, boolean create, boolean exclusiveLock) throws IOException, ClassNotFoundException, TimeoutException, InterruptedException {
+ int bucketNumber = index(hash(key));
+ File bucket = new File(root, bucketNumber + ".bucket");
+ return lockAndGetBucket(bucket, create, exclusiveLock);
}
- private void serialize(Map<Object, StoredEntry> map) {
+ final Bucket lockAndGetBucket(File f, boolean create, boolean exclusiveLock) throws IOException, ClassNotFoundException, TimeoutException, InterruptedException {
+ Bucket b = null;
+ String bucketName = f.getName();
+ // first get a shared lock on the global lock to make sure no state tfr is going on
+ acquireGlobalLock(false);
+ bucketLocks.acquireLock(bucketName, exclusiveLock);
+ if (f.exists()) {
+ FileInputStream is = new FileInputStream(f);
+ ObjectInputStream ois = new ObjectInputStream(is);
+ b = (Bucket) ois.readObject();
+ ois.close();
+ is.close();
+ } else if (create) {
+ b = new Bucket();
+ b.entries = new HashMap<Object, StoredEntry>();
+ }
+ if (b == null) {
+ bucketLocks.releaseLock(bucketName); // don't bother holding locks for null buckets
+ releaseGlobalLock();
+ } else b.fileName = bucketName;
+
+ return b;
}
- private static class Bucket implements Externalizable {
+ final void unlockBucket(Bucket b) {
+ if (b != null) bucketLocks.releaseLock(b.fileName);
+ releaseGlobalLock();
+ }
+
+ final void acquireGlobalLock(boolean exclusive) throws TimeoutException, InterruptedException {
+ Lock l = exclusive ? globalLock.writeLock() : globalLock.readLock();
+ if (!l.tryLock(lockTimeout, TimeUnit.MILLISECONDS))
+ throw new TimeoutException("Timed out trying to acquire " + (exclusive ? "exclusive" : "shared") + " global lock after " + lockTimeout + " millis. Lock is " + l);
+ }
+
+ final void releaseGlobalLock() {
+ try {
+ globalLock.readLock().unlock();
+ } catch (IllegalMonitorStateException imse) {
+ // no op
+ }
+ }
+
+ final void saveBucket(Bucket b) throws IOException, CacheLoaderException {
+ if (b.modified) {
+ File f = new File(root, b.fileName);
+ if (f.exists()) {
+ if (!f.delete()) log.warn("Had problems removing file {0}", f);
+ }
+
+ if (!b.entries.isEmpty()) {
+ FileOutputStream fos = null;
+ ObjectOutputStream oos = null;
+ try {
+ fos = new FileOutputStream(f);
+ oos = new ObjectOutputStream(fos);
+ oos.writeObject(b);
+ oos.flush();
+ fos.flush();
+ } finally {
+ safeClose(oos);
+ safeClose(fos);
+ }
+ }
+
+ b.modified = false; // reset this
+ }
+ }
+
+ /**
+ * A bucket is where entries are stored.
+ */
+ public final static class Bucket implements Externalizable {
Map<Object, StoredEntry> entries;
- String bucketName;
+ transient String fileName;
+ transient boolean modified = false;
- public void writeExternal(ObjectOutput out) throws IOException {
- // TODO: Manik: Customise this generated block
+ final void addEntry(StoredEntry se) {
+ entries.put(se.getKey(), se);
+ modified = true;
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- // TODO: Manik: Customise this generated block
+ final boolean removeEntry(Object key) {
+ if (entries.remove(key) != null) {
+ modified = true;
+ return true;
+ }
+ return false;
}
+
+ final StoredEntry getEntry(Object key) {
+ return entries.get(key);
+ }
+
+ public final void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(entries.size());
+ for (StoredEntry se : entries.values()) out.writeObject(se);
+ }
+
+ public final void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ int sz = in.readInt();
+ entries = new HashMap<Object, StoredEntry>(sz);
+ for (int i = 0; i < sz; i++) {
+ StoredEntry se = (StoredEntry) in.readObject();
+ entries.put(se.getKey(), se);
+ }
+ }
}
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStoreConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStoreConfig.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStoreConfig.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -3,13 +3,29 @@
import org.horizon.loader.AbstractCacheLoaderConfig;
/**
- * Configures {@link org.horizon.loader.file.FileCacheStore}
+ * Configures {@link org.horizon.loader.file.FileCacheStore}. This allows you to tune a number of characteristics of
+ * the {@link FileCacheStore}.
+ * <p/>
+ * <ul> <li><tt>location</tt> - a location on disk where the store can write internal files. This defaults to
+ * <tt>Horizon-FileCacheStore</tt> in the current working directory.</li> <li><tt>purgeSynchronously</tt> - whether
+ * {@link org.horizon.loader.CacheStore#purgeExpired()} calls happen synchronously or not. By default, this is set to
+ * <tt>false</tt>.</li> <li><tt>streamBufferSize</tt> - when writing state to disk, a buffered stream is used. This
+ * parameter allows you to tune the buffer size. Larger buffers are usually faster but take up more (temporary) memory,
+ * resulting in more gc. By default, this is set to <tt>8192</tt>.</li> <li><tt>lockConcurrencyLevel</tt> - locking
+ * granularity is per file bucket. This setting defines the number of shared locks to use. The more locks you have,
+ * the better your concurrency will be, but more locks take up more memory. By default, this is set to
+ * <tt>2048</tt>.</li> <li><tt>lockAcquistionTimeout</tt> - the length of time, in milliseconds, to wait for locks
+ * before timing out and throwing an exception. By default, this is set to <tt>60000</tt>.</li> </ul>
*
* @author Manik Surtani
* @since 1.0
*/
public class FileCacheStoreConfig extends AbstractCacheLoaderConfig {
- String location;
+ String location = "Horizon-FileCacheStore";
+ private boolean purgeSynchronously = false;
+ private int streamBufferSize = 8192;
+ private int lockConcurrencyLevel = 2048;
+ private long lockAcquistionTimeout = 60000;
public FileCacheStoreConfig() {
setClassName(FileCacheStore.class.getName());
@@ -23,4 +39,40 @@
testImmutability("location");
this.location = location;
}
+
+ public boolean isPurgeSynchronously() {
+ return purgeSynchronously;
+ }
+
+ public void setPurgeSynchronously(boolean purgeSynchronously) {
+ testImmutability("purgeSynchronously");
+ this.purgeSynchronously = purgeSynchronously;
+ }
+
+ public int getStreamBufferSize() {
+ return streamBufferSize;
+ }
+
+ public void setStreamBufferSize(int streamBufferSize) {
+ testImmutability("steamBufferSize");
+ this.streamBufferSize = streamBufferSize;
+ }
+
+ public int getLockConcurrencyLevel() {
+ return lockConcurrencyLevel;
+ }
+
+ public void setLockConcurrencyLevel(int lockConcurrencyLevel) {
+ testImmutability("lockConcurrencyLevel");
+ this.lockConcurrencyLevel = lockConcurrencyLevel;
+ }
+
+ public long getLockAcquistionTimeout() {
+ return lockAcquistionTimeout;
+ }
+
+ public void setLockAcquistionTimeout(long lockAcquistionTimeout) {
+ testImmutability("lockAcquistionTimeout");
+ this.lockAcquistionTimeout = lockAcquistionTimeout;
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/JDBCCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -1,17 +1,14 @@
package org.horizon.loader.jdbc;
import org.horizon.Cache;
+import org.horizon.loader.AbstractCacheStore;
import org.horizon.loader.CacheLoaderConfig;
-import org.horizon.loader.CacheStore;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.StoredEntry;
import org.horizon.marshall.Marshaller;
-import javax.transaction.Transaction;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Collection;
-import java.util.List;
import java.util.Set;
/**
@@ -19,20 +16,16 @@
*
* @author Manik Surtani
*/
-public class JDBCCacheStore implements CacheStore {
+public class JDBCCacheStore extends AbstractCacheStore {
public void store(StoredEntry ed) {
// TODO: Manik: Customise this generated block
}
- public void storeAll(Collection ed) {
- // TODO: Manik: Customise this generated block
- }
-
public void store(InputStream inputStream) {
// TODO: Manik: Customise this generated block
}
- public void load(OutputStream outputStream) throws IOException {
+ public void load(OutputStream outputStream) {
// TODO: Manik: Customise this generated block
}
@@ -44,26 +37,10 @@
return false; // TODO: Manik: Customise this generated block
}
- public void removeAll(Set<Object> keys) {
- // TODO: Manik: Customise this generated block
- }
-
public void purgeExpired() {
// TODO: Manik: Customise this generated block
}
- public void commit(Transaction tx) {
- // TODO: Manik: Customise this generated block
- }
-
- public void rollback(Transaction tx) {
- // TODO: Manik: Customise this generated block
- }
-
- public void prepare(List list, Transaction tx, boolean isOnePhase) {
- // TODO: Manik: Customise this generated block
- }
-
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
// TODO: Manik: Customise this generated block
}
@@ -72,18 +49,10 @@
return null; // TODO: Manik: Customise this generated block
}
- public Set loadAll(Collection keys) {
+ public Set<StoredEntry> loadAll() throws CacheLoaderException {
return null; // TODO: Manik: Customise this generated block
}
- public Set loadAll() {
- return null; // TODO: Manik: Customise this generated block
- }
-
- public boolean containsKey(Object key) {
- return false; // TODO: Manik: Customise this generated block
- }
-
public Class<? extends CacheLoaderConfig> getConfigurationClass() {
return JDBCCacheStoreConfig.class;
}
Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -19,7 +19,9 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Random;
import java.util.Set;
@SuppressWarnings("unchecked")
@@ -37,7 +39,7 @@
}
@AfterMethod
- public void tearDown() {
+ public void tearDown() throws CacheLoaderException {
if (cs != null) {
cs.clear();
cs.stop();
@@ -63,7 +65,7 @@
}
- public void testLoadAndStore() throws InterruptedException {
+ public void testLoadAndStore() throws InterruptedException, CacheLoaderException {
assert !cs.containsKey("k");
StoredEntry se = new StoredEntry("k", "v", -1, -1);
cs.store(se);
@@ -93,7 +95,7 @@
assert !cs.containsKey("k");
}
- public void testOnePhaseCommit() {
+ public void testOnePhaseCommit() throws CacheLoaderException {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new Store(new StoredEntry("k1", "v1", -1, -1)));
mods.add(new Store(new StoredEntry("k2", "v2", -1, -1)));
@@ -118,7 +120,7 @@
assert cs.containsKey("k3");
}
- public void testTwoPhaseCommit() {
+ public void testTwoPhaseCommit() throws CacheLoaderException {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new Store(new StoredEntry("k1", "v1", -1, -1)));
mods.add(new Store(new StoredEntry("k2", "v2", -1, -1)));
@@ -155,7 +157,7 @@
assert cs.containsKey("k3");
}
- public void testRollback() {
+ public void testRollback() throws CacheLoaderException {
cs.store(new StoredEntry("old", "old", -1, -1));
@@ -197,7 +199,7 @@
assert cs.containsKey("old");
}
- public void testCommitAndRollbackWithoutPrepare() {
+ public void testCommitAndRollbackWithoutPrepare() throws CacheLoaderException {
cs.store(new StoredEntry("old", "old", -1, -1));
Transaction tx = EasyMock.createNiceMock(Transaction.class);
cs.commit(tx);
@@ -207,7 +209,7 @@
assert cs.containsKey("old");
}
- public void testPreload() {
+ public void testPreload() throws CacheLoaderException {
cs.store(new StoredEntry("k1", "v1", -1, -1));
cs.store(new StoredEntry("k2", "v2", -1, -1));
cs.store(new StoredEntry("k3", "v3", -1, -1));
@@ -223,12 +225,15 @@
assert expected.isEmpty();
}
- public void testPurgeExpired() throws InterruptedException {
+ public void testPurgeExpired() throws InterruptedException, Exception {
long now = System.currentTimeMillis();
long lifespan = 1000;
cs.store(new StoredEntry("k1", "v1", now, now + lifespan));
cs.store(new StoredEntry("k2", "v2", now, now + lifespan));
cs.store(new StoredEntry("k3", "v3", now, now + lifespan));
+ assert cs.containsKey("k1");
+ assert cs.containsKey("k2");
+ assert cs.containsKey("k3");
Thread.sleep(lifespan + 100);
cs.purgeExpired();
assert !cs.containsKey("k1");
@@ -236,7 +241,7 @@
assert !cs.containsKey("k3");
}
- public void testStreamingAPI() throws IOException, ClassNotFoundException {
+ public void testStreamingAPI() throws IOException, ClassNotFoundException, CacheLoaderException {
cs.store(new StoredEntry("k1", "v1", -1, -1));
cs.store(new StoredEntry("k2", "v2", -1, -1));
cs.store(new StoredEntry("k3", "v3", -1, -1));
@@ -264,4 +269,70 @@
CacheLoaderConfig clc = Util.getInstance(cfgClass);
assert clc.getClassName().equals(cs.getClass().getName()) : "Cache loader doesn't provide a proper configuration type that is capable of creating the loader!";
}
+
+ public void testConcurrency() throws Exception {
+ int numThreads = 5;
+ final int loops = 1000;
+ final String[] keys = new String[10];
+ final String[] values = new String[10];
+ for (int i = 0; i < 10; i++) keys[i] = "k" + i;
+ for (int i = 0; i < 10; i++) values[i] = "v" + i;
+
+
+ final Random r = new Random();
+ final List<Exception> exceptions = new LinkedList<Exception>();
+
+ final Runnable store = new Runnable() {
+ public void run() {
+ try {
+ int randomInt = r.nextInt(10);
+ cs.store(new StoredEntry(keys[randomInt], values[randomInt]));
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ }
+ };
+
+ final Runnable remove = new Runnable() {
+ public void run() {
+ try {
+ cs.remove(keys[r.nextInt(10)]);
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ }
+ };
+
+ final Runnable get = new Runnable() {
+ public void run() {
+ try {
+ int randomInt = r.nextInt(10);
+ StoredEntry se = cs.load(keys[randomInt]);
+ assert se == null || se.getValue().equals(values[randomInt]);
+ cs.loadAll();
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ }
+ };
+
+ Thread[] threads = new Thread[numThreads];
+
+ for (int i = 0; i < numThreads; i++) {
+ threads[i] = new Thread() {
+ public void run() {
+ for (int i = 0; i < loops; i++) {
+ store.run();
+ remove.run();
+ get.run();
+ }
+ }
+ };
+ }
+
+ for (Thread t : threads) t.start();
+ for (Thread t : threads) t.join();
+
+ if (!exceptions.isEmpty()) throw exceptions.get(0);
+ }
}
Modified: core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -53,25 +53,25 @@
}
@AfterMethod
- public void afterMethod() {
+ public void afterMethod() throws CacheLoaderException {
if (cache != null) cache.clear();
if (store != null) store.clear();
}
- private void assertInCacheAndStore(Object key, Object value) {
+ private void assertInCacheAndStore(Object key, Object value) throws CacheLoaderException {
assertInCacheAndStore(key, value, -1);
}
- private void assertInCacheAndStore(Object key, Object value, long lifespanMillis) {
+ private void assertInCacheAndStore(Object key, Object value, long lifespanMillis) throws CacheLoaderException {
assertInCacheAndStore(cache, store, key, value, lifespanMillis);
}
- private void assertInCacheAndStore(Cache cache, CacheStore store, Object key, Object value) {
+ private void assertInCacheAndStore(Cache cache, CacheStore store, Object key, Object value) throws CacheLoaderException {
assertInCacheAndStore(cache, store, key, value, -1);
}
- private void assertInCacheAndStore(Cache cache, CacheStore store, Object key, Object value, long lifespanMillis) {
+ private void assertInCacheAndStore(Cache cache, CacheStore store, Object key, Object value, long lifespanMillis) throws CacheLoaderException {
StoredEntry se = cache.getAdvancedCache().getDataContainer().createEntryForStorage(key);
testStoredEntry(se, value, lifespanMillis, "Cache", key);
se = store.load(key);
@@ -84,18 +84,18 @@
assert entry.getLifespan() == expectedLifespan : src + " expected lifespan for key " + key + " to be " + expectedLifespan + " but was " + entry.getLifespan() + ". Entry is " + entry;
}
- private void assertNotInCacheAndStore(Cache cache, CacheStore store, Object... keys) {
+ private void assertNotInCacheAndStore(Cache cache, CacheStore store, Object... keys) throws CacheLoaderException {
for (Object key : keys) {
assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Cache should not contain key " + key;
assert !store.containsKey(key) : "Store should not contain key " + key;
}
}
- private void assertNotInCacheAndStore(Object... keys) {
+ private void assertNotInCacheAndStore(Object... keys) throws CacheLoaderException {
assertNotInCacheAndStore(cache, store, keys);
}
- public void testStoreAndRetrieve() {
+ public void testStoreAndRetrieve() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2", "k3", "k4", "k5", "k6", "k7");
cache.put("k1", "v1");
@@ -144,7 +144,7 @@
assertNotInCacheAndStore("k1", "k2", "k3", "k4", "k5", "k6", "k7");
}
- public void testReplaceMethods() {
+ public void testReplaceMethods() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2", "k3", "k4");
cache.replace("k1", "v1-SHOULD-NOT-STORE");
@@ -179,7 +179,7 @@
}
- public void testLoading() {
+ public void testLoading() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2", "k3", "k4");
store.store(new StoredEntry("k1", "v1"));
store.store(new StoredEntry("k2", "v2"));
@@ -204,7 +204,7 @@
assertNotInCacheAndStore("k1", "k2", "k3", "k4");
}
- public void testPreloading() {
+ public void testPreloading() throws CacheLoaderException {
Configuration preloadingCfg = cfg.clone();
preloadingCfg.getCacheLoaderManagerConfig().setPreload(true);
((DummyInMemoryCacheStore.Cfg) preloadingCfg.getCacheLoaderManagerConfig().getFirstCacheLoaderConfig()).setStore("preloadingCache");
@@ -246,7 +246,7 @@
}
}
- public void testPurgeOnStartup() {
+ public void testPurgeOnStartup() throws CacheLoaderException {
Configuration purgingCfg = cfg.clone();
purgingCfg.getCacheLoaderManagerConfig().getFirstCacheLoaderConfig().setPurgeOnStartup(true);
((DummyInMemoryCacheStore.Cfg) purgingCfg.getCacheLoaderManagerConfig().getFirstCacheLoaderConfig()).setStore("purgingCache");
@@ -338,7 +338,7 @@
assertInCacheAndStore("k2", "v2", lifespan);
}
- public void testEvictAndRemove() {
+ public void testEvictAndRemove() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2");
cache.put("k1", "v1");
cache.put("k2", "v2", lifespan, MILLISECONDS);
Modified: core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -53,26 +53,26 @@
}
@AfterMethod
- public void afterMethod() {
+ public void afterMethod() throws CacheLoaderException {
if (cache != null) cache.clear();
if (store != null) store.clear();
}
- private void assertInCacheNotInStore(Object key, Object value) {
+ private void assertInCacheNotInStore(Object key, Object value) throws CacheLoaderException {
assertInCacheNotInStore(key, value, -1);
}
- private void assertInCacheNotInStore(Object key, Object value, long lifespanMillis) {
+ private void assertInCacheNotInStore(Object key, Object value, long lifespanMillis) throws CacheLoaderException {
StoredEntry se = cache.getAdvancedCache().getDataContainer().createEntryForStorage(key);
testStoredEntry(se, value, lifespanMillis, "Cache", key);
assert !store.containsKey(key) : "Key " + key + " should not be in store!";
}
- private void assertInStoreNotInCache(Object key, Object value) {
+ private void assertInStoreNotInCache(Object key, Object value) throws CacheLoaderException {
assertInStoreNotInCache(key, value, -1);
}
- private void assertInStoreNotInCache(Object key, Object value, long lifespanMillis) {
+ private void assertInStoreNotInCache(Object key, Object value, long lifespanMillis) throws CacheLoaderException {
StoredEntry se = store.load(key);
testStoredEntry(se, value, lifespanMillis, "Store", key);
assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Key " + key + " should not be in cache!";
@@ -85,14 +85,14 @@
assert entry.getLifespan() == expectedLifespan : src + " expected lifespan for key " + key + " to be " + expectedLifespan + " but was " + entry.getLifespan() + ". Entry is " + entry;
}
- private void assertNotInCacheAndStore(Object... keys) {
+ private void assertNotInCacheAndStore(Object... keys) throws CacheLoaderException {
for (Object key : keys) {
assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Cache should not contain key " + key;
assert !store.containsKey(key) : "Store should not contain key " + key;
}
}
- public void testPassivate() {
+ public void testPassivate() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2");
cache.put("k1", "v1");
@@ -122,7 +122,7 @@
assertInStoreNotInCache("k2", "v2", lifespan);
}
- public void testRemoveAndReplace() {
+ public void testRemoveAndReplace() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2");
cache.put("k1", "v1");
@@ -221,7 +221,7 @@
assertInStoreNotInCache("k2", "v2", lifespan);
}
- public void testPutMap() {
+ public void testPutMap() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2", "k3");
cache.put("k1", "v1");
cache.put("k2", "v2");
Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -3,6 +3,7 @@
import org.easymock.EasyMock;
import org.horizon.loader.BaseCacheStoreTest;
import org.horizon.loader.CacheLoaderConfig;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
import org.horizon.loader.dummy.DummyInMemoryCacheStore;
@@ -227,7 +228,7 @@
}
- public void testPropagatingStreams() throws IOException, ClassNotFoundException {
+ public void testPropagatingStreams() throws IOException, ClassNotFoundException, CacheLoaderException {
store2.store(new StoredEntry("k1", "v1"));
store2.store(new StoredEntry("k2", "v2", lifespan));
Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -1,6 +1,7 @@
package org.horizon.loader.decorators;
import static org.easymock.EasyMock.*;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
import org.testng.annotations.Test;
@@ -9,7 +10,7 @@
@Test(groups = "unit", testName = "loader.decorators.ReadOnlyCacheStoreTest")
public class ReadOnlyCacheStoreTest {
- public void testWriteMethods() {
+ public void testWriteMethods() throws CacheLoaderException {
CacheStore mock = createMock(CacheStore.class);
ReadOnlyStore store = new ReadOnlyStore(mock);
StoredEntry mockEntry = new StoredEntry();
Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -5,6 +5,7 @@
import org.horizon.Cache;
import org.horizon.config.CacheLoaderManagerConfig;
import org.horizon.config.Configuration;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheLoaderManager;
import org.horizon.loader.CacheStore;
import org.horizon.loader.StoredEntry;
@@ -98,7 +99,7 @@
return stores;
}
- private Object load(CacheStore cs, Object key) {
+ private Object load(CacheStore cs, Object key) throws CacheLoaderException {
StoredEntry se = cs.load(key);
return se == null ? null : se.getValue();
}
Modified: core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheStore.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -4,13 +4,13 @@
import org.horizon.loader.AbstractCacheLoaderConfig;
import org.horizon.loader.AbstractCacheStore;
import org.horizon.loader.CacheLoaderConfig;
+import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.StoredEntry;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
import org.horizon.marshall.Marshaller;
import org.horizon.marshall.ObjectStreamMarshaller;
-import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -36,24 +36,31 @@
}
@SuppressWarnings("unchecked")
- public void store(InputStream inputStream) throws IOException, ClassNotFoundException {
- ObjectInputStream ois = inputStream instanceof ObjectInputStream ? (ObjectInputStream) inputStream :
- new ObjectInputStream(inputStream);
+ public void store(InputStream inputStream) throws CacheLoaderException {
+ try {
+ ObjectInputStream ois = inputStream instanceof ObjectInputStream ? (ObjectInputStream) inputStream :
+ new ObjectInputStream(inputStream);
- int numEntries = (Integer) marshaller.objectFromObjectStream(ois);
- store.clear();
- for (int i = 0; i < numEntries; i++) {
- StoredEntry e = (StoredEntry) marshaller.objectFromObjectStream(ois);
- store.put(e.getKey(), e);
+ int numEntries = (Integer) marshaller.objectFromObjectStream(ois);
+ store.clear();
+ for (int i = 0; i < numEntries; i++) {
+ StoredEntry e = (StoredEntry) marshaller.objectFromObjectStream(ois);
+ store.put(e.getKey(), e);
+ }
+ } catch (Exception e) {
+ throw new CacheLoaderException(e);
}
}
- public void load(OutputStream outputStream) throws IOException {
-
- ObjectOutputStream oos = outputStream instanceof ObjectOutputStream ? (ObjectOutputStream) outputStream :
- new ObjectOutputStream(outputStream);
- marshaller.objectToObjectStream(store.size(), oos);
- for (StoredEntry se : store.values()) marshaller.objectToObjectStream(se, oos);
+ public void load(OutputStream outputStream) throws CacheLoaderException {
+ try {
+ ObjectOutputStream oos = outputStream instanceof ObjectOutputStream ? (ObjectOutputStream) outputStream :
+ new ObjectOutputStream(outputStream);
+ marshaller.objectToObjectStream(store.size(), oos);
+ for (StoredEntry se : store.values()) marshaller.objectToObjectStream(se, oos);
+ } catch (Exception e) {
+ throw new CacheLoaderException(e);
+ }
}
public void clear() {
Modified: core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java 2009-02-18 16:06:10 UTC (rev 7723)
+++ core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java 2009-02-18 17:13:31 UTC (rev 7724)
@@ -2,26 +2,78 @@
import org.horizon.loader.BaseCacheStoreTest;
import org.horizon.loader.CacheStore;
+import org.horizon.loader.StoredEntry;
import org.horizon.test.TestingUtil;
import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-@Test(groups = "unit", enabled = false, testName = "loader.file.FileCacheStoreTest")
+import java.io.File;
+
+@Test(groups = "unit", enabled = true, testName = "loader.file.FileCacheStoreTest")
public class FileCacheStoreTest extends BaseCacheStoreTest {
- private final String tmpDirectory = "__tempDir/" + getClass().getSimpleName();
+ private final String tmpDirectory = TestingUtil.TEST_FILES + File.separator + getClass().getSimpleName();
protected CacheStore createCacheStore() {
CacheStore cs = new FileCacheStore();
FileCacheStoreConfig cfg = new FileCacheStoreConfig();
cfg.setLocation(tmpDirectory);
+ cfg.setPurgeSynchronously(true); // for more accurate unit testing
cs.init(cfg, getCache(), getMarshaller());
cs.start();
return cs;
}
@AfterTest
+ @BeforeTest
public void removeTempDirectory() {
TestingUtil.recursiveFileRemove(tmpDirectory);
}
+
+ @Override
+ public void testPurgeExpired() throws Exception {
+ long now = System.currentTimeMillis();
+ long lifespan = 1000;
+ cs.store(new StoredEntry("k1", "v1", now, now + lifespan));
+ cs.store(new StoredEntry("k2", "v2", now, now + lifespan));
+ cs.store(new StoredEntry("k3", "v3", now, now + lifespan));
+ assert cs.containsKey("k1");
+ assert cs.containsKey("k2");
+ assert cs.containsKey("k3");
+ Thread.sleep(lifespan + 100);
+ cs.purgeExpired();
+ FileCacheStore fcs = (FileCacheStore) cs;
+ assert fcs.lockAndGetBucket("k1", false, false) == null;
+ assert fcs.lockAndGetBucket("k2", false, false) == null;
+ assert fcs.lockAndGetBucket("k3", false, false) == null;
+ System.out.println("Global lock: " + fcs.globalLock.readLock().toString());
+ }
+
+ public void testBucketRemoval() throws Exception {
+ FileCacheStore fcs = (FileCacheStore) cs;
+ FileCacheStore.Bucket b = null;
+ try {
+ b = fcs.lockAndGetBucket("test", true, false);
+ assert b != null;
+ assert !b.modified;
+ b.addEntry(new StoredEntry("test", "value"));
+ assert b.modified;
+
+ fcs.saveBucket(b);
+ assert !b.modified;
+ assert !b.entries.isEmpty();
+
+ assert new File(fcs.root, b.fileName).exists();
+
+ b.removeEntry("test");
+ assert b.entries.isEmpty();
+ assert b.modified;
+
+ fcs.saveBucket(b);
+ assert !new File(fcs.root, b.fileName).exists();
+ } finally {
+ fcs.unlockBucket(b);
+ }
+ }
}
15 years, 11 months
JBoss Cache SVN: r7723 - in core/trunk/src: main/java/org/jboss/cache/config and 7 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 11:06:10 -0500 (Wed, 18 Feb 2009)
New Revision: 7723
Added:
core/trunk/src/main/resources/config-samples/non-blocking-state-transfer.xml
core/trunk/src/main/resources/schema/jbosscache-config-3.1.xsd
core/trunk/src/main/resources/schema/jbosscache-registry-3.1.xsd
Removed:
core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
Modified:
core/trunk/src/main/docbook/userguide/en/modules/configuration.xml
core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/resources/config-samples/all.xml
core/trunk/src/main/resources/config-samples/buddy-replication.xml
core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
core/trunk/src/main/resources/config-samples/eviction-enabled.xml
core/trunk/src/main/resources/config-samples/external-jgroups-file.xml
core/trunk/src/main/resources/config-samples/invalidation-async.xml
core/trunk/src/main/resources/config-samples/local.xml
core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml
core/trunk/src/main/resources/config-samples/string-property-replaced.xml
core/trunk/src/main/resources/config-samples/total-replication.xml
core/trunk/src/main/resources/config2to3.xslt
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheConfigsTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
core/trunk/src/test/resources/configs/buddy-replication-cache.xml
core/trunk/src/test/resources/configs/clonable-config.xml
core/trunk/src/test/resources/configs/local-lru-eviction.xml
core/trunk/src/test/resources/configs/local-passivation.xml
core/trunk/src/test/resources/configs/local-tx.xml
core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
core/trunk/src/test/resources/configs/mux.xml
core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml
core/trunk/src/test/resources/configs/parser-test-async.xml
core/trunk/src/test/resources/configs/parser-test.xml
core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
core/trunk/src/test/resources/configs/replSync.xml
core/trunk/src/test/resources/configs/string-property-replaced.xml
core/trunk/src/test/resources/jbc3-registry-configs.xml
core/trunk/src/test/resources/unit-test-cache-service.xml
Log:
1. Added XML element for non-blocking state transfer
2. Updated XML parser
3. Updated schema from version 3.0 to version 3.1
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -51,7 +51,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
</jbosscache>
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -10,7 +10,7 @@
<programlisting role="XML"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!--
@@ -334,8 +334,8 @@
<row>
<entry><emphasis role="bold">xmlns</emphasis></entry>
<entry> - </entry>
- <entry>urn:jboss:jbosscache-core:config:3.0</entry>
- <entry>urn:jboss:jbosscache-core:config:3.0</entry>
+ <entry>urn:jboss:jbosscache-core:config:3.1</entry>
+ <entry>urn:jboss:jbosscache-core:config:3.1</entry>
<entry>Defines the XML namespace for all configuration entries.</entry>
</row>
<row>
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1149,6 +1149,7 @@
public void setNonBlockingStateTransfer(boolean nonBlockingStateTransfer)
{
+ testImmutability("nonBlockingStateTransfer");
this.nonBlockingStateTransfer = nonBlockingStateTransfer;
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -47,14 +47,14 @@
private static final JBossEntityResolver resolver = new JBossEntityResolver();
- public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
- public static final String JBOSSCACHE_REPO_NS = "urn:jboss:jbosscache-core:cache-repo:3.0";
+ public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.1";
+ public static final String JBOSSCACHE_REPO_NS = "urn:jboss:jbosscache-core:cache-repo:3.1";
static
{
// Globally register this namespace
- JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
- JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-registry-3.0.xsd");
+ JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.1.xsd");
+ JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-registry-3.1.xsd");
}
private static final Log log = LogFactory.getLog(RootElementBuilder.class);
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -206,11 +206,12 @@
private void configureStateRetrieval(Element element)
{
if (element == null) return; //we might not have this configured
- String fetchInMemoryState = getAttributeValue(element, "fetchInMemoryState");
- if (existsAttribute(fetchInMemoryState)) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
- String stateRetrievalTimeout = getAttributeValue(element, "timeout");
- if (existsAttribute(stateRetrievalTimeout)) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
-
+ String tmp = getAttributeValue(element, "fetchInMemoryState");
+ if (existsAttribute(tmp)) config.setFetchInMemoryState(getBoolean(tmp));
+ tmp = getAttributeValue(element, "timeout");
+ if (existsAttribute(tmp)) config.setStateRetrievalTimeout(getLong(tmp));
+ tmp = getAttributeValue(element, "nonBlocking");
+ if (existsAttribute(tmp)) config.setNonBlockingStateTransfer(getBoolean(tmp));
}
private void configureTransaction(Element element)
Modified: core/trunk/src/main/resources/config-samples/all.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/all.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/all.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!--
Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/main/resources/config-samples/eviction-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/main/resources/config-samples/external-jgroups-file.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/external-jgroups-file.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/external-jgroups-file.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/main/resources/config-samples/invalidation-async.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/invalidation-async.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/main/resources/config-samples/local.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/local.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/local.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- By not specifying the 'clustering' element, the cache runs in LOCAL mode. -->
<!-- Configure the TransactionManager -->
Modified: core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Copied: core/trunk/src/main/resources/config-samples/non-blocking-state-transfer.xml (from rev 7684, core/trunk/src/main/resources/config-samples/total-replication.xml)
===================================================================
--- core/trunk/src/main/resources/config-samples/non-blocking-state-transfer.xml (rev 0)
+++ core/trunk/src/main/resources/config-samples/non-blocking-state-transfer.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+ <clustering mode="replication">
+ <sync />
+ <stateRetrieval fetchInMemoryState="true" nonBlocking="true" timeout="60000" />
+ </clustering>
+</jbosscache>
Modified: core/trunk/src/main/resources/config-samples/string-property-replaced.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/string-property-replaced.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/string-property-replaced.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking lockAcquisitionTimeout="${test.property.LockAcquisitionTimeout:15000}"
nodeLockingScheme="${test.property.NodeLockingScheme:MVCC}"/>
Modified: core/trunk/src/main/resources/config-samples/total-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/total-replication.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config-samples/total-replication.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/main/resources/config2to3.xslt
===================================================================
--- core/trunk/src/main/resources/config2to3.xslt 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/config2to3.xslt 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns="urn:jboss:jbosscache-core:config:3.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8" omit-xml-declaration="no"/>
<xsl:template match="/">
<xsl:element name="jbosscache">
Deleted: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,261 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
- xmlns:tns="urn:jboss:jbosscache-core:config:3.0" targetNamespace="urn:jboss:jbosscache-core:config:3.0"
- xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
-
- <xs:element name="jbosscache" type="tns:cacheConfigurationType"/>
-
- <xs:complexType name="cacheConfigurationType">
- <xs:all>
- <xs:element name="locking" type="tns:lockingType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="transaction" type="tns:transactionType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="startup" type="tns:startupType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="shutdown" type="tns:shutdownType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="serialization" type="tns:serializationType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="jmxStatistics" type="tns:jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="listeners" type="tns:listenersType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="invocationBatching" type="tns:invocationBatchingType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="eviction" type="tns:evictionType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="loaders" type="tns:loadersType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="customInterceptors" type="tns:customInterceptorsType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="clustering" type="tns:clusteringType" minOccurs="0" maxOccurs="1"/>
- </xs:all>
- </xs:complexType>
-
- <xs:complexType name="clusteringType">
- <xs:all>
- <xs:element name="sync" type="tns:syncType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="async" type="tns:asyncType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="stateRetrieval" type="tns:stateRetrievalType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="buddy" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:all minOccurs="0">
- <xs:element name="dataGravitation" maxOccurs="1">
- <xs:complexType>
- <xs:attribute name="auto" type="tns:booleanType"/>
- <xs:attribute name="removeOnFind" type="tns:booleanType"/>
- <xs:attribute name="searchBackupTrees" type="tns:booleanType"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="locator" maxOccurs="1">
- <xs:complexType>
- <xs:all>
- <xs:element name="properties" type="xs:string" maxOccurs="1"/>
- </xs:all>
- <xs:attribute name="class" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="enabled" type="tns:booleanType"/>
- <xs:attribute name="poolName" type="xs:string"/>
- <xs:attribute name="communicationTimeout" type="xs:integer"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="jgroupsConfig" type="tns:jgroupsConfigType" minOccurs="0" maxOccurs="1"/>
- </xs:all>
- <xs:attribute name="mode">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern
- value="[Rr][Ee][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]|[Ii][Nn][Vv][Aa][Ll][Ii][Dd][Aa][Tt][Ii][Oo][Nn]|[Rr]|[Ii]|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="clusterName" type="xs:string" />
-
-
- </xs:complexType>
-
- <xs:complexType name="lockingType">
- <xs:attribute name="isolationLevel">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern
- value="[Ss][Ee][Rr][Ii][Aa][Ll][Ii][Zz][Aa][Bb][Ll][Ee]|[Rr][Ee][Pp][Ee][Aa][Tt][Aa][Bb][Ll][Ee]_[Rr][Ee][Aa][Dd]|[Rr][Ee][Aa][Dd]_[Cc][Oo][Mm][Mm][Ii][Tt][Tt][Ee][Dd]|[Nn][Oo][Nn][Ee]|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="lockParentForChildInsertRemove" type="tns:booleanType"/>
- <xs:attribute name="lockAcquisitionTimeout" type="tns:positiveInteger"/>
- <xs:attribute name="nodeLockingScheme">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern
- value="[Mm][Vv][Cc][Cc]|[Oo][Pp][Tt][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|[Pp][Ee][Ss][Ss][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="writeSkewCheck" type="tns:booleanType"/>
- <xs:attribute name="concurrencyLevel" type="xs:integer"/>
- </xs:complexType>
-
- <xs:complexType name="transactionType">
- <xs:attribute name="transactionManagerLookupClass" type="xs:string"/>
- <xs:attribute name="syncRollbackPhase" type="tns:booleanType"/>
- <xs:attribute name="syncCommitPhase" type="tns:booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="startupType">
- <xs:attribute name="regionsInactiveOnStartup" type="tns:booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="stateRetrievalType">
- <xs:attribute name="fetchInMemoryState" type="tns:booleanType"/>
- <xs:attribute name="timeout" type="tns:positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="shutdownType">
- <xs:attribute name="hookBehavior">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern
- value="[Dd][Ee][Ff][Aa][Uu][Ll][Tt]|[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|[Dd][Oo][Nn][Tt]_[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
-
- <xs:complexType name="serializationType">
- <xs:attribute name="objectInputStreamPoolSize" type="tns:positiveInteger"/>
- <xs:attribute name="objectOutputStreamPoolSize" type="tns:positiveInteger"/>
- <xs:attribute name="version" type="xs:string"/>
- <xs:attribute name="marshallerClass" type="xs:string"/>
- <xs:attribute name="useLazyDeserialization" type="tns:booleanType"/>
- <xs:attribute name="useRegionBasedMarshalling" type="tns:booleanType"/>
- </xs:complexType>
-
- <xs:simpleType name="booleanType">
- <xs:restriction base="xs:string">
- <xs:pattern value="\$\{.*\}|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="positiveInteger">
- <xs:restriction base="xs:string">
- <xs:pattern value="\$\{.*\}|\+?[0-9]*"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:complexType name="jmxStatisticsType">
- <xs:attribute name="enabled" type="tns:booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="listenersType">
- <xs:attribute name="asyncPoolSize" type="tns:positiveInteger"/>
- <xs:attribute name="asyncQueueSize" type="tns:positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="invocationBatchingType">
- <xs:attribute name="enabled" type="tns:booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="jgroupsConfigType">
- <xs:sequence>
- <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="configFile" type="xs:string"/>
- <xs:attribute name="multiplexerStack" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="syncType">
- <xs:attribute name="replTimeout" type="tns:positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="asyncType">
- <xs:attribute name="useReplQueue" type="tns:booleanType"/>
- <xs:attribute name="replQueueInterval" type="tns:positiveInteger"/>
- <xs:attribute name="replQueueMaxElements" type="tns:positiveInteger"/>
- <xs:attribute name="serializationExecutorPoolSize" type="tns:positiveInteger"/>
- <xs:attribute name="serializationExecutorQueueSize" type="tns:positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="evictionType">
- <xs:sequence>
- <xs:element name="default" type="tns:evictionRegionType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="tns:evictionRegionType"/>
- </xs:sequence>
- <xs:attribute name="wakeUpInterval" type="tns:positiveInteger" use="required"/>
- </xs:complexType>
-
- <xs:complexType name="evictionRegionType">
- <xs:sequence>
- <xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="tns:propertyType"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="algorithmClass" type="xs:string"/>
- <xs:attribute name="actionPolicyClass" type="xs:string"/>
- <xs:attribute name="eventQueueSize" type="tns:positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="loadersType">
- <xs:sequence>
- <xs:element name="preload" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="node" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="fqn" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="loader" maxOccurs="unbounded">
- <xs:complexType>
- <xs:all>
- <xs:element name="properties"/>
- <xs:element name="singletonStore" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:all>
- <xs:element name="properties" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:all>
- <xs:attribute name="enabled" type="tns:booleanType"/>
- <xs:attribute name="class" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="async" type="tns:booleanType"/>
- <xs:attribute name="fetchPersistentState" type="tns:booleanType"/>
- <xs:attribute name="ignoreModifications" type="tns:booleanType"/>
- <xs:attribute name="purgeOnStartup" type="tns:booleanType"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="passivation" type="tns:booleanType"/>
- <xs:attribute name="shared" type="tns:booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="customInterceptorsType">
- <xs:sequence>
- <xs:element name="interceptor" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="property" maxOccurs="unbounded" type="tns:propertyType" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="position">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern value="[Ff][Ii][Rr][Ss][Tt]|[Ll][Aa][Ss][Tt]"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="before" type="xs:string"/>
- <xs:attribute name="after" type="xs:string"/>
- <xs:attribute name="index" type="tns:positiveInteger"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="propertyType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="value" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-</xs:schema>
-
Copied: core/trunk/src/main/resources/schema/jbosscache-config-3.1.xsd (from rev 7684, core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd)
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.1.xsd (rev 0)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.1.xsd 2009-02-18 16:06:10 UTC (rev 7723)
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
+ xmlns:tns="urn:jboss:jbosscache-core:config:3.1" targetNamespace="urn:jboss:jbosscache-core:config:3.1"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
+
+ <xs:element name="jbosscache" type="tns:cacheConfigurationType"/>
+
+ <xs:complexType name="cacheConfigurationType">
+ <xs:all>
+ <xs:element name="locking" type="tns:lockingType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="transaction" type="tns:transactionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="startup" type="tns:startupType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="shutdown" type="tns:shutdownType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="serialization" type="tns:serializationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="jmxStatistics" type="tns:jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="listeners" type="tns:listenersType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="invocationBatching" type="tns:invocationBatchingType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="eviction" type="tns:evictionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="loaders" type="tns:loadersType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="customInterceptors" type="tns:customInterceptorsType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="clustering" type="tns:clusteringType" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ </xs:complexType>
+
+ <xs:complexType name="clusteringType">
+ <xs:all>
+ <xs:element name="sync" type="tns:syncType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="async" type="tns:asyncType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="stateRetrieval" type="tns:stateRetrievalType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="buddy" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:all minOccurs="0">
+ <xs:element name="dataGravitation" maxOccurs="1">
+ <xs:complexType>
+ <xs:attribute name="auto" type="tns:booleanType"/>
+ <xs:attribute name="removeOnFind" type="tns:booleanType"/>
+ <xs:attribute name="searchBackupTrees" type="tns:booleanType"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="locator" maxOccurs="1">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties" type="xs:string" maxOccurs="1"/>
+ </xs:all>
+ <xs:attribute name="class" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ <xs:attribute name="poolName" type="xs:string"/>
+ <xs:attribute name="communicationTimeout" type="xs:integer"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="jgroupsConfig" type="tns:jgroupsConfigType" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ <xs:attribute name="mode">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern
+ value="[Rr][Ee][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]|[Ii][Nn][Vv][Aa][Ll][Ii][Dd][Aa][Tt][Ii][Oo][Nn]|[Rr]|[Ii]|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="clusterName" type="xs:string" />
+
+
+ </xs:complexType>
+
+ <xs:complexType name="lockingType">
+ <xs:attribute name="isolationLevel">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern
+ value="[Ss][Ee][Rr][Ii][Aa][Ll][Ii][Zz][Aa][Bb][Ll][Ee]|[Rr][Ee][Pp][Ee][Aa][Tt][Aa][Bb][Ll][Ee]_[Rr][Ee][Aa][Dd]|[Rr][Ee][Aa][Dd]_[Cc][Oo][Mm][Mm][Ii][Tt][Tt][Ee][Dd]|[Nn][Oo][Nn][Ee]|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="lockParentForChildInsertRemove" type="tns:booleanType"/>
+ <xs:attribute name="lockAcquisitionTimeout" type="tns:positiveInteger"/>
+ <xs:attribute name="nodeLockingScheme">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern
+ value="[Mm][Vv][Cc][Cc]|[Oo][Pp][Tt][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|[Pp][Ee][Ss][Ss][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="writeSkewCheck" type="tns:booleanType"/>
+ <xs:attribute name="concurrencyLevel" type="xs:integer"/>
+ </xs:complexType>
+
+ <xs:complexType name="transactionType">
+ <xs:attribute name="transactionManagerLookupClass" type="xs:string"/>
+ <xs:attribute name="syncRollbackPhase" type="tns:booleanType"/>
+ <xs:attribute name="syncCommitPhase" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="startupType">
+ <xs:attribute name="regionsInactiveOnStartup" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="stateRetrievalType">
+ <xs:attribute name="fetchInMemoryState" type="tns:booleanType"/>
+ <xs:attribute name="timeout" type="tns:positiveInteger"/>
+ <xs:attribute name="nonBlocking" type="tns:booleanType" />
+ </xs:complexType>
+
+ <xs:complexType name="shutdownType">
+ <xs:attribute name="hookBehavior">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern
+ value="[Dd][Ee][Ff][Aa][Uu][Ll][Tt]|[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|[Dd][Oo][Nn][Tt]_[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="serializationType">
+ <xs:attribute name="objectInputStreamPoolSize" type="tns:positiveInteger"/>
+ <xs:attribute name="objectOutputStreamPoolSize" type="tns:positiveInteger"/>
+ <xs:attribute name="version" type="xs:string"/>
+ <xs:attribute name="marshallerClass" type="xs:string"/>
+ <xs:attribute name="useLazyDeserialization" type="tns:booleanType"/>
+ <xs:attribute name="useRegionBasedMarshalling" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:simpleType name="booleanType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="\$\{.*\}|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="positiveInteger">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="\$\{.*\}|\+?[0-9]*"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="jmxStatisticsType">
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="listenersType">
+ <xs:attribute name="asyncPoolSize" type="tns:positiveInteger"/>
+ <xs:attribute name="asyncQueueSize" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="invocationBatchingType">
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="jgroupsConfigType">
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="configFile" type="xs:string"/>
+ <xs:attribute name="multiplexerStack" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="syncType">
+ <xs:attribute name="replTimeout" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="asyncType">
+ <xs:attribute name="useReplQueue" type="tns:booleanType"/>
+ <xs:attribute name="replQueueInterval" type="tns:positiveInteger"/>
+ <xs:attribute name="replQueueMaxElements" type="tns:positiveInteger"/>
+ <xs:attribute name="serializationExecutorPoolSize" type="tns:positiveInteger"/>
+ <xs:attribute name="serializationExecutorQueueSize" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="evictionType">
+ <xs:sequence>
+ <xs:element name="default" type="tns:evictionRegionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="tns:evictionRegionType"/>
+ </xs:sequence>
+ <xs:attribute name="wakeUpInterval" type="tns:positiveInteger" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="evictionRegionType">
+ <xs:sequence>
+ <xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="tns:propertyType"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="algorithmClass" type="xs:string"/>
+ <xs:attribute name="actionPolicyClass" type="xs:string"/>
+ <xs:attribute name="eventQueueSize" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="loadersType">
+ <xs:sequence>
+ <xs:element name="preload" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="node" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="fqn" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="loader" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties"/>
+ <xs:element name="singletonStore" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ <xs:attribute name="class" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="async" type="tns:booleanType"/>
+ <xs:attribute name="fetchPersistentState" type="tns:booleanType"/>
+ <xs:attribute name="ignoreModifications" type="tns:booleanType"/>
+ <xs:attribute name="purgeOnStartup" type="tns:booleanType"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="passivation" type="tns:booleanType"/>
+ <xs:attribute name="shared" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="customInterceptorsType">
+ <xs:sequence>
+ <xs:element name="interceptor" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="property" maxOccurs="unbounded" type="tns:propertyType" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="position">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[Ff][Ii][Rr][Ss][Tt]|[Ll][Aa][Ss][Tt]"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="before" type="xs:string"/>
+ <xs:attribute name="after" type="xs:string"/>
+ <xs:attribute name="index" type="tns:positiveInteger"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="propertyType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="value" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+</xs:schema>
+
Property changes on: core/trunk/src/main/resources/schema/jbosscache-config-3.1.xsd
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
- xmlns:tns="urn:jboss:jbosscache-core:config:3.0"
- xmlns:repo="urn:jboss:jbosscache-core:cache-repo:3.0"
- targetNamespace="urn:jboss:jbosscache-core:cache-repo:3.0"
- xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
- <xs:import schemaLocation="jbosscache-config-3.0.xsd" namespace="urn:jboss:jbosscache-core:config:3.0"/>
-
- <xs:element name="cache-configs">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="cache-config" type="repo:cacheConfig" minOccurs="1" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:complexType name="cacheConfig">
- <xs:complexContent>
- <xs:extension base="tns:cacheConfigurationType" xml:space="default">
- <xs:attribute name="name" type="xs:string"/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-</xs:schema>
Copied: core/trunk/src/main/resources/schema/jbosscache-registry-3.1.xsd (from rev 7684, core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd)
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-registry-3.1.xsd (rev 0)
+++ core/trunk/src/main/resources/schema/jbosscache-registry-3.1.xsd 2009-02-18 16:06:10 UTC (rev 7723)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
+ xmlns:tns="urn:jboss:jbosscache-core:config:3.1"
+ xmlns:repo="urn:jboss:jbosscache-core:cache-repo:3.1"
+ targetNamespace="urn:jboss:jbosscache-core:cache-repo:3.1"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
+ <xs:import schemaLocation="jbosscache-config-3.1.xsd" namespace="urn:jboss:jbosscache-core:config:3.1"/>
+
+ <xs:element name="cache-configs">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="cache-config" type="repo:cacheConfig" minOccurs="1" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="cacheConfig">
+ <xs:complexContent>
+ <xs:extension base="tns:cacheConfigurationType" xml:space="default">
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+</xs:schema>
Property changes on: core/trunk/src/main/resources/schema/jbosscache-registry-3.1.xsd
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheConfigsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheConfigsTest.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheConfigsTest.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -23,7 +23,7 @@
String xml = "<cache-configs>\n" +
" <cache-config name=\"A\">\n" +
" <jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- " xmlns=\"urn:jboss:jbosscache-core:config:3.0\">\n" +
+ " xmlns=\"urn:jboss:jbosscache-core:config:3.1\">\n" +
" <locking isolationLevel=\"REPEATABLE_READ\" lockAcquisitionTimeout=\"15000\"/>\n" +
" <transaction transactionManagerLookupClass=\"org.jboss.cache.transaction.GenericTransactionManagerLookup\"/>\n" +
" <clustering><stateRetrieval timeout=\"20000\"/></clustering>\n" +
@@ -32,7 +32,7 @@
"\n" +
" <cache-config name=\"B\">\n" +
" <jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- " xmlns=\"urn:jboss:jbosscache-core:config:3.0\">\n" +
+ " xmlns=\"urn:jboss:jbosscache-core:config:3.1\">\n" +
" <locking isolationLevel=\"READ_COMMITTED\" lockAcquisitionTimeout=\"15000\"/>\n" +
" <transaction transactionManagerLookupClass=\"org.jboss.cache.transaction.GenericTransactionManagerLookup\"/>\n" +
" <clustering><stateRetrieval timeout=\"20000\"/></clustering>\n" +
@@ -41,7 +41,7 @@
"\n" +
" <cache-config name=\"C\">\n" +
" <jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- " xmlns=\"urn:jboss:jbosscache-core:config:3.0\">\n" +
+ " xmlns=\"urn:jboss:jbosscache-core:config:3.1\">\n" +
" <locking isolationLevel=\"READ_COMMITTED\" lockAcquisitionTimeout=\"100\"/>\n" +
" <clustering><stateRetrieval timeout=\"100\"/></clustering>\n" +
" </jbosscache>\n" +
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -47,7 +47,7 @@
public class SampleConfigFilesCorrectnessTest
{
public static final String CONFIG_ROOT = "src/main/resources/config-samples";
- public static final String XSD_FILE = "src/main/resources/jbosscache-config-3.0.xsd";
+ public static final String XSD_FILE = "src/main/resources/jbosscache-config-3.1.xsd";
private InMemoryAppender appender;
private Level oldLevel;
@@ -116,6 +116,7 @@
String[] TOLERABLE_WARNINGS =
{
"DummyTransactionManager",
+ "not recommended for sync replication",
"could not bind to /", //this is a binding excpetion that might appear on some linuxes...
"failed to join /" //this might appear on linux + jdk6
};
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -103,6 +103,12 @@
assert syncConfig.getStateRetrievalTimeout() == 15124;
}
+ public void testNonBlockingStateTransfer()
+ {
+ assert syncConfig.isNonBlockingStateTransfer();
+ assert !asyncConfig.isNonBlockingStateTransfer();
+ }
+
public void testSyncReplTimeout()
{
assert syncConfig.getSyncReplTimeout() == 15421;
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2009-02-18 16:06:10 UTC (rev 7723)
@@ -43,7 +43,7 @@
public void testSimpleFile()
{
ExceptionCountingErrorHandler handler = new ExceptionCountingErrorHandler();
- System.setProperty("jbosscache.config.schemaLocation", "src/main/resources/jbosscache-config-3.0.xsd");
+ System.setProperty("jbosscache.config.schemaLocation", "src/main/resources/jbosscache-config-3.1.xsd");
XmlConfigurationParser parser = new XmlConfigurationParser(handler);
for (String file : testFiles)
{
Modified: core/trunk/src/test/resources/configs/buddy-replication-cache.xml
===================================================================
--- core/trunk/src/test/resources/configs/buddy-replication-cache.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/buddy-replication-cache.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<clustering clusterName="JBossCache-Cluster">
Modified: core/trunk/src/test/resources/configs/clonable-config.xml
===================================================================
--- core/trunk/src/test/resources/configs/clonable-config.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/clonable-config.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="SERIALIZABLE" lockAcquisitionTimeout="1" nodeLockingScheme="optimistic"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<clustering clusterName="CloneCluster">
Modified: core/trunk/src/test/resources/configs/local-lru-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-lru-eviction.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/local-lru-eviction.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/local-passivation.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-passivation.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/local-passivation.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/local-tx.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-tx.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/local-tx.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/mux.xml
===================================================================
--- core/trunk/src/test/resources/configs/mux.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/mux.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<clustering>
<stateRetrieval timeout="20000"/>
Modified: core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml
===================================================================
--- core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.1">
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<clustering>
<stateRetrieval fetchInMemoryState="false"/>
Modified: core/trunk/src/test/resources/configs/parser-test-async.xml
===================================================================
--- core/trunk/src/test/resources/configs/parser-test-async.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/parser-test-async.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -3,7 +3,7 @@
<!-- file used for functional test of the xml parser -->
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
@@ -25,7 +25,7 @@
<clustering mode="replication" clusterName="JBossCache-cluster">
<async useReplQueue="false" serializationExecutorPoolSize="250" serializationExecutorQueueSize="5000000"/>
- <stateRetrieval timeout="15124" fetchInMemoryState="true"/>
+ <stateRetrieval timeout="15124" fetchInMemoryState="true" nonBlocking="false"/>
<buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
<dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
<locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
Modified: core/trunk/src/test/resources/configs/parser-test.xml
===================================================================
--- core/trunk/src/test/resources/configs/parser-test.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/parser-test.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -3,7 +3,7 @@
<!-- file used for functional test of the xml parser -->
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
<!-- perCache -> differrent EntryFactory-->
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
@@ -28,7 +28,7 @@
<!-- per Cache -->
<clustering mode="replication" clusterName="JBossCache-cluster">
- <stateRetrieval timeout="15124" fetchInMemoryState="true"/>
+ <stateRetrieval timeout="15124" fetchInMemoryState="true" nonBlocking="true"/>
<buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
<dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
<locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
Modified: core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<clustering clusterName="JBossCache-Cluster123" />
<eviction wakeUpInterval="5000">
Modified: core/trunk/src/test/resources/configs/replSync.xml
===================================================================
--- core/trunk/src/test/resources/configs/replSync.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/replSync.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="true"/>
Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml
===================================================================
--- core/trunk/src/test/resources/configs/string-property-replaced.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking lockAcquisitionTimeout="${test.property.LockAcquisitionTimeout:15000}"
nodeLockingScheme="${test.property.NodeLockingScheme:MVCC}"/>
Modified: core/trunk/src/test/resources/jbc3-registry-configs.xml
===================================================================
--- core/trunk/src/test/resources/jbc3-registry-configs.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/jbc3-registry-configs.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.0">
+<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.1" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.1">
<!--
Various JBoss Cache configurations, suitable for different caching
Modified: core/trunk/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/unit-test-cache-service.xml 2009-02-18 12:05:26 UTC (rev 7722)
+++ core/trunk/src/test/resources/unit-test-cache-service.xml 2009-02-18 16:06:10 UTC (rev 7723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.1">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="false"/>
15 years, 11 months
JBoss Cache SVN: r7722 - in core/branches/3.0.X/src: test/java/org/jboss/cache/loader/testloaders and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 07:05:26 -0500 (Wed, 18 Feb 2009)
New Revision: 7722
Modified:
core/branches/3.0.X/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/branches/3.0.X/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java
core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java
core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java
core/branches/3.0.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
Log:
JBCACHE-1479 excessive cache loading and deadlocks
Modified: core/branches/3.0.X/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/branches/3.0.X/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2009-02-18 10:33:00 UTC (rev 7721)
+++ core/branches/3.0.X/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2009-02-18 12:05:26 UTC (rev 7722)
@@ -250,6 +250,7 @@
n = nodeFactory.createWrappedNode(in, parent.getDelegationTarget());
n.setCreated(true);
+ n.setDataLoaded(true); // created here so we are loading it here
context.putLookedUpNode(fqn, n);
n.markForUpdate(dataContainer, writeSkewCheck);
}
Modified: core/branches/3.0.X/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java
===================================================================
--- core/branches/3.0.X/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java 2009-02-18 10:33:00 UTC (rev 7721)
+++ core/branches/3.0.X/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java 2009-02-18 12:05:26 UTC (rev 7722)
@@ -291,4 +291,12 @@
{
nodes.clear();
}
+
+ public static class Cfg extends IndividualCacheLoaderConfig
+ {
+ public Cfg()
+ {
+ setClassName(DummyInMemoryCacheLoader.class.getName());
+ }
+ }
}
Modified: core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java
===================================================================
--- core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java 2009-02-18 10:33:00 UTC (rev 7721)
+++ core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java 2009-02-18 12:05:26 UTC (rev 7722)
@@ -44,8 +44,6 @@
assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + AUSTRIA, cache.get(AUSTRIA, AREA));
- load++;
-
// verify statistics after retrieving entries - misses should still be same since nodes were already loaded
assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
@@ -104,7 +102,6 @@
// add two attributes - this should cause two stores
stores += 2;
- load++;
cache.put(POLAND, CAPITAL, "Warsaw");
cache.put(POLAND, CURRENCY, "Zloty");
assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
Modified: core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java
===================================================================
--- core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java 2009-02-18 10:33:00 UTC (rev 7721)
+++ core/branches/3.0.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java 2009-02-18 12:05:26 UTC (rev 7722)
@@ -52,8 +52,6 @@
assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + AUSTRIA, cache.get(AUSTRIA, AREA));
- miss++;
-
// verify statistics after retrieving entries - no change since nodes were already loaded
assertEquals("CacheLoaderLoads count error: ", 0, act.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, act.getCacheLoaderMisses());
@@ -82,7 +80,7 @@
assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + AUSTRIA, cache.get(AUSTRIA, CURRENCY));
// verify statistics after retrieving evicted entry - loads and activations should now increment by 1
- activations++;
+ activations+= 3;
assertEquals("CacheLoaderLoads count error: ", 1, act.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, act.getCacheLoaderMisses());
assertEquals("Activations count error: ", activations, act.getActivations());
@@ -113,7 +111,7 @@
cache.put(POLAND, new HashMap<String, Object>());
cache.put(POLAND, CAPITAL, "Warsaw");
cache.put(POLAND, CURRENCY, "Zloty");
- miss += 3;
+ miss ++;
assertEquals("CacheLoaderLoads count error: ", 1, act.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, act.getCacheLoaderMisses());
assertEquals("Activations count error: ", activations, act.getActivations());
@@ -127,7 +125,7 @@
assertEquals("Passivations count error: ", 2, pass.getPassivations());
// retrieve a valid attribute - this will cause an activation and a load
- activations++;
+ activations+=3;
assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + POLAND, cache.get(POLAND, CURRENCY));
assertEquals("CacheLoaderLoads count error: ", 2, act.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, act.getCacheLoaderMisses());
@@ -142,7 +140,7 @@
assertEquals("Passivations count error: ", 3, pass.getPassivations());
// retrieve an invalid attribute - this will cause an activation and a load
- activations++;
+ activations+=3;
assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + POLAND, cache.get(POLAND, AREA));
assertEquals("CacheLoaderLoads count error: ", 3, act.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, act.getCacheLoaderMisses());
Modified: core/branches/3.0.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/branches/3.0.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2009-02-18 10:33:00 UTC (rev 7721)
+++ core/branches/3.0.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2009-02-18 12:05:26 UTC (rev 7722)
@@ -655,7 +655,7 @@
assertTrue(loader.exists(Fqn.fromString("/first/second")));
assert (exists("/first"));
String val = (String) cache.get("/first/second", "key1");
- assertTrue(loader.exists(Fqn.fromString("/first/second")));
+ assertFalse(loader.exists(Fqn.fromString("/first/second")));
assertEquals("val1", val);
String val2 = (String) cache.get("/first/second/third", "key2");// activate node
assertFalse(loader.exists(Fqn.fromString("/first/second/third")));
15 years, 11 months
JBoss Cache SVN: r7721 - in core/branches/3.0.X: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 05:33:00 -0500 (Wed, 18 Feb 2009)
New Revision: 7721
Modified:
core/branches/3.0.X/pom.xml
core/branches/3.0.X/src/main/java/org/jboss/cache/Version.java
Log:
UPdated version
Modified: core/branches/3.0.X/pom.xml
===================================================================
--- core/branches/3.0.X/pom.xml 2009-02-18 10:30:46 UTC (rev 7720)
+++ core/branches/3.0.X/pom.xml 2009-02-18 10:33:00 UTC (rev 7721)
@@ -4,7 +4,7 @@
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>
<properties>
- <jbosscache-core-version>3.0.3.CR1</jbosscache-core-version>
+ <jbosscache-core-version>3.0.3-SNAPSHOT</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
Modified: core/branches/3.0.X/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/branches/3.0.X/src/main/java/org/jboss/cache/Version.java 2009-02-18 10:30:46 UTC (rev 7720)
+++ core/branches/3.0.X/src/main/java/org/jboss/cache/Version.java 2009-02-18 10:33:00 UTC (rev 7721)
@@ -31,10 +31,10 @@
*/
@Immutable
public class Version {
- public static final String version = "3.0.3.CR1";
+ public static final String version = "3.0.3-SNAPSHOT";
public static final String codename = "Naga";
//public static final String cvs = "$Id$";
- static final byte[] version_id = {'0', '3', '0', '3', 'C', 'R', '1'};
+ static final byte[] version_id = {'0', '3', '0', '3', 'S'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
15 years, 11 months
JBoss Cache SVN: r7720 - core/branches.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-18 05:30:46 -0500 (Wed, 18 Feb 2009)
New Revision: 7720
Added:
core/branches/3.0.X/
Log:
Created branch off tag
Copied: core/branches/3.0.X (from rev 7719, core/tags/3.0.3.CR1)
15 years, 11 months