我是Apache Ignite的新手,我正在尝试使用FileSystem功能。
当我使用XML配置文件时,一切正常,但是当将conf转换为JAVA时,我得到了这个错误:
Exception in thread "main" class org.apache.ignite.igfs.IgfsException: Failed to execute operation because there are no IGFS metadata nodes. at org.apache.ignite.internal.processors.igfs.IgfsMetaManager.runClientTask(IgfsMetaManager.java:254) at org.apache.ignite.internal.processors.igfs.IgfsImpl.mkdirs(IgfsImpl.java:757) at org.apache.ignite.internal.processors.igfs.IgfsImpl.mkdirs(IgfsImpl.java:749) at com.test.IgniteCacheClass.main(IgniteCacheClass.java:171) Caused by: class org.apache.ignite.cluster.ClusterGroupEmptyException: Cluster group is empty. at org.apache.ignite.internal.util.IgniteUtils$5.apply(IgniteUtils.java:765) at org.apache.ignite.internal.util.IgniteUtils$5.apply(IgniteUtils.java:763) at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:903) at org.apache.ignite.internal.IgniteComputeImpl.call(IgniteComputeImpl.java:355) at org.apache.ignite.internal.processors.igfs.IgfsMetaManager.runClientTask(IgfsMetaManager.java:251) ... 3 more Caused by: class org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException: Cluster group is empty. at org.apache.ignite.internal.util.IgniteUtils.emptyTopologyException(IgniteUtils.java:4621) at org.apache.ignite.internal.processors.closure.GridClosureProcessor.callAsync(GridClosureProcessor.java:584) at org.apache.ignite.internal.processors.closure.GridClosureProcessor.callAsync(GridClosureProcessor.java:428) at org.apache.ignite.internal.IgniteComputeImpl.call(IgniteComputeImpl.java:352) ... 4 more
我在写作时找到了解决方案,但我有另一个问题。它没有用,因为我用客户端模式启动它(显然......)。但是使用XML,没有明确设置客户端模式,我将创建一个Ignite服务器节点。
所以,现在我决定成为该服务器节点的客户端,但我不想再次设置所有参数。例如,只提供元数据和数据缓存名称以及FileSystem名称,是否有一种连接方式?如果我将conf作为二进制对象存储(如果它有效......),你会发现它很脏吗?
如果有人可以就此话题提出建议,我会很高兴:)
祝你好运
答案 0 :(得分:0)
晚上好,谢谢你的快速回复。
正如我所说,我在配置中发现了一个错误(我认为)。如果需要,我把所有相同的boh配置。我以节点作为客户端启动,但似乎首先作为服务器运行。
你知道为什么我现在需要在作为客户端连接时再次提供所有配置吗?在作为客户连接时,有没有办法放弃整个conf?
XML配置
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Ignite Spring configuration file to startup ignite cache.
When starting a standalone node, you need to execute the following command:
{IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-igfs.xml
When starting Ignite from Java IDE, pass path to this file into Ignition:
Ignition.start("examples/config/filesystem/example-igfs.xml");
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--
Optional description.
-->
<description>
Spring file for ignite configuration with client available endpoints.
</description>
<!--
Initialize property configurer so we can reference environment variables.
-->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
<property name="searchSystemEnvironment" value="true"/>
</bean>
<!--
Configuration below demonstrates how to setup a IgniteFs node with file data.
-->
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="fileSystemConfiguration">
<list>
<bean class="org.apache.ignite.configuration.FileSystemConfiguration">
<property name="name" value="igfs"/>
<property name="metaCacheName" value="igfs-meta"/>
<property name="dataCacheName" value="igfs-data"/>
<!-- Must correlate with cache affinity mapper. -->
<property name="blockSize" value="#{128 * 1024}"/>
<property name="perNodeBatchSize" value="512"/>
<property name="perNodeParallelBatchCount" value="16"/>
<!-- Set number of prefetch blocks. -->
<property name="prefetchBlocks" value="32"/>
<!--
Example of configured IPC loopback endpoint.
-->
<!--
<property name="ipcEndpointConfiguration">
<bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
<property name="type" value="TCP" />
</bean>
</property>
-->
<!--
Example of configured shared memory endpoint.
-->
<!--
<property name="ipcEndpointConfiguration">
<bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
<property name="type" value="SHMEM" />
</bean>
</property>
-->
</bean>
</list>
</property>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="igfs-data"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<property name="backups" value="0"/>
<property name="affinityMapper">
<bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper">
<!-- Haw many blocks in row will be stored on the same node. -->
<constructor-arg value="512"/>
</bean>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="igfs-meta"/>
<property name="cacheMode" value="REPLICATED"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
</bean>
</list>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignition provides several options for automatic discovery that can be used
instead os static IP based discovery. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
Java配置
IgniteConfiguration config = new IgniteConfiguration();
FileSystemConfiguration fsConfig = new FileSystemConfiguration();
fsConfig.setName("igfs");
fsConfig.setMetaCacheName("igfs-meta");
fsConfig.setDataCacheName("igfs-data");
fsConfig.setBlockSize(128 * 1024);
fsConfig.setPerNodeBatchSize(512);
fsConfig.setPerNodeParallelBatchCount(16);
fsConfig.setPrefetchBlocks(32);
CacheConfiguration fsDataCache = new CacheConfiguration();
fsDataCache.setName("igfs-data");
fsDataCache.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
fsDataCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
fsDataCache.setBackups(0);
fsDataCache.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(512));
CacheConfiguration fsMetadataCache = new CacheConfiguration();
fsMetadataCache.setCacheMode(CacheMode.REPLICATED);
fsMetadataCache.setName("igfs-meta");
fsMetadataCache.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
fsMetadataCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
config = new IgniteConfiguration();
config.setClientMode(true);
config.setWorkDirectory("c:/temp/ignite/instance");
config.setFileSystemConfiguration(fsConfig);
config.setCacheConfiguration(fsDataCache, fsMetadataCache);
TcpDiscoverySpi discoverySpi=new TcpDiscoverySpi();
discoverySpi.setLocalPort(47506);
discoverySpi.setLocalPortRange(20);
TcpDiscoveryVmIpFinder ipFinder=new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
discoverySpi.setIpFinder(ipFinder);
config.setDiscoverySpi(discoverySpi);
Ignite ignite = Ignition.start(config);
再次感谢您
答案 1 :(得分:0)
目前无法设置缓存名称和IGFS名称。您必须为客户端节点提供完整配置。我们将来会对此进行一些改进,但我怀疑我们能够将配置简化为几个字符串,因为客户端与底层文件系统进行通信,因此我们必须保留一些配置。
弗拉基米尔。
答案 2 :(得分:0)
对于那些对此感兴趣的人,我提出了一些代码,以使客户更容易。
对于服务器
IgniteConfiguration configBin = new IgniteConfiguration();
CacheConfiguration cacheConfig = new CacheConfiguration();
configBin.setCacheConfiguration(cacheConfig);
Ignite igniteFSCache = Ignition.start(configBin);
IgniteCache<String, Object> binaryCache = igniteFSCache.getOrCreateCache("confCache").withKeepBinary();
FileSystemConfiguration fsConfig = new FileSystemConfiguration();
fsConfig.setName("igfs");
fsConfig.setMetaCacheName("igfs-meta");
fsConfig.setDataCacheName("igfs-data");
fsConfig.setBlockSize(128 * 1024);
fsConfig.setPerNodeBatchSize(512);
fsConfig.setPerNodeParallelBatchCount(16);
fsConfig.setPrefetchBlocks(32);
binaryCache.put("fsConfig", fsConfig);
CacheConfiguration fsDataCache = new CacheConfiguration();
fsDataCache.setName("igfs-data");
fsDataCache.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
fsDataCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
fsDataCache.setBackups(0);
fsDataCache.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(512));
binaryCache.put("fsDataCache", fsDataCache);
CacheConfiguration fsMetadataCache = new CacheConfiguration();
fsMetadataCache.setCacheMode(CacheMode.REPLICATED);
fsMetadataCache.setName("igfs-meta");
fsMetadataCache.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
fsMetadataCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
binaryCache.put("fsMetadataCache", fsMetadataCache);
IgniteConfiguration config = new IgniteConfiguration();
config.setWorkDirectory("c:/temp/ignite/instance");
config.setFileSystemConfiguration(fsConfig);
config.setCacheConfiguration(fsDataCache, fsMetadataCache);
config.setGridName("CacheGrid");
TcpDiscoverySpi discoverySpi=new TcpDiscoverySpi();
discoverySpi.setLocalPort(47506);
discoverySpi.setLocalPortRange(20);
TcpDiscoveryVmIpFinder ipFinder=new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
discoverySpi.setIpFinder(ipFinder);
config.setDiscoverySpi(discoverySpi);
Ignite ignite = Ignition.getOrStart(config);
对于客户
IgniteConfiguration configBin = new IgniteConfiguration();
configBin.setClientMode(true);
Ignite igniteFSCache = Ignition.start(configBin);
IgniteCache<String, Object> binaryCache = igniteFSCache.getOrCreateCache("confCache").withKeepBinary();
BinaryObject fsConfig = (BinaryObject)binaryCache.get("fsConfig");
FileSystemConfiguration fsConf = (FileSystemConfiguration)fsConfig.deserialize();
CacheConfiguration fsDataCache = (CacheConfiguration)binaryCache.get("fsDataCache");
CacheConfiguration fsMetadataCache = (CacheConfiguration)binaryCache.get("fsMetadataCache");
IgniteConfiguration config = new IgniteConfiguration();
config.setWorkDirectory("c:/temp/ignite/instance");
config.setFileSystemConfiguration(fsConf);
config.setCacheConfiguration(fsDataCache, fsMetadataCache);
config.setGridName("CacheGrid");
config.setClientMode(true);
Ignite ignite = Ignition.getOrStart(config);
祝你好运