-
1. Re: HotRod Client and RESTFul Client behavior
nadirx Oct 16, 2017 2:46 AM (in response to justcono) -
2. Re: HotRod Client and RESTFul Client behavior
justcono Oct 16, 2017 8:06 PM (in response to nadirx)Hi Tristan,
Thank you kindly for your response. I tried it but with no success. I added:
<distributed-cache name="default" mode="ASYNC" segments="20" owners="2" remote-timeout="30000" start="EAGER">
<locking acquire-timeout="30000" concurrency-level="1000" striping="false"/>
<transaction mode="NONE"/>
<backups>
<backup site="PROD2" strategy="ASYNC" failure-policy="WARN" enabled="true" />
</backups>
<partition-handling enabled="true"/>
<compatibility/>
</distributed-cache>
Put cache via REST
echo "Tesla" | curl -v -u aaaa:aaaa -X PUT -d @- --header "Content-Type: text/plain" http://192.168.11.237:8080/rest/default/car
Get cache via Hotrod:
URL resource = Thread.currentThread().getContextClassLoader()
.getResource("hotrod-client.properties");
RemoteCacheManager cacheContainer = new RemoteCacheManager(true);
//obtain a handle to the remote default cache
RemoteCache cache = cacheContainer.getCache("default");System.out.println("Value: "+cache.get("car"));
Kind Regards,
cd
-
3. Re: HotRod Client and RESTFul Client behavior
gustavonalle Oct 17, 2017 3:20 AM (in response to justcono)Hi,
Compatibility between Rest and Hot Rod currently works only for UTF-8 based content, you configuration is correct but you need to set the appropriate marshaller in the hot rod client:
import org.infinispan.commons.marshall.UTF8StringMarshaller; RemoteCacheManager rcm = new RemoteCacheManager(new ConfigurationBuilder().marshaller(new UTF8StringMarshaller()).build());
-
4. Re: HotRod Client and RESTFul Client behavior
justcono Oct 17, 2017 7:49 PM (in response to gustavonalle)Hi Gustavo,
I tried that but with no success. I'm sure it's something I've done incorrectly. I've uploaded my configs and src. I'm afraid I'm a non-expert at this. If you can suggest something I can do some additional research. Again, all I need to do is read from two different client types the same cache entry from the same cache, one client is restful via 'curl' and other is the hotrod client.
Domain Controller
domain.xml + host-master.xml
Slave:
host-slave.xml
Thanks,
cd
-
hotrod-client-src.tar.gz 67.5 KB
-
host-slave.xml.zip 1.2 KB
-
host-master.xml.zip 955 bytes
-
domain.xml.zip 3.9 KB
-
-
5. Re: HotRod Client and RESTFul Client behavior
gustavonalle Oct 18, 2017 1:21 AM (in response to justcono)Could you try with
<compatibility enabled="true"/>
rather than
<compatibility/>?
-
6. Re: HotRod Client and RESTFul Client behavior
justcono Oct 20, 2017 6:05 PM (in response to gustavonalle)Hi Gustavo,
Thanks for bearing with me on this... I made the update as you suggested and made some progress but still not there yet.
Observation #1. Without the marshaller, I'm able to retrieve some kind of reference instead of getting back null.
eg:
Value: [B@7823a2f9
With marshalling I get the following exception:
[Server:prod1-s1] 17:42:34,523 ERROR [org.infinispan.interceptors.InvocationContextInterceptor] (HotRodServerWorker-6-1) ISPN000136: Error executing command GetCacheEntryCommand, writing keys []: java.io.IOException: Unsupported protocol version 99
[Server:prod1-s1] at org.jboss.marshalling.river.RiverUnmarshaller.start(RiverUnmarshaller.java:1348)
[Server:prod1-s1] at org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller.startObjectInput(AbstractJBossMarshaller.java:128)
[Server:prod1-s1] at org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller.objectFromByteBuffer(AbstractJBossMarshaller.java:109)
[Server:prod1-s1] at org.infinispan.commons.marshall.AbstractMarshaller.objectFromByteBuffer(AbstractMarshaller.java:82)
[Server:prod1-s1] at org.infinispan.server.hotrod.HotRodTypeConverter.unmarshall(HotRodTypeConverter.scala:38)
[Server:prod1-s1] at org.infinispan.server.hotrod.HotRodTypeConverter.boxKey(HotRodTypeConverter.scala:20)
[Server:prod1-s1] at org.infinispan.interceptors.compat.BaseTypeConverterInterceptor.visitGetCacheEntryCommand(BaseTypeConverterInterceptor.java:129)
[Server:prod1-s1] at org.infinispan.commands.read.GetCacheEntryCommand.acceptVisitor(GetCacheEntryCommand.java:42)
[Server:prod1-s1] at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
[Server:prod1-s1] at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:110)
[Server:prod1-s1] at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:79)
[Server:prod1-s1] at org.infinispan.commands.AbstractVisitor.visitGetCacheEntryCommand(AbstractVisitor.java:90)
[Server:prod1-s1] at org.infinispan.commands.read.GetCacheEntryCommand.acceptVisitor(GetCacheEntryCommand.java:42)
[Server:prod1-s1] at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
[Server:prod1-s1] at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:113)
[Server:prod1-s1] at org.infinispan.commands.AbstractVisitor.visitGetCacheEntryCommand(AbstractVisitor.java:90)
[Server:prod1-s1] at org.infinispan.commands.read.GetCacheEntryCommand.acceptVisitor(GetCacheEntryCommand.java:42)
[Server:prod1-s1] at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:335)
[Server:prod1-s1] at org.infinispan.cache.impl.CacheImpl.getCacheEntry(CacheImpl.java:421)
[Server:prod1-s1] at org.infinispan.cache.impl.DecoratedCache.getCacheEntry(DecoratedCache.java:568)
[Server:prod1-s1] at org.infinispan.cache.impl.AbstractDelegatingAdvancedCache.getCacheEntry(AbstractDelegatingAdvancedCache.java:212)
[Server:prod1-s1] at org.infinispan.server.hotrod.CacheDecodeContext.get(CacheDecodeContext.scala:127)
[Server:prod1-s1] at org.infinispan.server.hotrod.LocalContextHandler.realChannelRead(LocalContextHandler.java:67)
[Server:prod1-s1] at org.infinispan.server.hotrod.LocalContextHandler.channelRead(LocalContextHandler.java:49)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[Server:prod1-s1] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
[Server:prod1-s1] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[Server:prod1-s1] at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
[Server:prod1-s1] at org.infinispan.server.core.transport.StatsChannelHandler.channelRead(StatsChannelHandler.java:39)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[Server:prod1-s1] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[Server:prod1-s1] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[Server:prod1-s1] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
[Server:prod1-s1] at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:1017)
[Server:prod1-s1] at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:394)
[Server:prod1-s1] at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:299)
[Server:prod1-s1] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
[Server:prod1-s1] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
[Server:prod1-s1] at java.lang.Thread.run(Thread.java:748)
code:
Configuration configuration = new ConfigurationBuilder()
.tcpKeepAlive(true)
.connectionTimeout(0)
.socketTimeout(300000)
.connectionPool()
.maxTotal(1)
.marshaller(new UTF8StringMarshaller())
.addServers("192.168.11.237:11222")
.build();
RemoteCacheManager cacheContainer = new RemoteCacheManager(configuration);
RemoteCache cache = cacheContainer.getCache("default");
System.out.println("Value: "+cache.get("car")); -
7. Re: HotRod Client and RESTFul Client behavior
gustavonalle Oct 21, 2017 2:41 AM (in response to justcono)Hi, the issue is that although the client is using the marshaller, the server does not have knowledge of it, and picks a default one that cannot understand what the client is sending.
From the stack trace, it looks like you're using Infinispan before 9.1, so I'd recommend to upgrade to either 8.2.7.Final or 9.0.3.Final at least so that you can use the already provided string marshaller:
<compatibility enabled="true" marshaller="org.infinispan.commons.marshall.UTF8StringMarshaller"/>
HTH,
Gustavo
-
8. Re: HotRod Client and RESTFul Client behavior
justcono Oct 28, 2017 4:04 PM (in response to gustavonalle)Hi Gustavo,
Thanks for the help. I'll have to convert my configuration to 9.x... generally does the community recommend Infinispan 9 for production? I tried to align to Infinispan 8.2.8 FINAL to Jboss datagrid 8.4.0 so that if purchase the supported version there will be little to no refactoring and expected functional + non-functional behaviour will be the same.
I'll update this once I get some cycles to try it out.
Kind Regards,
cd