Reputation: 3
I am using Infinispan 7.0.2.Final and i am having very strange behaviour.
I am using infinispan for remote querying between server and client using inifinispan DSL for querying, and for some reason server does not return result list, but the result size is not zero.
The behaviour I am talking about is represented in the following code. After executing the following code:
Query query = qf.from(CacheEntity.class).having("ID").like("%AI%").toBuilder().build();
System.out.println("size: "+query.getResultSize());
System.out.println("result: "+query.list());
I get this output:
size: 2000
result: []
Which is strange, because the result clearly does not have 2000 elements :)
I setup the client in the following way:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-main.xml");
RemoteCacheManager manager = ((RemoteCacheManager) context.getBean("cacheManager"));
RemoteCache cache = manager.getCache("cache");
SerializationContext srcCtx = ProtoStreamMarshaller.getSerializationContext(manager);
FileDescriptorSource fds = new FileDescriptorSource();
fds.addProtoFiles("entity.proto");
srcCtx.registerProtoFiles(fds);
srcCtx.registerMarshaller(new CachedEntityMarshaller());
RemoteCache<String, String> metadataCache = manager.getCache("___protobuf_metadata");
metadataCache.put("entity.proto", new InfinispanClientApplication().read("/entity.proto"));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(manager));
Server side:
HotRodServerConfiguration build = new HotRodServerConfigurationBuilder().
host("127.0.0.1").
port(11222).
build();
HotRodServer server = new HotRodServer();
server.start(build, cacheManager);
I also noticed that the writeTo method on my EntityMarshaller gets invoked on every write, but readTo method is never invoked.
I am currently stuck, and any help will be appreciated.
Thanks a lot!
SOLUTION:
In addition to the "best answer" response. I was configuring my infinispan cache using spring (SpringEmbeddedCacheManagerFactoryBean). I migrated to java config using org.infinispan.configuration classes. After that, I did what I was proposed in the "best answer", and that solved the problem completely.
Upvotes: 0
Views: 347
Reputation: 5888
I am not sure this is really the cause of your trouble, but a common issue when starting standalone HotRodServer is that you don't specify data-containers equivalence functions correctly:
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.dataContainer()
.keyEquivalence(new AnyServerEquivalence())
.valueEquivalence(new AnyServerEquivalence());
cacheManager.defineConfiguration("cache", builder.build());
Please make sure that you're using the code above for this cache.
Upvotes: 1