如何获取缓存数据Apache点燃

问题描述 投票:0回答:1

我是Apache点燃的新手。我正在尝试填充缓存并从缓存中读取。我创建了2个java项目,一个填充Apache点燃缓存,另一个打印缓存数据,但打印缓存项目给出错误。

这是我用来填充缓存的代码

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());
        }

    }


}

这是我用来打印缓存数据的代码

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();

这2个不同项目的代码和平,所以当1个第一个项目填充缓存时,我试图从另一个项目到达缓存,当我试图达到缓存数据时,发生下面的错误

从读取缓存并打印它的代码返回的错误

8月01日,2018年9:25:25 org.apache.ignite.logger.java.JavaLogger错误严重:无法启动管理器:GridManagerAdapter [enabled = true,name = oaiimanagers.discovery.GridDiscoveryManager] class org.apache.ignite .IgniteCheckedException:无法启动SPI:org.apache.ignite.internal.managers.GridManagerAdapter启动SPI:TcpDiscoverySpi [addrRslvr = null,sockTimeout = 5000,ackTimeout = 5000,reconCnt = 10,maxAckTimeout = 600000,forceSrvMode = false,clientReconnectDisabled = false] .startSpi(GridManagerAdapter.java:258)org.apache.inite.managers.discovery.GridDiscoveryManager.start(GridDiscoveryManager.java:660)org.apache.ignite.internal.IgniteKernal.startManager(IgniteKernal.java:1505) )org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:917)org.apache.inite.IgnitionEx $ IgniteNamedInstance.start0(IgnitionEx.java:1688)at org.apache.ignite.internal。 IgnitionEx $ IgniteNamedInstance.start(IgnitionEx.java:1547)at org.apache.ignite.internal.IgnitionEx.start0(Ign itionEx.java:1003)org.apache.ignite.IgnitionEx.start(IgnitionEx.java:534)org.apache.ignite.IgnitionEx.start(IgnitionEx.java:515)atg.apache.ignite .Ignition.start(Ignition.java:322)at test.App.main(App.java:76)引起:class org.apache.ignite.spi.IgniteSpiException:本地节点的marshaller与远程节点的marshaller不同(为了确保拓扑中的所有节点都具有相同的marshaller,在配置中显式配置marshaller)[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: org.apache.ignite上的0:0:1%lo,/ 127.0.0.1,/ 192.268.1.71],locNodeId = b41f0d09-5a7f-424b-b3b5-420a5e1acdf6,rmtNodeId = ff436f20-5d4b-477e-aade-837d59b1eaa7]。 org.apache.ignite.spi.disco上的spi.discovery.tcp.TcpDiscoverySpi.checkFailedError(TcpDiscoverySpi.java:1647) org.apache.ignite.spi.IgniteSpiThread.run上的very.tcp.ClientImpl $ MessageWorker.body(ClientImpl.java:1460)(IgniteSpiThread.java:62)

java apache ignite
1个回答
0
投票

引发者:class org.apache.ignite.spi.IgniteSpiException:本地节点的marshaller与远程节点的marshaller不同(为了确保拓扑中的所有节点都具有相同的编组器,在配置中显式配置marshaller)[locMarshaller = org.apache.ignite.internal .binary.BinaryMarshaller,rmtMarshaller = org.apache.ignite.marshaller.optimized.OptimizedMarshaller

看起来像在ignite.xml中你明确设置了marshaller。请检查xml配置文件中的<property name="marshaller">。您应该为群集中的所有节点配置相同的编组器,否则它们将无法通信。

© www.soinside.com 2019 - 2024. All rights reserved.