Я хочу использовать ignite в качестве api кеша, а также в качестве провайдера кеша Spring. Я запускаю следующую конфигурацию в файле ignite-config.xml, как показано ниже
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd"
>
<!-- <bean id="cacheIgniteBean" class="org.apache.ignite.IgniteSpringBean">
<property name="configuration"> -->
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="true"/>
<property name="igniteInstanceName" value="claimgrid"/>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="T_MST_TEUC_Q_PERCENTAGE"/>
<property name="cacheMode" value="REPLICATED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="partitionLossPolicy" value="READ_WRITE_SAFE"/>
<property name="backups" value="0"/>
<property name="groupName" value="masterData"/>
<property name="cacheStoreFactory">
<bean class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg value="com.mrm.access.benefits.ms.claim.cache.store.SequesterPercentageModelStore"/>
</bean>
</property>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
</bean>
</list>
</property>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>10.80.211.76</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
Я инициализирую узел зажигания, как показано ниже.
ApplicationContext context= SpringApplication.run(Application.class, args);
Ignite ignite=IgniteSpring.start("ignite-config.xml", context);
Узел запускается и работает. Сейчас я использую второй конфигурационный файл для Spring Cache Manager Spring-cache.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd"
>
<bean id="cacheManager" class="org.apache.ignite.cache.spring.SpringCacheManager">
<property name="igniteInstanceName" value="claimgrid" />
</bean>
<cache:annotation-driven/>
и я инициализирую этот файл, как показано ниже
Ignite ignite=Ignition.start("spring-cache.xml");
Я получаю следующее исключение
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to find configuration in: file:/E:/Workspace/ms.claim/spring-cache.xml
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:116)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:744)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:945)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:854)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:724)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:693)
at org.apache.ignite.Ignition.start(Ignition.java:352)
... 2 more
При отладке исходного кода воспламенения я обнаружил, что внутреннее воспламенение использует SpringHelper
для получения контекста приложения Spring, а затем пытается извлечь экземпляр IgniteConfiguration
в виде Spring-компонента, используя метод getBeansOfType()
в одном из классов и из там он не получает экземпляр конфигурации и выдает вышеупомянутое исключение.
Как упомянуто в документации Ignite, я использую то же свойство gridName
или instanceName
в SpringCacheManager
в spring-cache.xml
.
Может кто-нибудь проверить проблему? Также я не уверен, что следую правильному методу. Сначала я смотрю на узел воспламенения с ignite-config.xml
и IgniteSpring.start
, и как только узел работает, я инициализирую spring-cache.xml
с Ignition.start
, чтобы настроить Ignite
как SpringCacheManager
.