简体   繁体   中英

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

I use WildFly 8.2 with Immutant 2.1 (application is in Clojure)

Every time I redeploy my application in WildFly cluster, its Infinispan Web cache container is restarted, and all users sessions are lost.

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:

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

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):

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

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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