Infinispan (infinispan-5.0.1.FINAL) + HotRod + Cassandra 0.7.10 cache access problem
codevally Dec 7, 2011 8:47 PMHi All
I am currently setting up the Infinispan hotrod with cassandra 0.7.10 and they are working fine. I used the below simple java program to access the remote cache store and trying to put simple object to the cassandra specific named cache, but getting this error while putting to cache.
public class CacheManager {
private RemoteCache<Object, Object> remoteCache;
private RemoteCacheManager remoteCacheManager;
private static final String CACHE_NAME = "cassandraCache";
private void getRemoteCache()
{
Properties prop = new Properties();
String name = new String("Test Name");
Integer age = new Integer(33);
try
{
prop.load(new FileInputStream("hotrod.properties"));
}
catch (IOException e)
{
e.printStackTrace();
}
remoteCacheManager = new RemoteCacheManager(prop);
remoteCache= remoteCacheManager.getCache(CACHE_NAME);
remoteCache.put(name, age);
}
public static void main(String[] args) {
CacheManager cm = new CacheManager();
cm.getRemoteCache();
}
}
The error I am getting is:
2011-12-08 11:31:27,344 ERROR [InvocationContextInterceptor] (HotRodServerWorker-1-4) ISPN000136: Execution error
org.infinispan.loaders.CacheLoaderException: org.infinispan.loaders.keymappers.UnsupportedKeyTypeException: Unsupported key type: 'org.infinispan.util.ByteArrayKey' on key: ByteArrayKey{data=ByteArray{size=6, hashCode=36101d01, array=[3, 66, 1, 42, 73, 10, ..]}}
at org.infinispan.loaders.cassandra.CassandraCacheStore.store(CassandraCacheStore.java:432)
at org.infinispan.interceptors.CacheStoreInterceptor.visitPutKeyValueCommand(CacheStoreInterceptor.java:210)
at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
at org.infinispan.interceptors.CacheLoaderInterceptor.visitPutKeyValueCommand(CacheLoaderInterceptor.java:82)
at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:133)
at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:60)
at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:214)
at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:162)
at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:104)
at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:64)
at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:60)
at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:274)
at org.infinispan.CacheImpl.put(CacheImpl.java:518)
at org.infinispan.server.core.AbstractProtocolDecoder.put(AbstractProtocolDecoder.scala:185)
at org.infinispan.server.core.AbstractProtocolDecoder.decodeValue(AbstractProtocolDecoder.scala:141)
at org.infinispan.server.core.AbstractProtocolDecoder.decode(AbstractProtocolDecoder.scala:71)
at org.infinispan.server.core.AbstractProtocolDecoder.decode(AbstractProtocolDecoder.scala:45)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:471)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:444)
at org.infinispan.server.core.AbstractProtocolDecoder.messageReceived(AbstractProtocolDecoder.scala:347)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:540)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:350)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.infinispan.loaders.keymappers.UnsupportedKeyTypeException: Unsupported key type: 'org.infinispan.util.ByteArrayKey' on key: ByteArrayKey{data=ByteArray{size=6, hashCode=36101d01, array=[3, 66, 1, 42, 73, 10, ..]}}
at org.infinispan.loaders.cassandra.CassandraCacheStore.hashKey(CassandraCacheStore.java:597)
at org.infinispan.loaders.cassandra.CassandraCacheStore.store0(CassandraCacheStore.java:444)
at org.infinispan.loaders.cassandra.CassandraCacheStore.store(CassandraCacheStore.java:428)
This is how I configured the cassandra cache with infinispan.
<namedCache name="cassandraCache">
<loaders passivation="false" shared="true" preload="false">
<loader
class="org.infinispan.loaders.cassandra.CassandraCacheStore"
fetchPersistentState="true" ignoreModifications="false"
purgeOnStartup="false">
<properties>
<property name="host" value="10.1.161.69" />
<property name="keySpace" value="Infinispan" />
<property name="entryColumnFamily" value="InfinispanEntries" />
<property name="expirationColumnFamily" value="InfinispanExpiration" />
<property name="sharedKeyspace" value="false" />
<property name="readConsistencyLevel" value="ONE" />
<property name="writeConsistencyLevel" value="ONE" />
<property name="configurationPropertiesFile" value="/app/cassandra-config/cassandrapool.properties" />
<property name="keyMapper" value="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper" />
</properties>
</loader>
</loaders>
</namedCache>
Could someone please help me to solve this issue. Thanks.