问题描述
这是缓存的配置.我想启用writeThrough.为什么我遇到以下异常?未提供书写器或存储"是什么意思?
Here is the configuration for the cache. I want writeThrough to be enabled. why i got the below exception? what does "writer or store is not provided" mean?
配置:
<property name="cacheConfiguration">
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="txnCache"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<property name="writeThrough" value="true"/>
<property name="backups" value="1"/>
<!--property name="cacheMode" value="REPLICATED"/-->
<!-- <property name="atomicityMode" value="ATOMIC"/>
<property name="readFromBackup" value="true"/>
<property name="copyOnRead" value="true"/>-->
</bean>
</property>
错误:
[13:24:07,176][SEVERE][main][IgniteKernal] Got exception while starting (will rollback startup routine).
class org.apache.ignite.IgniteCheckedException: Cannot enable write-through (writer or store is not provided) for cache: txnCache
at org.apache.ignite.internal.processors.cache.GridCacheProcessor.validate(GridCacheProcessor.java:482)
at org.apache.ignite.internal.processors.cache.GridCacheProcessor.createCache(GridCacheProcessor.java:1462)
at org.apache.ignite.internal.processors.cache.GridCacheProcessor.onKernalStart(GridCacheProcessor.java:885)
at org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:1013)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start0(IgnitionEx.java:1895)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1647)
at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1075)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:573)
at org.apache.ignite.internal.processors.platform.PlatformAbstractBootstrap.start(PlatformAbstractBootstrap.java:48)
at org.apache.ignite.internal.processors.platform.PlatformIgnition.start(PlatformIgnition.java:76)
[13:24:07] Cancelled rebalancing from all nodes [topology=null]
[13:24:07] Cancelled rebalancing from all nodes [topology=null]
推荐答案
要配置直写,您需要实现CacheStore接口(或使用现有的接口之一)并设置CacheConfiguration的cacheStoreFactory以及CacheConfiguration的writeThrough属性,它将看起来像:
To configure write-through, you need to implement the CacheStore interface(or use one of the existing) and set cacheStoreFactory as well writeThrough property of CacheConfiguration, it will look like:
<bean id= "simpleDataSource" class="org.h2.jdbcx.JdbcDataSource"/>
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
...
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
...
<property name="writeThrough" value="true"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
<property name="dataSourceBean" value = "simpleDataSource" />
</bean>
</property>
</bean>
</list>
</property>
</bean>
以下是有关cacheStore和writeThrough的更多信息:
Here is more information about cacheStore and writeThrough:
https://apacheignite.readme.io/v2.0/docs/persistent-store#section-read-through-and-write-through
这意味着您没有在配置中提供存储.
It means that you didn't provide store in configuration.
这篇关于org.apache.ignite.IgniteCheckedException:无法启用直写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!