Enabling compatibility doesn't seems to do anything ?
ixo Jul 8, 2015 3:15 PMHello, I am a total newbie with infinispan, but features feets my needs.
I am using a C++ HotRod client with a Java embedded HotRot endpoint with cache, and when I am putting K/V the java cache listener throw an exception about cast error between B[ and String.
I found that I amy have to enable compatibility mode, so I did, but it doesn't to seems to do anything.
Here my code :
Main java software :
public static void main(final String[] args) { final EmbeddedCacheManager manager = new DefaultCacheManager(); final PersistenceConfigurationBuilder persistConfig = new ConfigurationBuilder().persistence(); final SingleFileStoreConfigurationBuilder fileStore = new SingleFileStoreConfigurationBuilder(persistConfig).location("cache"); final Configuration config = persistConfig.addStore(fileStore).build(); config.compatibility().enabled(); manager.defineConfiguration("records", config); final Cache<String, String> c = manager.getCache("records"); c.addListener(new CacheListener()); new HotRodServer().start(new HotRodServerConfigurationBuilder().build(), manager); while(true) { try { Thread.sleep(1000); System.out.println(c.size()); } catch(final InterruptedException e) { } } }
My cache listener :
@CacheEntryCreated public void observeAdd(final CacheEntryCreatedEvent<Object, String> event) { if(event.isPre()) return; System.err.println(event.getKey().getClass().getSimpleName()); System.err.println("new entry : " + event.getKey() + " -> " + event.getValue()); }
Extract of the exception :
Caused by: java.lang.ClassCastException: [B cannot be cast to java.lang.String
at recordprocessing.CacheListener.observeAdd(CacheListener.java:38) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl$1.run(AbstractListenerImpl.java:286) ~[infinispan-core-7.2.3.Final.jar:7.2.3.Final]
... 60 common frames omitted
My c++ hotrod client is exactly from the documentation :
#include "infinispan/hotrod/ConfigurationBuilder.h" #include "infinispan/hotrod/RemoteCacheManager.h" #include "infinispan/hotrod/RemoteCache.h" #include <stdlib.h> using namespace infinispan::hotrod; int main(int argc, char** argv) { ConfigurationBuilder b; b.addServer().host("127.0.0.1").port(11222); RemoteCacheManager cm(builder.build(), false); RemoteCache<std::string, std::string> cache = cm.getCache<std::string, std::string>(std::string("records")); cm.start(); std::string k1("key13"); std::string v1("boron"); rc.put(k1, v1); cm.stop(); return 0; }
What do I do wrong ? and what needs to be changed to make this code works ?
Thanks.
Best regards.