0
votes

I am new in Apache ignite. I am trying to populate cache and read from cache. I have created 2 java projects one populates Apache ignite caches and the other one print cached data however printing cache project gives error.

here is the code that I use to populate caches

public void run(String... arg0) throws Exception
{
    try (Ignite ignite = Ignition.start("ignite.xml"))
    {
        int iteration=0;

        while(true)
        {
            iteration++;
            IgniteCache<Object, Object> cache = ignite.getOrCreateCache("test cache " + iteration);
            System.out.println(""+100);
            System.out.println("Caching started for iteration " + iteration);
            printMemory();

            for (int i = 0; i < 100; i++)
            {
                cache.put(i, new CacheObject(i, "Cached integer " + i));
                System.out.println(i);
                Thread.sleep(100);

            }
            //cache.destroy();
            System.out.println("**************************************"+cache.size());
        }

    }


}

this is the code that I use to print cached data

Ignition.setClientMode(true);
    IgniteConfiguration cfg = new IgniteConfiguration();        
    cfg.setPeerClassLoadingEnabled(true);
    TcpDiscoveryMulticastIpFinder discoveryMulticastIpFinder = new TcpDiscoveryMulticastIpFinder();
    Set<String> set = new HashSet<>();

    set.add("serverhost:47500..47509");
    discoveryMulticastIpFinder.setAddresses(set);

    TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
    discoverySpi.setIpFinder(discoveryMulticastIpFinder);

    cfg.setDiscoverySpi(discoverySpi);

    cfg.setPeerClassLoadingEnabled(true);
    cfg.setIncludeEventTypes(EVTS_CACHE);
    Ignite ignite = Ignition.start(cfg);

    System.out.println("***************************************************\n"+ignite.cacheNames()+"\n****************************");
    CacheConfiguration<String, BinaryObject> cacheConfiguration = new CacheConfiguration<>(CACHE_NAME);
    IgniteCache<String, BinaryObject> cache = ignite.getOrCreateCache(cacheConfiguration).withKeepBinary();

this 2 peace of code in different project so while 1 first project populating cache, I am trying to reach the cache from another project the error below is occurred when I am trying to reach cached data

Error that returns from the code that reads cache and prints it

Aug 01, 2018 9:25:25 AM org.apache.ignite.logger.java.JavaLogger error SEVERE: Failed to start manager: GridManagerAdapter [enabled=true, name=o.a.i.i.managers.discovery.GridDiscoveryManager] class org.apache.ignite.IgniteCheckedException: Failed to start SPI: TcpDiscoverySpi [addrRslvr=null, sockTimeout=5000, ackTimeout=5000, reconCnt=10, maxAckTimeout=600000, forceSrvMode=false, clientReconnectDisabled=false] at org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:258) at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.start(GridDiscoveryManager.java:660) at org.apache.ignite.internal.IgniteKernal.startManager(IgniteKernal.java:1505) at org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:917) at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start0(IgnitionEx.java:1688) at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1547) at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1003) at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:534) at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:515) at org.apache.ignite.Ignition.start(Ignition.java:322) at test.App.main(App.java:76) Caused by: class org.apache.ignite.spi.IgniteSpiException: Local node's marshaller differs from remote node's marshaller (to make sure all nodes in topology have identical marshaller, configure marshaller explicitly in configuration) [locMarshaller=org.apache.ignite.internal.binary.BinaryMarshaller, rmtMarshaller=org.apache.ignite.marshaller.optimized.OptimizedMarshaller, locNodeAddrs=[192.168.1.71/0:0:0:0:0:0:0:1%lo, /127.0.0.1, /192.168.1.71], locPort=0, rmtNodeAddr=[192.168.1.71/0:0:0:0:0:0:0:1%lo, /127.0.0.1, /192.168.1.71], locNodeId=b41f0d09-5a7f-424b-b3b5-420a5e1acdf6, rmtNodeId=ff436f20-5d4b-477e-aade-837d59b1eaa7] at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.checkFailedError(TcpDiscoverySpi.java:1647) at org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.body(ClientImpl.java:1460) at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)

1

1 Answers

0
votes

Caused by: class org.apache.ignite.spi.IgniteSpiException: Local node's marshaller differs from remote node's marshaller (to make sure all nodes in topology have identical marshaller, configure marshaller explicitly in configuration) [locMarshaller=org.apache.ignite.internal.binary.BinaryMarshaller, rmtMarshaller=org.apache.ignite.marshaller.optimized.OptimizedMarshaller

Looks like in ignite.xml you've explicitly set marshaller. Please check <property name="marshaller"> in xml config file. You should have the same marshaller configured for all nodes in the cluster, or they won't be able to communicate.