Preload problem
john.prince Aug 5, 2009 7:56 AMHi, I'm trying to get persistence working, without much success. There seems to be a problem with the serialization of large objects. Here is a test to show the problem:
import java.util.Arrays;
import org.infinispan.Cache;
import org.infinispan.config.CacheLoaderManagerConfig;
import org.infinispan.config.Configuration;
import org.infinispan.loaders.file.FileCacheStoreConfig;
import org.infinispan.manager.CacheManager;
import org.infinispan.manager.DefaultCacheManager;
/**
* @author John Prince
* Date: Aug 5, 2009
* Time: 1:15:48 PM
*/
public class InfinispanTest
{
private static void runTest(int count)
{
try
{
Configuration cacheConfig = new Configuration();
CacheLoaderManagerConfig cacheLoaders = new CacheLoaderManagerConfig();
cacheLoaders.setPreload(true);
FileCacheStoreConfig fileStoreConfig = new FileCacheStoreConfig();
fileStoreConfig.setLocation("/work/temp/cache_store_" + count);
cacheLoaders.addCacheLoaderConfig(fileStoreConfig);
cacheConfig.setCacheLoaderManagerConfig(cacheLoaders);
CacheManager manager = new DefaultCacheManager(true);
manager.defineCache("test", cacheConfig);
Cache<String, byte[]> cache = manager.getCache("test");
cache.start();
byte[] bytes = new byte[count];
Arrays.fill(bytes, (byte) 1);
cache.put("test_object", bytes);
int cacheSize = cache.size();
manager.stop();
assert 1 == cacheSize;
}
catch (Throwable e)
{
System.out.println("FAILURE::: Test with " + count + " failed. ");
e.printStackTrace();
}
}
public static void main(String[] args)
{
runTest(60000);
runTest(60000);
runTest(70000);
runTest(70000);
}
}
With a 60000 byte array, the preload works. With 70000 it doesn't. Environment is Windows Vista, JDK 1.6.0_u14, yesterday's SVN version (before you just broke it today :>))
Is this a known problem? JBoss Serialization seems to have problems with large objects too - I assume that the origin of the problem is there, but I took a look at the code and then looked away again :>)
I realize this is alpha software, and I am otherwise very excited about the possibilities, but this is a bit of a killer for me. Any hints on what I might be doing wrong, or what the problem might be, would be greatly appreciated.
FWIW, you don't seem to have any tests for this - you have a couple of preload tests, but they are on very small objects.
Best wishes
John