首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取缓存数据Apache点燃

如何获取缓存数据Apache点燃
EN

Stack Overflow用户
提问于 2018-08-01 09:04:32
回答 1查看 1K关注 0票数 0

我是阿帕奇的新手。我正在尝试填充缓存并从缓存中读取。我已经创建了2个java项目,一个填充了Apache缓存,另一个创建了打印缓存数据,但是,打印缓存项目会出错。

下面是我用来填充缓存的代码

代码语言:javascript
复制
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());
        }

    }


}

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

代码语言:javascript
复制
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种不同项目中的代码和平,所以当第一个项目填充缓存时,我试图从另一个项目到达缓存,当我试图访问缓存数据时,出现了下面的错误。

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

2018年8月1日9:25:25 AM org.apache.ignite.logger.java.JavaLogger错误严重:启动管理失败: GridManagerAdapter enabled=true,org.apache.ignite.IgniteCheckedException类:未能启动SPI: TcpDiscoverySpi addrRslvr=null,sockTimeout=5000,ackTimeout=5000,reconCnt=10,maxAckTimeout=600000,forceSrvMode=false,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)在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)由:类org.apache.ignite.spi.IgniteSpiException引起的:本地节点的封送处理程序与远程节点的封送器不同(为了确保拓扑中的所有节点都具有相同的封送处理程序,( [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:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0%lo,/127.0.0.1,/192.168.1.71,locPort=0,rmtNodeAddr=192.168.1.71/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)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-01 09:15:36

由:类org.apache.ignite.spi.IgniteSpiException引起的:本地节点的封送器与远程节点的封送器不同(为了确保拓扑中的所有节点具有相同的封送处理程序,请在配置中显式配置封送封送器)

在ignite.xml中,您已经显式地设置了封送器。请在xml配置文件中检查<property name="marshaller">。您应该为集群中的所有节点配置相同的封送处理程序,否则它们将无法通信。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51629327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档