GAE是否支持EHCache的write-behind操作?
Is GAE Supports EHCache's Write-Behind Operation?
我正在尝试创建一个使用 ehcache 来存储和检索数据的 Web 应用程序。对我来说,以下配置对我来说工作正常。
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
memoryStoreEvictionPolicy="LRU">
<!-- <persistence strategy="none"/> -->
</defaultCache>
<cache name="st"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
但是引入write-behind操作后,出现如下错误
配置:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
memoryStoreEvictionPolicy="LRU">
<!-- <persistence strategy="none"/> -->
</defaultCache>
<cache name="st"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU"
>
<!-- <persistence strategy="none"/> -->
<cacheWriter writeMode="write-behind" maxWriteDelay="8" rateLimitPerSecond="5"
writeCoalescing="true" writeBatching="true" writeBatchSize="20"
retryAttempts="2" retryAttemptDelaySeconds="2">
<cacheWriterFactory class="com.gowtham.st.shared.STWriterFactory" />
</cacheWriter>
</cache>
</ehcache>
错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sT' defined in file [/base/data/home/apps/s~google-test-40392/1.383872259417297841/WEB-INF/classes/com/gowtham/st/server/ST.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.gowtham.st.server.ST]: Constructor threw exception; nested exception is java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
还有其他方法可以实现吗?
由于 Ehcache write-behind 直接使用线程,您将无法使其在开箱即用的 GAE 上运行。需要开发将线程的创建抽象出来,然后提供一个GAE集成模块。
我正在尝试创建一个使用 ehcache 来存储和检索数据的 Web 应用程序。对我来说,以下配置对我来说工作正常。
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
memoryStoreEvictionPolicy="LRU">
<!-- <persistence strategy="none"/> -->
</defaultCache>
<cache name="st"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
但是引入write-behind操作后,出现如下错误
配置:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
memoryStoreEvictionPolicy="LRU">
<!-- <persistence strategy="none"/> -->
</defaultCache>
<cache name="st"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU"
>
<!-- <persistence strategy="none"/> -->
<cacheWriter writeMode="write-behind" maxWriteDelay="8" rateLimitPerSecond="5"
writeCoalescing="true" writeBatching="true" writeBatchSize="20"
retryAttempts="2" retryAttemptDelaySeconds="2">
<cacheWriterFactory class="com.gowtham.st.shared.STWriterFactory" />
</cacheWriter>
</cache>
</ehcache>
错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sT' defined in file [/base/data/home/apps/s~google-test-40392/1.383872259417297841/WEB-INF/classes/com/gowtham/st/server/ST.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.gowtham.st.server.ST]: Constructor threw exception; nested exception is java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
还有其他方法可以实现吗?
由于 Ehcache write-behind 直接使用线程,您将无法使其在开箱即用的 GAE 上运行。需要开发将线程的创建抽象出来,然后提供一个GAE集成模块。