我是Apache ignite的新手。我正在尝试填充缓存并从缓存中读取。我创建了2个Java项目,其中一个填充Apache ignite缓存,另一个填充打印的数据,但是打印缓存项目给出了错误。
这是我用来填充缓存的代码
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个代码在不同项目中的和平度,因此当第一个项目填充缓存时,我试图从另一个项目访问缓存 当我尝试访问缓存的数据
时,发生以下错误从读取并打印缓存的代码返回的错误
2018年8月1日上午9:25:25 org.apache.ignite.logger.java.JavaLogger错误 严重:无法启动管理器:GridManagerAdapter [enabled = true,name = o.a.i.i.managers.discovery.GridDiscoveryManager] org.apache.ignite.IgniteCheckedException类:无法启动SPI:TcpDiscoverySpi [addrRslvr = null,sockTimeout = 5000,ackTimeout = 5000,reconCnt = 10,maxAckTimeout = 600000,forceSrvMode = false,clientReconnectDisabled = false] 在org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:258) 在org.apache.ignite.internal.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.ignite.internal.IgnitionEx $ IgniteNamedInstance.start0(IgnitionEx.java:1688) 在org.apache.ignite.internal.IgnitionEx $ IgniteNamedInstance.start(IgnitionEx.java:1547) 在org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1003) 在org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:534) 在org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:515) 在org.apache.ignite.Ignition.start(Ignition.java:322) 在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: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] 在org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.checkFailedError(TcpDiscoverySpi.java:1647) 在org.apache.ignite.spi.discovery.tcp.ClientImpl $ MessageWorker.body(ClientImpl.java:1460) 在org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
答案 0 :(得分:0)
由以下原因导致:类org.apache.ignite.spi.IgniteSpiException:本地节点的编组器与远程节点的编组器不同(为确保拓扑中的所有节点都具有相同的编组器,请在配置中显式配置编组器)[locMarshaller = org.apache。 ignite.internal.binary.BinaryMarshaller,rmtMarshaller = org.apache.ignite.marshaller.optimized.OptimizedMarshaller
就像在ignite.xml中,您已经明确设置了marshaller。请检查xml配置文件中的<property name="marshaller">
。您应该为集群中的所有节点配置相同的编组器,否则它们将无法通信。