You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by endian675 <mi...@griggs.org.uk> on 2015/11/11 15:50:11 UTC

CacheStore being serialized to client?

I have a CacheStore implementation called CacheMissHandlerIgnite.  I run my
"server" node(clientMode=false) and use that to load non-cached data from
the underlying data sources.  When I connect my "client" node
(clientMode=true) I get the serialization error below.  It seems that the
CacheStore implementation is being serialized to the client node - is this
intentional/correct/required?

Connected to the target VM, address: '127.0.0.1:62615', transport: 'socket'
[14:53:40]    __________  ________________ 
[14:53:40]   /  _/ ___/ |/ /  _/_  __/ __/ 
[14:53:40]  _/ // (7 7    // /  / / / _/   
[14:53:40] /___/\___/_/|_/___/ /_/ /___/  
[14:53:40] 
[14:53:40] ver. 1.3.0-incubating#20150710-sha1:2ade6d00
[14:53:40] 2015 Copyright(C) Apache Software Foundation
[14:53:40] 
[14:53:40] Ignite documentation: http://ignite.incubator.apache.org
[14:53:40] 
[14:53:40] Quiet mode.
[14:53:40]   ^-- To see **FULL** console log here add -DIGNITE_QUIET=false
or "-v" to ignite.{sh|bat}
[14:53:40] 
[14:53:40] Initial heap size is 128MB (should be no less than 512MB, use
-Xms512m -Xmx512m).
[14:53:41] Configured plugins:
[14:53:41]   ^-- None
[14:53:41] 
Nov 11, 2015 2:53:46 PM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Failed to unmarshal discovery data for component: 1
class org.apache.ignite.IgniteCheckedException: Failed to find class with
given class loader for unmarshalling (make sure same versions of all classes
are available on all nodes or enable peer-class-loading):
sun.misc.Launcher$AppClassLoader@14dad5dc
	at
org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal(JdkMarshaller.java:104)
	at
org.apache.ignite.marshaller.AbstractMarshaller.unmarshal(AbstractMarshaller.java:67)
	at
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.onExchange(TcpDiscoverySpi.java:1529)
	at
org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.processNodeAddFinishedMessage(ClientImpl.java:1317)
	at
org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.processDiscoveryMessage(ClientImpl.java:1229)
	at
org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.body(ClientImpl.java:1199)
	at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.lang.ClassNotFoundException:
c.g.r.cachewrapper.ignite.CacheMissHandlerIgnite
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at
org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:7911)
	at
org.apache.ignite.marshaller.jdk.JdkMarshallerObjectInputStream.resolveClass(JdkMarshallerObjectInputStream.java:52)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
	at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
	at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
	at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
	at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
	at java.util.ArrayList.readObject(ArrayList.java:791)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
	at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
	at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
	at
org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal(JdkMarshaller.java:98)
	... 6 more




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-tp1931.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: CacheStore being serialized to client?

Posted by endian675 <en...@gmail.com>.
vkulichenko wrote
> Can you create a JIRA ticket and send a link to the dev@ list? I think it
> should be discussed in the community first.
> 
> -Val

I have created
http://apache-ignite-developers.2346864.n4.nabble.com/IGNITE-1903-CacheStore-implementation-is-serialised-to-grid-clients-whether-they-require-it-or-not-tc4811.html

Mike



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-tp1931p1957.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: CacheStore being serialized to client?

Posted by vkulichenko <va...@gmail.com>.
endian675 wrote
> I've now tried this with a non-Singleton class factory and still get the
> same error.  

You get an error because you don't have a class on the client node. With
ClassFactory it doesn't receive the store instance, but it still receives
corresponding Class object, therefore fails. I think the cleanest way to
solve it for now is to add store class on the client's classpath.

endian675 wrote
> Could we consider not sending the message to nodes in the topology if a)
> the cache is not TRANSACTIONAL and b) the node is clientMode=true ?

Can you create a JIRA ticket and send a link to the dev@ list? I think it
should be discussed in the community first.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-tp1931p1954.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: CacheStore being serialized to client?

Posted by endian675 <en...@gmail.com>.
I've now tried this with a non-Singleton class factory and still get the same
error.  

Could we consider not sending the message to nodes in the topology if a) the
cache is not TRANSACTIONAL and b) the node is clientMode=true ?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-tp1931p1946.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: CacheStore being serialized to client?

Posted by endian675 <en...@gmail.com>.
Thanks for your input, Val.  Now that I am back at the office, I can see that
I am already using a Factory:

<pre>
igniteConfiguration.setCacheStoreFactory(new
FactoryBuilder.SingletonFactory<>(this.cacheMissHandler));
</pre>

Obviously the problem is the SingletonFactory, as it will pass the instance
around the topology, and any client that doesn't have that class will throw
this de-serialization exception.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-tp1931p1941.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: CacheStore being serialized to client?

Posted by vkulichenko <va...@gmail.com>.
Hi,

Yes this is correct. The whole cache configuration is serialized and sent to
newly joined nodes (including clients). Also if you're using TRANSACTIONAL
cache, the store will be called on the client node to maintain DB
transaction along with the cache transaction.

Note that the configuration contains store factory, so the store itself
doesn't have to be serializable. For example, you can use ClassFactory to
avoid store serialization:

<bean class="org.apache.ignite.configuration.CacheConfiguration">
  <property name="cacheStoreFactory">
    <bean class="javax.cache.configuration.FactoryBuilder$ClassFactory">
      <constructor-arg
value="c.g.r.cachewrapper.ignite.CacheMissHandlerIgnite"/>
    </bean>
  </property>
</bean>

Makes sense?

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-tp1931p1934.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.