1
votes

I am using Apache Ignite 2.10.0, i want read/write through feature to load/write data into cache from and to the third party persistence, in order to do it i implemented PersonStore which extends CacheStoreAdapter class. I want my classes(PersonStore, pojo and others) to get auto deployed remotely to the Ignite server node from client node, to do this i enabled the peerClassLoading in CacheConfiguration, on starting server i see

java.lang.RuntimeException: Failed to create an instance of com.demoIgnite.adapter.PersonStore
        at javax.cache.configuration.FactoryBuilder$ClassFactory.create(FactoryBuilder.java:134)
        .....
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
        at java.lang.Thread.run(Thread.java:745) 
Caused by:java.lang.ClassNotFoundException: com.demoIgnite.adapter.PersonStore
        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 javax.cache.configuration.FactoryBuilder$ClassFactory.create(FactoryBuilder.java:130)

However, if i manually try to place the jar to the ignite libs it works absolutely fine. But via this approach i had to rebuild, replace and restart the Ignite server each time when there is a code modification which i wanted to avoid. I am new to Apache Ignite and after reading the ignite documents was assuming that this could be taken care automatically if peerClassLoading is enabled, please help me if i am missing something there. Also, please suggest me a way to make this automated.

My cache configuration:

CacheConfiguration<String, Person> cachecfg = new CacheConfiguration<String, Person>(); cachecfg.setName("person-store"); cachecfg.setCacheMode(CacheMode.PARTITIONED); cachecfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); cachecfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cachecfg.setReadThrough(true); cachecfg.setWriteThrough(true); cachecfg.setCacheStoreFactory(FactoryBuilder.factoryOf(PersonStore.class));

IgniteConfiguration :

IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName("my-ignite");
cfg.setClientMode(true); cfg.setPeerClassLoadingEnabled(true); cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); cfg.setCacheConfiguration(cacheCfg); TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder(); ipFinder.setAddresses(Collections.singletonList("127.0.0.1:10800")); cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));

1

1 Answers

1
votes

Cache stores and POJO classes cannot be peer loaded.

Peer loading is mostly for compute callables, services (event based mode), some listeners, etc.