Cache loader factory with peer class enabled mode

classic Classic list List threaded Threaded
4 messages Options
Fitzgerald Fitzgerald
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cache loader factory with peer class enabled mode

This post has NOT been accepted by the mailing list yet.
This post was updated on .
I have started ignite server with default configuration, only "peerClassLoadingEnabled" is different which is set to "true" because I don't want to deploy my jars in server too......

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="peerClassLoadingEnabled" value="true"/>
    </bean>

</beans>

......Also I have one client which uses "read-through" caching mechanism, so I have set cache loader factory in cache configuration.Client is like this...

public class CustomCacheLoaderFactory
                implements Factory<CustomLoader> {

        private static final long serialVersionUID = 7993486374740146730L;

        public CustomLoader create() {
                return new CustomLoader();
        }
}

public class CustomLoader implements CacheLoader<String, String>{

        public String load(String key) throws CacheLoaderException {
                return "asdasd";
        }

        public Map<String, String> loadAll(Iterable<? extends String> iterable) throws CacheLoaderException {
                throw new UnsupportedOperationException();
        }
}


@SpringBootApplication
public class IgniteBootClientApplication implements CommandLineRunner{

        public static void main(String[] args) {
                SpringApplication.run(IgniteBootClientApplication.class, args);
        }

        @Override
        public void run(String... strings) throws Exception {
                IgniteConfiguration cfg = new IgniteConfiguration();
                cfg.setPeerClassLoadingEnabled(true);
                Ignition.setClientMode(true);
                Ignite ignite = Ignition.start(cfg);
                IgniteCache<String, String> cache = ignite.getOrCreateCache(new CacheConfiguration<String, String>()
                                .setName("test-cache").setCacheLoaderFactory(new CustomCacheLoaderFactory()).setReadThrough(true));
                System.out.println(cache.get("Aasd"));
        }
}

......After I'm starting client, following exception occurs in server...

[12:46:06] Topology snapshot [ver=2, servers=1, clients=1, CPUs=8, heap=7.1GB]
Jul 11, 2017 12:46:06 PM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Failed to unmarshal discovery custom message.
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) [clsLdr=sun.misc.Launcher$AppClassLoader@18b4aac2, cls=com.examples.ignite.CustomCacheLoaderFactory]
        at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:123)
        at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:94)
        at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:142)
        at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
        at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9887)
        at org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage.message(TcpDiscoveryCustomEventMessage.java:81)
        at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:5331)
        at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processCustomMessage(ServerImpl.java:5152)
        at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2571)
        at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2364)
        at org.apache.ignite.spi.discovery.tcp.ServerImpl$MessageWorkerAdapter.body(ServerImpl.java:6460)
        at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2450)
        at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.lang.ClassNotFoundException: com.examples.ignite.CustomCacheLoaderFactory
        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:8478)
        at org.apache.ignite.marshaller.jdk.JdkMarshallerObjectInputStream.resolveClass(JdkMarshallerObjectInputStream.java:54)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1819)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1713)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1986)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
        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:498)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2122)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
        at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:120)
        ... 12 more

...As you can see from Topology snapshot it looks like client connects to server and disconnects immediately. Also after before-mentioned exception, in client appears log telling "Failed to wait for partition map exchange".

Have I configured something wrong?Shouldn't the peer-class-loading resolve the issue?Why it's trying to unmarshall factory?

Ignite version is 2.0.0.

Thanks for advance.

dkarachentsev dkarachentsev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cache loader factory with peer class enabled mode

Hi,

Peer class loading was designed for compute tasks deployment, it's not applicable for configuration classes or cache entries. So you have to copy that classes to all nodes.

Thanks!
-Dmitry.
daniels daniels
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cache loader factory with peer class enabled mode

Thank you! I use the caching of ignite with cacheLoaderFactories. And  I met the perrClassLoading problem. Now i want not to use cacheLoaderFactories.What methods will you offer to replace them so that there doesn't come the problem of peerclasLoading?
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cache loader factory with peer class enabled mode

Loading...