org.apache.ignite.IgniteCheckedException: Cannot enable write-through

放肆的年华 提交于 2019-12-12 03:27:17

问题


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?

Configuration:

<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>

Error:

[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]

回答1:


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>

Here is more information about cacheStore and writeThrough:

https://apacheignite.readme.io/v2.0/docs/persistent-store#section-read-through-and-write-through

what does "writer or store is not provided" mean?

It means that you didn't provide store in configuration.



来源:https://stackoverflow.com/questions/44819513/org-apache-ignite-ignitecheckedexception-cannot-enable-write-through

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!