org.apache.ignite.IgniteCheckedException:无法启用直写

时间:2017-06-29 08:03:54

标签: spring ignite

以下是缓存的配置。我想要writeThrough启用。为什么我得到以下例外?什么"作家或商店没有提供"意思?

配置:

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

1 个答案:

答案 0 :(得分:3)

要配置直写,您需要实现CacheStore接口(或使用现有的一个)并设置cacheStoreFactory以及CacheConfiguration的writeThrough属性,它将如下所示:

<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的更多信息:

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

  

&#34;未提供作家或商店&#34;意思?

这意味着您没有在配置中提供商店。