Coherence中的事务缓存

时间:2014-07-30 15:54:29

标签: caching distributed-caching oracle-coherence

我正在尝试在Coherence中设置事务缓存,但在尝试创建连接时遇到以下问题(根据文档中的示例):

java.lang.IllegalStateException: Service "TransactionalCache" has been started with a non-compatible BackingMapManager: com.tangosol.coherence.transaction.internal.TxConfigurableCacheFactory$Manager@30d73d83
        at com.tangosol.net.ExtensibleConfigurableCacheFactory.validateBackingMapManager(ExtensibleConfigurableCacheFactory.java:806)
        at com.tangosol.net.ExtensibleConfigurableCacheFactory.ensureService(ExtensibleConfigurableCacheFactory.java:585)
        at com.tangosol.net.ExtensibleConfigurableCacheFactory.ensureService(ExtensibleConfigurableCacheFactory.java:317)
        at com.tangosol.coherence.transaction.internal.ConfigHelper.getTransactionalService(ConfigHelper.java:136)
        at com.tangosol.coherence.transaction.internal.ConfigHelper.ensureTransactionalService(ConfigHelper.java:328)
        at com.tangosol.coherence.transaction.DefaultConnectionFactory.createConnection(DefaultConnectionFactory.java:41)

这是我的cache-config:

<caching-scheme-mapping>
      <cache-mapping>
         <cache-name>testCache</cache-name>
         <scheme-name>testScheme</scheme-name>
      </cache-mapping>
   </caching-scheme-mapping>

   <caching-schemes>
      <transactional-scheme>
         <scheme-name>testScheme</scheme-name>
         <!--<service-name>TransactionalCache</service-name>-->
         <partition-count>2039</partition-count>
         <backup-count>1</backup-count>
         <autostart>true</autostart>
      </transactional-scheme>
   </caching-schemes>

我使用CacheFactory.setConfigurableCacheFactory(new DefaultConfigurableCacheFactory(configFile))加载此配置,然后调用CacheFactory.getCache("testCache"),我也试图创建DefaultConfigurableCacheFactory并使用ensureCache获取缓存,但没有运气

我做错了什么?

编辑:我尝试使用

设置配置

System.setProperty("tangosol.coherence.cacheconfig", configFile);

现在我可以创建连接,检索OptimisticNamedCache但是当我尝试执行put()(使用autocommit = false)时,我会收到另一个异常:

java.lang.RuntimeException: java.lang.NullPointerException
        at com.tangosol.coherence.transaction.internal.router.LocalDirector.checkForException(LocalDirector.java:106)
        at com.tangosol.coherence.transaction.internal.router.LocalDirector.route(LocalDirector.java:59)
        at com.tangosol.coherence.transaction.internal.Endpoint.dispatch(Endpoint.java:105)
        at com.tangosol.coherence.transaction.internal.OptimisticNamedCacheImpl.invoke(OptimisticNamedCacheImpl.java:711)
        at com.tangosol.coherence.transaction.internal.OptimisticNamedCacheImpl.put(OptimisticNamedCacheImpl.java:370)
Caused by: java.lang.NullPointerException
        at com.tangosol.coherence.transaction.internal.storage.LockManager.unlock(LockManager.java:68)
        at com.tangosol.coherence.transaction.internal.component.StorageUnlock.invoke(StorageUnlock.java:46)
        at com.tangosol.coherence.transaction.internal.component.CompositeComponent.invoke(CompositeComponent.java:77)
        at com.tangosol.coherence.transaction.internal.Endpoint.dispatch(Endpoint.java:95)
        at com.tangosol.coherence.transaction.internal.router.StaticEndpointConcern.apply(StaticEndpointConcern.java:48)
        at com.tangosol.coherence.transaction.internal.router.OperationFilter.apply(OperationFilter.java:51)
        at com.tangosol.coherence.transaction.internal.router.OutboundRouterImpl.route(OutboundRouterImpl.java:36)
        at com.tangosol.coherence.transaction.internal.Endpoint.dispatch(Endpoint.java:105)
        at com.tangosol.coherence.transaction.internal.router.StaticEndpointConcern.apply(StaticEndpointConcern.java:48)
        at com.tangosol.coherence.transaction.internal.router.OperationFilter.apply(OperationFilter.java:51)
        at com.tangosol.coherence.transaction.internal.router.OutboundRouterImpl.route(OutboundRouterImpl.java:36)
        at com.tangosol.coherence.transaction.internal.Endpoint.dispatch(Endpoint.java:105)
        at com.tangosol.coherence.transaction.internal.router.AbstractProcessor.doProcess(AbstractProcessor.java:119)
        at com.tangosol.coherence.transaction.internal.router.CoherenceProcessor.processAll(CoherenceProcessor.java:76)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.invokeAll(PartitionedCache.CDB:35)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onInvokeAllRequest(PartitionedCache.CDB:90)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$InvokeAllRequest.run(PartitionedCache.CDB:1)
        at com.tangosol.coherence.component.util.DaemonPool.add(DaemonPool.CDB:20)
        at com.tangosol.coherence.component.util.DaemonPool.add(DaemonPool.CDB:1)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$InvokeAllRequest.onReceived(PartitionedCache.CDB:8)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:38)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:23)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
        at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:51)
        at java.lang.Thread.run(Thread.java:724)

EDIT2 :除此之外,还有一件奇怪的事情:当我尝试使用CacheFactory.getCache()CacheFactory.releaseCache()发布原始(非tx)缓存时,我得到了这个例外:

java.lang.IllegalArgumentException: The cache testCache was created using a different factory; that same factory should be used to release the cache.
     at com.tangosol.net.ExtensibleConfigurableCacheFactory.releaseCache(ExtensibleConfigurableCacheFactory.java:1013)
     at com.tangosol.net.ExtensibleConfigurableCacheFactory.releaseCache(ExtensibleConfigurableCacheFactory.java:288)
     at com.tangosol.net.CacheFactory.releaseCache(CacheFactory.java:486)
     at org.radargun.service.Coherence3Service.releaseCache(Coherence3Service.java:118)
     at org.radargun.service.Coherence3Service.stop(Coherence3Service.java:129)
     at org.radargun.stages.lifecycle.LifecycleHelper.stop(LifecycleHelper.java:133)
     at org.radargun.stages.ScenarioCleanupStage.executeOnSlave(ScenarioCleanupStage.java:36)
     at org.radargun.Slave.run(Slave.java:97)
     at org.radargun.Slave.main(Slave.java:157)

0 个答案:

没有答案