[infinispan-commits] Infinispan SVN: r1850 - in trunk: cachestore and 18 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue May 25 17:24:53 EDT 2010


Author: mircea.markus
Date: 2010-05-25 17:24:52 -0400 (Tue, 25 May 2010)
New Revision: 1850

Added:
   trunk/cachestore/remote/
   trunk/cachestore/remote/src/
   trunk/cachestore/remote/src/main/
   trunk/cachestore/remote/src/main/java/
   trunk/cachestore/remote/src/main/java/org/
   trunk/cachestore/remote/src/main/java/org/infinispan/
   trunk/cachestore/remote/src/main/java/org/infinispan/loaders/
   trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/
   trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java
   trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java
   trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStoreConfig.java
   trunk/cachestore/remote/src/test/
   trunk/cachestore/remote/src/test/java/
   trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/
   trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreConfigTest.java
   trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreFunctionalTest.java
   trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreTest.java
   trunk/cachestore/remote/src/test/resources/
   trunk/cachestore/remote/src/test/resources/hotrod-client.properties
   trunk/cachestore/remote/src/test/resources/log4j.xml
   trunk/cachestore/remote/src/test/resources/remote-cl-config.xml
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java
Removed:
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/HotRodMarshaller.java
Modified:
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/exceptions/HotRodTimeoutException.java
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java
   trunk/core/src/main/java/org/infinispan/affinity/KeyAffinityServiceFactory.java
   trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java
   trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java
   trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java
   trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
   trunk/pom.xml
Log:
ISPN-27


Added: trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java
===================================================================
--- trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java	                        (rev 0)
+++ trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,40 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.client.hotrod.HotRodMarshaller;
+import org.infinispan.client.hotrod.exceptions.HotRodClientException;
+import org.infinispan.marshall.Marshaller;
+
+import java.io.IOException;
+
+/**
+ * Marshaller used internally by the remote cache store.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+public class InternalCacheEntryMarshaller implements HotRodMarshaller {
+
+   public final Marshaller marshaller;
+
+   public InternalCacheEntryMarshaller(Marshaller marshaller) {
+      this.marshaller = marshaller;
+   }
+
+   @Override
+   public byte[] marshallObject(Object toMarshall) {
+      try {
+         return marshaller.objectToByteBuffer(toMarshall);
+      } catch (IOException e) {
+         throw new HotRodClientException(e);
+      }
+   }
+
+   @Override
+   public Object readObject(byte[] bytes) {
+      try {
+         return marshaller.objectFromByteBuffer(bytes);
+      } catch (Exception e) {
+         throw new HotRodClientException(e);
+      }
+   }
+}

Added: trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java
===================================================================
--- trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java	                        (rev 0)
+++ trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,150 @@
+package org.infinispan.loaders.remote;
+
+import net.jcip.annotations.ThreadSafe;
+import org.infinispan.Cache;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.container.entries.InternalCacheEntry;
+import org.infinispan.loaders.AbstractCacheStore;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderException;
+import org.infinispan.loaders.CacheLoaderMetadata;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Cache store that delegates the call to a infinispan cluster. Communication between this cache store and the remote
+ * cluster is achieved through the java HotRod client: this assures fault tolerance and smart dispatching of calls to
+ * the nodes that have the highest chance of containing the given key.
+ * <p/>
+ * Due to certain HotRod constraints, this cache store does not support preload and also cannot be used for provide
+ * state. Setting <b>fetchPersistentState</b> is not allowed.
+ * <p/>
+ * Purging elements is also not possible, as HotRod does not support the fetching of all remote keys (this would be a
+ * very costly operation as well). Purging takes place at the remote end (infinispan cluster).
+ * <p/>
+ *
+ * @see org.infinispan.loaders.remote.RemoteCacheStoreConfig
+ * @see <a href="http://community.jboss.org/wiki/JavaHotRodclient">Hotrod Java Client</a>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at ThreadSafe
+ at CacheLoaderMetadata(configurationClass = RemoteCacheStoreConfig.class)
+public class RemoteCacheStore extends AbstractCacheStore {
+
+   private static Log log = LogFactory.getLog(RemoteCacheStore.class);
+
+   private volatile RemoteCacheStoreConfig config;
+   private volatile RemoteCacheManager remoteCacheManager;
+   private volatile Cache<Object, InternalCacheEntry> remoteCache;
+   private static final String LIFESPAN = "lifespan";
+   private static final String MAXIDLE = "maxidle";
+
+   @Override
+   public InternalCacheEntry load(Object key) throws CacheLoaderException {
+      return remoteCache.get(key);
+   }
+
+   @Override
+   protected void purgeInternal() throws CacheLoaderException {
+      if (log.isTraceEnabled()) {
+         log.trace("Skipping purge call, as this is performed on the remote cache.");
+      }
+   }
+
+   @Override
+   public void store(InternalCacheEntry entry) throws CacheLoaderException {
+      if (log.isTraceEnabled()) {
+         log.trace("Adding entry: " + entry);
+      }
+      remoteCache.put(entry.getKey(), entry, toSeconds(entry.getLifespan(), entry, LIFESPAN), TimeUnit.SECONDS, toSeconds(entry.getMaxIdle(), entry, MAXIDLE), TimeUnit.SECONDS);
+   }
+
+   private long toSeconds(long millis, InternalCacheEntry entry, String desc) {
+      if (millis > 0 && millis < 1000) {
+         if (log.isTraceEnabled()) {
+            log.trace("Adjusting " + desc + " time for (k,v): (" + entry.getKey() + ", " + entry.getValue() + ") from "
+                  + millis + " millis to 1 sec, as milliseconds are not supported by HotRod");
+         }
+         return 1;
+      }
+      return TimeUnit.MILLISECONDS.toSeconds(millis);
+   }
+
+   @Override
+   public void fromStream(ObjectInput inputStream) throws CacheLoaderException {
+      fail();
+   }
+
+   @Override
+   public void toStream(ObjectOutput outputStream) throws CacheLoaderException {
+      fail();
+   }
+
+   @Override
+   public void clear() throws CacheLoaderException {
+      remoteCache.clear();
+   }
+
+   @Override
+   public boolean remove(Object key) throws CacheLoaderException {
+      return remoteCache.remove(key) != null;
+   }
+
+   @Override
+   public Set<InternalCacheEntry> loadAll() throws CacheLoaderException {
+      fail();
+      return null;
+   }
+
+   @Override
+   public Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException {
+      fail();
+      return null;
+   }
+
+   @Override
+   public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException {
+      fail();
+      return null;
+   }
+
+   private void fail() throws CacheLoaderException {
+      String message = "RemoteCacheStore can only run in shared mode and it doesn't support preload!";
+      log.error(message);
+      throw new CacheLoaderException(message);
+   }
+
+   @Override
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+      super.init(config, cache, m);
+      this.config = (RemoteCacheStoreConfig) config;
+   }
+
+   @Override
+   public void start() throws CacheLoaderException {
+      super.start();
+      Marshaller marshaller = getMarshaller();
+
+      if (marshaller == null) {throw new IllegalStateException("Null marshaller not allowed!");}
+      remoteCacheManager = new RemoteCacheManager(new InternalCacheEntryMarshaller(marshaller), config.getHotRodClientProperties());
+      remoteCache = remoteCacheManager.getCache(config.getRemoteCacheName());
+   }
+
+   @Override
+   public void stop() throws CacheLoaderException {
+      remoteCacheManager.stop();
+   }
+
+   @Override
+   public Class<? extends CacheLoaderConfig> getConfigurationClass() {
+      return RemoteCacheStoreConfig.class;
+   }
+}

Added: trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStoreConfig.java
===================================================================
--- trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStoreConfig.java	                        (rev 0)
+++ trunk/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStoreConfig.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,93 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.CacheException;
+import org.infinispan.loaders.AbstractCacheStoreConfig;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.util.FileLookup;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Configuration for RemoteCacheStore.
+ * <p/>
+ * Parameters:
+ * <ul>
+ * <li>HotRodClientPropertiesFile-the file that contains the configuration of hotrod client. See <a href="http://community.jboss.org/wiki/JavaHotRodclient">Hotrod Java Client</a>
+ *     for more details on the hotrod client. 
+ * <li>remoteCacheName-the name of the remote cache in the remote infinispan cluster, to which to connect to</li>
+ * <li>UseDefaultRemoteCache-if set to true, the default remote cache will be used, as obtained by {@link org.infinispan.manager.CacheManager#getCache()}.
+ * </ul>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+public class RemoteCacheStoreConfig extends AbstractCacheStoreConfig {
+
+   private volatile String remoteCacheName;
+
+   private final Properties hotRodClientProperties = new Properties();
+
+   public RemoteCacheStoreConfig() {
+      setCacheLoaderClassName(RemoteCacheStore.class.getName());
+   }
+
+   public void setRemoteCacheName(String remoteCacheName) {
+      this.remoteCacheName = remoteCacheName;
+   }
+
+   public String getRemoteCacheName() {
+      return remoteCacheName;
+   }
+
+   public void setUseDefaultRemoteCache(boolean useDefaultRemoteCache) {
+      if (useDefaultRemoteCache) {
+         setRemoteCacheName(DefaultCacheManager.DEFAULT_CACHE_NAME);
+      }
+   }
+
+   public boolean isUseDefaultRemoteCache() {
+      return DefaultCacheManager.DEFAULT_CACHE_NAME.equals(getRemoteCacheName());
+   }
+
+   @Override
+   public void setPurgeOnStartup(Boolean purgeOnStartup) {
+      super.setPurgeOnStartup(purgeOnStartup);
+      if (purgeOnStartup) {
+         log.info("Purge on start-up will be ignored; remote cache store cannot be purged.");
+      }
+   }
+
+   @Override
+   public void setFetchPersistentState(Boolean fetchPersistentState) {
+      if (fetchPersistentState) {
+         String message = "fetchPersistentState cannot be set for remote cache store. This is because " +
+               "persistent state cannot be generated by RemoteCacheStore, and state generation is proprietary. I.e. this " +
+               "store would not be able to integrate state generated by other store implementations.";
+         log.error(message);
+         throw new IllegalStateException(message);
+      } else {
+         super.setFetchPersistentState(fetchPersistentState);
+      }
+   }
+
+   public Properties getHotRodClientProperties() {
+      return hotRodClientProperties;
+   }
+
+   public void setHotRodClientProperties(Properties props) {
+      this.hotRodClientProperties.putAll(props);
+   }
+
+   public void setHotRodClientPropertiesFile(String hotRodClientProperties) {
+      FileLookup fileLookup = new FileLookup();
+      InputStream inputStream = fileLookup.lookupFile(hotRodClientProperties);
+      try {
+         this.hotRodClientProperties.load(inputStream);
+      } catch (IOException e) {
+         log.error("Issues while loading properties from file", e);
+         throw new CacheException(e);
+      }
+   }
+}

Added: trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreConfigTest.java
===================================================================
--- trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreConfigTest.java	                        (rev 0)
+++ trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreConfigTest.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,64 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.Cache;
+import org.infinispan.loaders.CacheLoader;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.server.hotrod.test.HotRodTestingUtil;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * Simple test to sample how remote cache store is configured.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "loaders.remote.RemoteCacheStoreConfigTest", groups = "functional")
+public class RemoteCacheStoreConfigTest {
+
+   public static final String CACHE_LOADER_CONFIG = "remote-cl-config.xml";
+   private EmbeddedCacheManager cacheManager;
+   private HotRodServer hotRodServer;
+
+   @BeforeTest
+   public void startUp() {
+      cacheManager = TestCacheManagerFactory.createLocalCacheManager();
+      assertEquals(cacheManager.getCache().size(), 0);
+      hotRodServer = HotRodTestingUtil.startHotRodServer(cacheManager, 19711);
+   }
+
+   public void simpleTest() throws IOException {
+      CacheManager cm = new DefaultCacheManager(CACHE_LOADER_CONFIG);
+      Cache<Object, Object> cache = cm.getCache();
+      CacheLoader cacheLoader = TestingUtil.getCacheLoader(cache);
+      assert cacheLoader != null;
+      assert cacheLoader instanceof RemoteCacheStore;
+
+
+      cache.put("k", "v");
+
+      assertEquals(1, cacheManager.getCache().size());
+      cache.stop();
+      assertEquals(1, cacheManager.getCache().size());
+      cm.stop();
+      cm = new DefaultCacheManager(CACHE_LOADER_CONFIG);
+      cache = cm.getCache();
+      assertEquals("v", cache.get("k"));
+   }
+
+   @AfterTest
+   public void tearDown() {
+      hotRodServer.stop();
+      cacheManager.stop();
+   }
+}

Added: trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreFunctionalTest.java
===================================================================
--- trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreFunctionalTest.java	                        (rev 0)
+++ trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreFunctionalTest.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,53 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.client.hotrod.TestHelper;
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "loaders.remote.RemoteCacheStoreFunctionalTest", groups = "functional")
+public class RemoteCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+   private EmbeddedCacheManager localCacheManager;
+   private HotRodServer hrServer;
+
+   @Override
+   protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+      RemoteCacheStoreConfig remoteCacheStoreConfig = new RemoteCacheStoreConfig();
+      localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
+      hrServer = TestHelper.startHotRodServer(localCacheManager);
+
+      remoteCacheStoreConfig.setRemoteCacheName(DefaultCacheManager.DEFAULT_CACHE_NAME);
+      Properties properties = new Properties();
+      properties.put("hotrod-servers", "localhost:"+ hrServer.getPort());
+      remoteCacheStoreConfig.setHotRodClientProperties(properties);
+
+      return remoteCacheStoreConfig;
+   }
+
+   @AfterTest
+   public void tearDown() {
+      hrServer.stop();
+      localCacheManager.stop();
+   }
+
+   @Override
+   public void testPreloadAndExpiry() {
+      assert true : "Remote cache store does not support preload";
+   }
+
+   @Override
+   public void testTwoCachesSameCacheStore() {
+      //not applicable
+   }
+}

Added: trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreTest.java
===================================================================
--- trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreTest.java	                        (rev 0)
+++ trunk/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreTest.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,99 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.client.hotrod.TestHelper;
+import org.infinispan.config.Configuration;
+import org.infinispan.container.entries.InternalCacheEntry;
+import org.infinispan.container.entries.InternalEntryFactory;
+import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.loaders.BaseCacheStoreTest;
+import org.infinispan.loaders.CacheLoaderException;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "loaders.remote.RemoteCacheStoreTest", groups = "functional")
+public class RemoteCacheStoreTest extends BaseCacheStoreTest {
+
+   private EmbeddedCacheManager localCacheManager;
+   private HotRodServer hrServer;
+
+   @Override
+   protected CacheStore createCacheStore() throws Exception {
+      RemoteCacheStoreConfig remoteCacheStoreConfig = new RemoteCacheStoreConfig();
+      remoteCacheStoreConfig.setUseDefaultRemoteCache(true);
+      assert remoteCacheStoreConfig.isUseDefaultRemoteCache();
+      
+      localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
+      Configuration configuration = localCacheManager.getDefaultConfiguration();
+      configuration.setEvictionWakeUpInterval(10);
+      configuration.setEvictionStrategy(EvictionStrategy.UNORDERED);
+      hrServer = TestHelper.startHotRodServer(localCacheManager);
+      Properties properties = new Properties();
+      properties.put("hotrod-servers", "localhost:" + hrServer.getPort());
+      remoteCacheStoreConfig.setHotRodClientProperties(properties);
+
+      RemoteCacheStore remoteCacheStore = new RemoteCacheStore();
+      remoteCacheStore.init(remoteCacheStoreConfig, getCache(), getMarshaller());
+      remoteCacheStore.start();
+      super.supportsLoadAll = false;
+      return remoteCacheStore;
+   }
+
+   @AfterTest
+   public void tearDown() {
+      hrServer.stop();
+      localCacheManager.stop();
+   }
+
+   @Override
+   public void testLoadKeys() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   protected void purgeExpired() throws CacheLoaderException {
+      localCacheManager.getCache().clear();
+   }
+
+   @Override
+   public void testPreload() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   public void testPreloadWithMaxSize() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   protected void sleepForStopStartTest() throws InterruptedException {
+      Thread.sleep(3000);
+   }
+
+
+   @Override
+   public void testStoreAndRemoveAll() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   public void testStreamingAPI() throws IOException, ClassNotFoundException, CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   public void testStreamingAPIReusingStreams() throws IOException, ClassNotFoundException, CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+}

Added: trunk/cachestore/remote/src/test/resources/hotrod-client.properties
===================================================================
--- trunk/cachestore/remote/src/test/resources/hotrod-client.properties	                        (rev 0)
+++ trunk/cachestore/remote/src/test/resources/hotrod-client.properties	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,9 @@
+# hopefully this port is available
+hotrod-servers=127.0.0.1:19711
+force-return-value=false
+
+
+##bellow is connection pooling config
+maxActive=99
+maxTotal = -98
+maxIdle = 97
\ No newline at end of file

Added: trunk/cachestore/remote/src/test/resources/log4j.xml
===================================================================
--- trunk/cachestore/remote/src/test/resources/log4j.xml	                        (rev 0)
+++ trunk/cachestore/remote/src/test/resources/log4j.xml	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!--
+   For more configuration infromation and examples see the Apache Log4j website: http://logging.apache.org/log4j/
+ -->
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- A time/date based rolling appender -->
+   <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
+      <param name="File" value="remote_cache_store.log"/>
+      <param name="Append" value="false"/>
+
+      <!-- Rollover at midnight each day -->
+      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+      <!-- Rollover at the top of each hour
+         <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+      -->
+      <param name="Threshold" value="TRACE"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
+
+         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+        <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+         -->
+      </layout>
+   </appender>
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <param name="Threshold" value="TRACE"/>
+      <param name="Target" value="System.out"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d %-5p [%c{1}] (%t) %m%n"/>
+      </layout>
+   </appender>
+
+
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
+
+   <category name="org.infinispan">
+      <priority value="TRACE"/>
+   </category>
+
+   <category name="com.mchange">
+      <priority value="WARN"/>
+   </category>
+
+   <category name="org.infinispan.profiling">
+      <priority value="WARN"/>
+   </category>
+
+   <category name="org.infinispan.jmx">
+      <priority value="WARN"/>
+   </category>
+
+   <category name="org.infinispan.factories">
+      <priority value="WARN"/>
+   </category>
+
+   <category name="com.mchange.v2">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <priority value="WARN"/>
+      <!--<appender-ref ref="CONSOLE"/>-->
+      <appender-ref ref="FILE"/>
+   </root>
+
+</log4j:configuration>

Added: trunk/cachestore/remote/src/test/resources/remote-cl-config.xml
===================================================================
--- trunk/cachestore/remote/src/test/resources/remote-cl-config.xml	                        (rev 0)
+++ trunk/cachestore/remote/src/test/resources/remote-cl-config.xml	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<infinispan
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
+      xmlns="urn:infinispan:config:4.0">
+
+   <default>
+      <jmxStatistics enabled="false"/>
+      <deadlockDetection enabled="true" spinDuration="1221"/>
+      <loaders passivation="false" shared="true" preload="false">
+         <loader class="org.infinispan.loaders.remote.RemoteCacheStore" fetchPersistentState="false"
+                 ignoreModifications="false" purgeOnStartup="false">
+            <properties>
+               <property name="hotRodClientPropertiesFile" value="hotrod-client.properties"/>
+               <property name="useDefaultRemoteCache" value="true"/>
+            </properties>
+         </loader>
+      </loaders>
+   </default>
+
+</infinispan>

Copied: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java (from rev 1829, trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/HotRodMarshaller.java)
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java	                        (rev 0)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -0,0 +1,18 @@
+package org.infinispan.client.hotrod;
+
+import net.jcip.annotations.ThreadSafe;
+
+/**
+ * Used for un/marshalling objects sent between hotrod client and server (hotrod is a binary protocol).
+ * A single instance of this class is shared by all threads, so this class needs to be thread safe.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at ThreadSafe 
+public interface HotRodMarshaller {
+
+   byte[] marshallObject(Object toMarshall);
+
+   Object readObject(byte[] bytes);
+}

Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -1,7 +1,7 @@
 package org.infinispan.client.hotrod;
 
 import org.infinispan.client.hotrod.exceptions.HotRodClientException;
-import org.infinispan.client.hotrod.impl.HotRodMarshaller;
+import org.infinispan.client.hotrod.HotRodMarshaller;
 import org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory;
 import org.infinispan.client.hotrod.impl.protocol.HotRodOperations;
 import org.infinispan.client.hotrod.impl.protocol.HotRodOperationsImpl;
@@ -136,7 +136,7 @@
 
    private Properties props;
    private TransportFactory transportFactory;
-   private String hotrodMarshaller;
+   private HotRodMarshaller hotRodMarshaller;
    private boolean started = false;
    private boolean forceReturnValueDefault = false;
    private ExecutorService asyncExecutorService;
@@ -145,6 +145,29 @@
 
 
    /**
+    * Builds a remote cache manager that relies on the provided {@link org.infinispan.client.hotrod.HotRodMarshaller} for marshalling
+    * keys and values to be send over to the remote infinispan cluster.
+    * @param hotRodMarshaller marshaller implementatin to be used
+    * @param props other properties
+    * @param start weather or not to start the manager on return from the constructor.
+    */
+   public RemoteCacheManager(HotRodMarshaller hotRodMarshaller, Properties props, boolean start) {
+      this(props);
+      this.hotRodMarshaller = hotRodMarshaller;
+      if (log.isTraceEnabled()) {
+         log.trace("Using explicitly set marshaller: " + hotRodMarshaller);
+      }
+      if (start) start();
+   }
+
+   /**
+    * Same as {@link org.infinispan.client.hotrod.RemoteCacheManager#RemoteCacheManager(HotRodMarshaller, java.util.Properties, boolean)} with start = true.
+    */
+   public RemoteCacheManager(HotRodMarshaller hotRodMarshaller, Properties props) {
+      this(hotRodMarshaller, props, false);
+   }
+
+   /**
     * Build a cache manager based on supplied properties.
     */
    public RemoteCacheManager(Properties props, boolean start) {
@@ -273,7 +296,14 @@
       transportFactory = (TransportFactory) VHelper.newInstance(factory);
       String servers = props.getProperty(CONF_HOTROD_SERVERS);
       transportFactory.start(props, getStaticConfiguredServers(servers), topologyId);
-      hotrodMarshaller = props.getProperty("marshaller");
+      if (hotRodMarshaller == null) {
+         String hotrodMarshallerClass = props.getProperty("marshaller");
+         if (hotrodMarshallerClass == null) {
+            hotrodMarshallerClass = SerializationMarshaller.class.getName();
+            log.info("'marshaller' not specified, using " + hotrodMarshallerClass);
+         }
+         hotRodMarshaller = (HotRodMarshaller) VHelper.newInstance(hotrodMarshallerClass); 
+      }
 
       String asyncExecutorClass = DefaultAsyncExecutorFactory.class.getName();
       if (props.contains("asyn-executor-factory")) {
@@ -283,10 +313,6 @@
       asyncExecutorService = executorFactory.getExecutor(props);
 
 
-      if (hotrodMarshaller == null) {
-         hotrodMarshaller = SerializationMarshaller.class.getName();
-         log.info("'marshaller' not specified, using " + hotrodMarshaller);
-      }
       if (props.get("force-return-value") != null && props.get("force-return-value").equals("true")) {
          forceReturnValueDefault = true;
       }
@@ -333,9 +359,8 @@
    }
 
    private <K, V> void startRemoteCache(RemoteCacheImpl<K, V> result) {
-      HotRodMarshaller marshaller = (HotRodMarshaller) VHelper.newInstance(hotrodMarshaller);
       HotRodOperations hotRodOperations = new HotRodOperationsImpl(result.getName(), transportFactory, topologyId);
-      result.init(hotRodOperations, marshaller, asyncExecutorService);
+      result.init(hotRodOperations, hotRodMarshaller, asyncExecutorService);
    }
 
    private Set<InetSocketAddress> getStaticConfiguredServers(String servers) {

Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/exceptions/HotRodTimeoutException.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/exceptions/HotRodTimeoutException.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/exceptions/HotRodTimeoutException.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -6,5 +6,5 @@
  * @author Mircea.Markus at jboss.com
  * @since 4.1
  */
-public class HotRodTimeoutException extends RuntimeException {
+public class HotRodTimeoutException extends HotRodClientException {
 }

Deleted: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/HotRodMarshaller.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/HotRodMarshaller.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/HotRodMarshaller.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -1,14 +0,0 @@
-package org.infinispan.client.hotrod.impl;
-
-/**
- * Used for un/marshalling objects sent between hotrod client and server (hotrod is a binary protocol). 
- *
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public interface HotRodMarshaller {
-
-   byte[] marshallObject(Object toMarshall);
-
-   Object readObject(byte[] bytes);
-}

Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -1,6 +1,7 @@
 package org.infinispan.client.hotrod.impl;
 
 import org.infinispan.client.hotrod.Flag;
+import org.infinispan.client.hotrod.HotRodMarshaller;
 import org.infinispan.client.hotrod.RemoteCache;
 import org.infinispan.client.hotrod.RemoteCacheManager;
 import org.infinispan.client.hotrod.ServerStatistics;
@@ -157,6 +158,9 @@
       assertRemoteCacheManagerIsStarted();
       int lifespanSecs = toSeconds(lifespan, lifespanUnit);
       int maxIdleSecs = toSeconds(maxIdleTime, maxIdleTimeUnit);
+      if (log.isTraceEnabled()) {
+         log.trace("About to add (K,V): (" + key + ", " + value + ") lifespanSecs:" + lifespanSecs + ", maxIdleSecs:" + maxIdleSecs);
+      }
       byte[] result = operations.put(obj2bytes(key), obj2bytes(value), lifespanSecs, maxIdleSecs, flags());
       return (V) bytes2obj(result);
    }

Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -1,5 +1,6 @@
 package org.infinispan.client.hotrod.impl;
 
+import org.infinispan.client.hotrod.HotRodMarshaller;
 import org.infinispan.client.hotrod.exceptions.HotRodClientException;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;

Modified: trunk/core/src/main/java/org/infinispan/affinity/KeyAffinityServiceFactory.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/affinity/KeyAffinityServiceFactory.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/core/src/main/java/org/infinispan/affinity/KeyAffinityServiceFactory.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -2,7 +2,10 @@
 
 import org.infinispan.Cache;
 import org.infinispan.executors.ExecutorFactory;
+import org.infinispan.remoting.transport.Address;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Properties;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -47,6 +50,24 @@
    
    /**
     * Same as {@link #newKeyAffinityService(org.infinispan.Cache,org.infinispan.executors.ExecutorFactory,
+    * KeyGenerator ,int)} with the an {@link RndKeyGenerator}.
+    */
+   public static <K,V> KeyAffinityService newKeyAffinityService(Cache<K,V> cache, Collection<Address> forAddresses, ExecutorFactory ex, int keyBufferSize) {
+      return newKeyAffinityService(cache, ex, new RndKeyGenerator(), keyBufferSize);
+   }
+   
+   /**
+    * Same as {@link #newKeyAffinityService(org.infinispan.Cache,org.infinispan.executors.ExecutorFactory,
+    * KeyGenerator ,int)} with the an {@link RndKeyGenerator}.
+    */
+   public static <K,V> KeyAffinityService newLocalKeyAffinityService(Cache<K,V> cache, ExecutorFactory ex, int keyBufferSize) {
+      Address localAddress = cache.getAdvancedCache().getRpcManager().getTransport().getAddress();
+      Collection<Address> forAddresses = Collections.singletonList(localAddress);
+      return newKeyAffinityService(cache, ex, new RndKeyGenerator(), keyBufferSize);
+   }
+
+   /**
+    * Same as {@link #newKeyAffinityService(org.infinispan.Cache,org.infinispan.executors.ExecutorFactory,
     * KeyGenerator ,int)} with the an {@link RndKeyGenerator} and an
     * {@link java.util.concurrent.Executors#newSingleThreadExecutor()} executor.
     */

Modified: trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -1,13 +1,20 @@
 package org.infinispan.loaders;
 
+import org.infinispan.Cache;
+import org.infinispan.marshall.Marshaller;
+
 /**
  * An abstract {@link org.infinispan.loaders.CacheLoader} that holds common implementations for some methods
  *
  * @author Manik Surtani
+ * @author Mircea.Markus at jboss.com
  * @since 4.0
  */
 public abstract class AbstractCacheLoader implements CacheLoader {
 
+   protected volatile Marshaller marshaller;
+   protected volatile Cache cache;
+
    /**
     * {@inheritDoc} This implementation delegates to {@link CacheLoader#load(Object)}, to ensure that a response is
     * returned only if the entry is not expired.
@@ -15,4 +22,11 @@
    public boolean containsKey(Object key) throws CacheLoaderException {
       return load(key) != null;
    }
+
+   @Override
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+      this.marshaller = m;
+      if (config == null) throw new IllegalStateException("Null config!!!");
+      this.cache = cache;
+   }
 }

Modified: trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -25,24 +25,22 @@
  * An abstract {@link org.infinispan.loaders.CacheStore} that holds common implementations for some methods
  *
  * @author Manik Surtani
+ * @author Mircea.Markus at jboss.com
  * @since 4.0
  */
 public abstract class AbstractCacheStore extends AbstractCacheLoader implements CacheStore {
 
-   private Map<GlobalTransaction, List<? extends Modification>> transactions;
    private static Log log = LogFactory.getLog(AbstractCacheStore.class);
+
+   private Map<GlobalTransaction, List<? extends Modification>> transactions;
    private AbstractCacheStoreConfig config;
    protected ExecutorService purgerService;
-   protected Marshaller marshaller;
-   protected Cache cache;
    private static final AtomicInteger THREAD_COUNTER = new AtomicInteger(0);
    protected boolean multiThreadedPurge = false;
 
    public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException{
+      super.init(config, cache, m);
       this.config = (AbstractCacheStoreConfig) config;
-      this.marshaller = m;
-      if (config == null) throw new IllegalStateException("Null config!!!");
-      this.cache = cache;
    }
 
    protected final int getConcurrencyLevel() {

Modified: trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -73,7 +73,6 @@
    public void testTwoCachesSameCacheStore() {
       EmbeddedCacheManager localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
       try {
-         GlobalConfiguration configuration = localCacheManager.getGlobalConfiguration();
          CacheLoaderManagerConfig clmConfig = new CacheLoaderManagerConfig();
          clmConfig.setCacheLoaderConfigs(Collections.singletonList((CacheLoaderConfig) csConfig));
          localCacheManager.getDefaultConfiguration().setCacheLoaderManagerConfig(clmConfig);

Modified: trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java	2010-05-25 21:24:52 UTC (rev 1850)
@@ -56,6 +56,8 @@
 
    protected GlobalTransactionFactory gtf = new GlobalTransactionFactory();
 
+   protected volatile boolean supportsLoadAll = true;
+
    @BeforeMethod
    public void setUp() throws Exception {
       try {
@@ -126,18 +128,22 @@
       assert cs.containsKey("k");
       InternalCacheEntry ice = cs.load("k");
       assertCorrectExpiry(ice, "v", lifespan, -1, false);
-      ice = cs.loadAll().iterator().next();
-      assertCorrectExpiry(ice, "v", lifespan, -1, false);
+      if (supportsLoadAll) {
+         ice = cs.loadAll().iterator().next();
+         assertCorrectExpiry(ice, "v", lifespan, -1, false);
+      }
 
       lifespan = 1;
       se = InternalEntryFactory.create("k", "v", lifespan);
       cs.store(se);
       Thread.sleep(100);
-      cs.purgeExpired();
+      purgeExpired();
       assert se.isExpired();
       assert cs.load("k") == null;
       assert !cs.containsKey("k");
-      assert cs.loadAll().isEmpty();
+      if (supportsLoadAll) {
+         assert cs.loadAll().isEmpty();
+      }
    }
 
    private void assertCorrectExpiry(InternalCacheEntry ice, String value, long lifespan, long maxIdle, boolean expired) {
@@ -161,20 +167,28 @@
       assert cs.containsKey("k");
       InternalCacheEntry ice = cs.load("k");
       assertCorrectExpiry(ice, "v", -1, idle, false);
-      ice = cs.loadAll().iterator().next();
-      assertCorrectExpiry(ice, "v", -1, idle, false);
+      if (supportsLoadAll) {
+         ice = cs.loadAll().iterator().next();
+         assertCorrectExpiry(ice, "v", -1, idle, false);
+      }
 
       idle = 1;
       se = InternalEntryFactory.create("k", "v", -1, idle);
       cs.store(se);
       Thread.sleep(100);
-      cs.purgeExpired();
+      purgeExpired();
       assert se.isExpired();
       assert cs.load("k") == null;
       assert !cs.containsKey("k");
-      assert cs.loadAll().isEmpty();
+      if (supportsLoadAll) {
+         assert cs.loadAll().isEmpty();
+      }
    }
 
+   protected void purgeExpired() throws CacheLoaderException {
+      cs.purgeExpired();
+   }
+
    public void testLoadAndStoreWithLifespanAndIdle() throws InterruptedException, CacheLoaderException {
       assert !cs.containsKey("k");
 
@@ -186,18 +200,22 @@
       assert cs.containsKey("k");
       InternalCacheEntry ice = cs.load("k");
       assertCorrectExpiry(ice, "v", lifespan, idle, false);
-      ice = cs.loadAll().iterator().next();
-      assertCorrectExpiry(ice, "v", lifespan, idle, false);
+      if (supportsLoadAll) {
+         ice = cs.loadAll().iterator().next();
+         assertCorrectExpiry(ice, "v", lifespan, idle, false);
+      }
 
       idle = 1;
       se = InternalEntryFactory.create("k", "v", lifespan, idle);
       cs.store(se);
       Thread.sleep(100);
-      cs.purgeExpired();
+      purgeExpired();
       assert se.isExpired();
       assert cs.load("k") == null;
       assert !cs.containsKey("k");
-      assert cs.loadAll().isEmpty();
+      if (supportsLoadAll) {
+         assert cs.loadAll().isEmpty();
+      }
    }
 
    public void testStopStartDoesNotNukeValues() throws InterruptedException, CacheLoaderException {
@@ -215,7 +233,9 @@
       cs.store(se2);
       cs.store(se3);
       cs.store(se4);
-      Thread.sleep(100);
+
+      sleepForStopStartTest();
+
       cs.stop();
       cs.start();
       assert se1.isExpired();
@@ -232,7 +252,11 @@
       assert !cs.containsKey("k3");
    }
 
+   protected void sleepForStopStartTest() throws InterruptedException {
+      Thread.sleep(100);
+   }
 
+
    public void testOnePhaseCommit() throws CacheLoaderException {
       List<Modification> mods = new ArrayList<Modification>();
       mods.add(new Store(InternalEntryFactory.create("k1", "v1")));
@@ -464,7 +488,7 @@
       assert cs.containsKey("k2");
       assert cs.containsKey("k3");
       Thread.sleep(lifespan + 10);
-      cs.purgeExpired();
+      purgeExpired();
       assert !cs.containsKey("k1");
       assert !cs.containsKey("k2");
       assert !cs.containsKey("k3");
@@ -618,7 +642,9 @@
                int randomInt = r.nextInt(10);
                InternalCacheEntry se = cs.load(keys[randomInt]);
                assert se == null || se.getValue().equals(values[randomInt]);
-               cs.loadAll();
+               if (supportsLoadAll) {
+                  cs.loadAll();
+               }
             } catch (Exception e) {
                exceptions.add(e);
             }

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2010-05-25 21:03:57 UTC (rev 1849)
+++ trunk/pom.xml	2010-05-25 21:24:52 UTC (rev 1850)
@@ -29,6 +29,7 @@
       <module>cachestore/jdbm</module>
       <module>cachestore/bdbje</module>
       <module>cachestore/cloud</module>
+      <module>cachestore/remote</module>
       <module>server</module>
       <module>server/core</module>
       <module>server/memcached</module>



More information about the infinispan-commits mailing list