简体   繁体   English

重新部署时不要在WildFly(jBoss)中停止Infinispan缓存容器

[英]Don's stop Infinispan cache containers in WildFly (jBoss) on redeploy

I use WildFly 8.2 with Immutant 2.1 (application is in Clojure) 我将WildFly 8.2与Immutant 2.1结合使用(应用程序在Clojure中)

Every time I redeploy my application in WildFly cluster, its Infinispan Web cache container is restarted, and all users sessions are lost. 每次我在WildFly群集中重新部署应用程序时,它的Infinispan Web缓存容器都会重新启动,并且所有用户会话都会丢失。

Is it possible to not restart the cache container, or flush data to disk before redeploy? 重新部署之前是否可以不重新启动缓存容器或将数据刷新到磁盘?

Thanks in advance 提前致谢

UPD: Thanks to sprockets answer, I could find configuration for web container that would do what I needed: UPD:多亏了链轮的回答,我可以找到满足我需要的Web容器配置:

<cache-container name="web" default-cache="repl" module="org.wildfly.clustering.web.infinispan" aliases="standard-session-cache">
    <transport lock-timeout="60000"/>
    <replicated-cache name="repl" batching="true" mode="ASYNC">
       <file-store preload="true" passivation="false" purge="false" relative-to="jboss.home.dir" path="infinispan-file-store">
          <write-behind/>
       </file-store>
    </replicated-cache>
</cache-container>

Problem is that web container is very picky about its configuration and throws not very informative exceptions if you use incompatible settings. 问题在于,Web容器对其配置非常挑剔,如果使用不兼容的设置,则不会引发非常有用的异常。 So basically, you only need to add 所以基本上,您只需要添加

<file-store preload="true" passivation="false" purge="false" relative-to="jboss.home.dir" path="infinispan-file-store">
  <write-behind/>
</file-store>

To container configuration. 进行容器配置。

Ifninispan provides cache passivation and cache activation to do this: https://docs.jboss.org/author/display/ISPN/Cache+Loaders+and+Stores#CacheLoadersandStores-CachePassivation Ifninispan提供了缓存钝化和缓存激活来执行此操作: https ://docs.jboss.org/author/display/ISPN/Cache+Loaders+and+Stores#CacheLoadersandStores-CachePassivation

A cache loader can be used to enforce entry passivation and activation on eviction in a cache. 缓存加载器可用于在缓存中逐出时强制条目钝化和激活。 Cache passivation is the process of removing an object from in-memory cache and writing it to a secondary data store (eg, file system, database) on eviction. 缓存钝化是从内存缓存中删除对象并将对象逐出时将其写入辅助数据存储(例如文件系统,数据库)的过程。 Cache Activation is the process of restoring an object from the data store into the in-memory cache when it's needed to be used. 缓存激活是在需要使用对象时将其从数据存储还原到内存中缓存的过程。 In both cases, the configured cache loader will be used to read from the data store and write to the data store. 在这两种情况下,都将使用配置的缓存加载器从数据存储读取数据并将其写入数据存储。

We use this to passivate data from a clustered hibernate-search cache-container to a file-store like this (in our standalone-full-ha.xml): 我们使用它来将数据从集群的hibernate-search缓存容器钝化到这样的文件存储中(在standalone-full-ha.xml中):

<cache-container name="hibernate-search" jndi-name="java:jboss/infinispan/container/hibernate-search" start="EAGER">
            <transport lock-timeout="330000"/>
            <replicated-cache name="LuceneIndexesMetadata" start="EAGER" mode="SYNC" remote-timeout="330000">
                <locking striping="false" acquire-timeout="330000" concurrency-level="500"/>
                <transaction mode="NONE"/>
                <eviction strategy="NONE" max-entries="-1"/>
                <expiration max-idle="-1"/>
                <state-transfer enabled="true" timeout="480000"/>
                <file-store preload="true" passivation="false" purge="false" relative-to="jboss.home.dir" path="infinispan-file-store">
                    <write-behind/>
                </file-store>
                <indexing index="NONE"/>
            </replicated-cache>

The data is then available after the node is restarted. 重新启动节点后,数据便可用。

The schema for the subsystem, describing all valid elements and attributes, can be found in the Wildfly distribution, in the docs/schema directory. 可以在Wildfly发行版的docs / schema目录中找到描述所有有效元素和属性的子系统架构。

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM