【发布时间】:2012-08-18 18:01:16
【问题描述】:
我们在 WebLogic Server 10.3.4 上运行 Spring 3.0.5 Web 应用程序
Solaris with Sun JVM 1.6.0_x 64bit 使用 EhCache 2.4.2 作为缓存
图书馆。 WLS 设置为具有 2 个节点的集群,两个节点都在
同一台物理机,通过标准启动
startManagedWebLogic.sh 脚本(不使用 NodeManager / 管理控制台)。
在我们的ehcache.xml 中,我们将磁盘存储路径设置为:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<!-- Location of persistent caches on disk -->
<diskStore path="ehcache.disk.store.dir" />
..
根据the 2.4 series documentation of EhCache 此设置允许设置 JVM 系统属性,以便 指定磁盘存储路径。
系统属性在startManagedWebLogic.sh 中使用
标准JAVA_OPTIONS元素:
JAVA_OPTIONS="-Dehcache.disk.store.dir=/var/tmp/EhCache-${SERVER_NAME} <other stuff>"
export JAVA_OPTIONS
SERVER_NAME 在之前的同一脚本中定义
选项。
在集群节点启动期间,我可以看到正在设置的属性 正确(包装以提高可读性):
/usr/jdk/jdk1.6.0_21/bin/java -d64 -server -Xms4096m -Xmx4096m
-XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseParallelOldGC
-verbose:gc -XX:+PrintGCTimeStamps -Dweblogic.Name=Node2 [..]
-Dehcache.disk.store.dir=/var/tmp/EhCache-Node2 [..]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
weblogic.Server
但是,然后使用应用程序,我可以看到占位符是 没有正确替换,因此使用占位符名称而不是 实际路径设置:
2012-08-22 11:52:59,426 DEBUG [net.sf.ehcache.CacheManager] - [Creating new CacheManager with default config]
2012-08-22 11:52:59,429 DEBUG [net.sf.ehcache.CacheManager] - [Configuring ehcache from classpath.]
..
2012-08-22 11:52:59,458 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] - [Disk Store Path: ehcache.disk.store.dir]
..
2012-08-22 11:52:59,586 DEBUG [net.sf.ehcache.store.DiskStore] - [IOException reading index. Creating new index. ]
2012-08-22 11:52:59,587 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file ehcache.disk.store.dir/bookmarksCountForUserCache.index deleted.]
2012-08-22 11:52:59,588 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file ehcache.disk.store.dir/bookmarksCountForUserCache.index created successfully]
2012-08-22 11:52:59,588 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file dirty or empty. Deleting data file bookmarksCountForUserCache.data]
2012-08-22 11:52:59,597 DEBUG [net.sf.ehcache.store.MemoryStore] - [Initialized net.sf.ehcache.store.LruMemoryStore for bookmarksCountForUserCache]
2012-08-22 11:52:59,600 DEBUG [net.sf.ehcache.store.LruMemoryStore] - [bookmarksCountForUserCache Cache: Using SpoolingLinkedHashMap implementation]
2012-08-22 11:52:59,601 DEBUG [net.sf.ehcache.Cache] - [Initialised cache: bookmarksCountForUserCache]
在我的 WLS 域内的文件系统中,我可以看到一个新文件夹
ehcache.disk.store.dir 已创建,因此路径被解释为
相对路径。
我也尝试过,而不是使用纯字符串ehcache.disk.store.dir
使用标准模式${ehcache.disk.store.dir},但这只是
将要创建的文件夹名称更改为${..}。
有没有办法使用系统指定每个节点的磁盘存储路径 所有节点的属性和相同的 EhCache 配置?
我们的ehcache.xml 位于已部署的 .war 文件中,因此将
所有集群节点都相同。更改应用程序代码不是一种选择,因为我们已经结束了此版本的代码冻结。不过,我可以调整服务器的启动设置来设置系统属性,如上所述。
感谢您的帮助!
【问题讨论】:
标签: java caching weblogic ehcache disk