Конфигурация кэширования Jboss eap-6.3

Как мы можем настроить кеш на сервере jboss eap 6.3 и использовать его в других приложениях, таких как j2ee и т. Д.

Пожалуйста, помогите здесь .. !!


person G dangi    schedule 25.07.2015    source источник
comment
Вы задаете один и тот же вопрос дважды? stackoverflow.com/questions/31612928/   -  person shonky linux user    schedule 28.07.2015
comment
Вам следует ответить, а не голосовать против моего вопроса...?? для вашего сведения, этот вопрос был для конфигурации Groovy и Grails, а этот - для общих проектов eclipse.   -  person G dangi    schedule 28.07.2015


Ответы (2)


Кэширование с использованием конфигурации eap jboss:

Шаги

1) подсистема внутри standalone-ha.xml jboss eap 6.3

 <subsystem xmlns="urn:jboss:domain:infinispan:1.5">
            <cache-container name="DataCacheContainer" aliases="demo" default-cache="EdgeCache" start="EAGER" module="org.jboss.as.clustering.infinispan">
                <transport lock-timeout="60000"/>
                <replicated-cache name="EdgeCache" mode="ASYNC" batching="true">
                    <eviction strategy="LRU" max-entries="250000"/>
                    <file-store/>
                </replicated-cache>
                <replicated-cache name="SubdivCache" mode="SYNC" batching="true">
                    <eviction strategy="LIRS" max-entries="25000"/>
                    <file-store/>
                </replicated-cache>
            </cache-container>
            <cache-container name="LocatorCacheContainer" default-cache="trainLocatorCache">
                <local-cache name="LocatorCache"/>
            </cache-container>
            <cache-container name="ScheduleCacheContainer" default-cache="tgeoControlPtCache">
                <local-cache name="ControlPtCache"/>
            </cache-container>
            <cache-container name="singleton" aliases="cluster ha-partition" default-cache="default">
                <transport lock-timeout="60000"/>
                <replicated-cache name="default" mode="SYNC" batching="true">
                    <locking isolation="REPEATABLE_READ"/>
                </replicated-cache>
            </cache-container>
            <cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
                <transport lock-timeout="60000"/>
                <replicated-cache name="repl" mode="ASYNC" batching="true">
                    <file-store/>
                </replicated-cache>
                <replicated-cache name="sso" mode="SYNC" batching="true"/>
                <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
                    <file-store/>
                </distributed-cache>
            </cache-container>
            <cache-container name="ejb" aliases="sfsb sfsb-cache" default-cache="repl" module="org.jboss.as.clustering.ejb3.infinispan">
                <transport lock-timeout="60000"/>
                <replicated-cache name="repl" mode="ASYNC" batching="true">
                    <eviction strategy="LRU" max-entries="10000"/>
                    <file-store/>
                </replicated-cache>
                <replicated-cache name="remote-connector-client-mappings" mode="SYNC" batching="true"/>
                <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
                    <eviction strategy="LRU" max-entries="10000"/>
                    <file-store/>
                </distributed-cache>
            </cache-container>

2) Поиск этого контейнера кеша из кода с использованием URL-адреса:

 private static Cache<Integer, DataObject> cache;
    private static Cache<String, Integer> DivCache;


            InitialContext ic = new InitialContext();

            CacheContainer cc = (CacheContainer)    ic.lookup("java:jboss/infinispan/container/DataCacheContainer");

            cc.start();

            cache = cc.getCache("EdgeCache");
            divCache = cc.getCache("SubDivCache");
            cache.start();
            divCache.start();

            logger.info("Cache Objects started successfully...");

3) Теперь вы можете хранить данные в этих объектах кеша.

cache.put("один", "два"); divCache.put("три","четыре");

person G dangi    schedule 12.08.2016

Привет, я сделал "Кэширование с помощью Infinispan в Jboss EAP 6.3"

Ниже приведены шаги для того же

  1. Необходимо создать один проект (Maven/Dynamic web).
  2. Если ваш проект является проектом maven, добавьте одну зависимость в pom.xml любой версии, которая вам нужна:

        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>7.1.0.Final</version>
        </dependency> 
    

3. Создайте образец класса в своем проекте и добавьте в него этот фрагмент кода:

Cache<String, String> userInputCache;
EmbeddedCacheManager cm = new DefaultCacheManager("infinispan.xml");
userInputCache = cm.getCache("demoClusterCache");
userInputCache.put("demo", "DemoCacheValue");
System.out.println("cache value is :+ userInputCache.get("demo")); 

4. Теперь нужно добавить этот «userInputCache в ваш файл infinispan.xml», приведенный ниже, это код для того же:

<infinispan
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:infinispan:config:7.1 http://www.infinispan.org/schemas/infinispan-config-7.1.xsd"
        xmlns="urn:infinispan:config:7.1">         
        <jgroups>
            <stack-file name="udp" path="jgroups.xml" />
        </jgroups>          
        <cache-container default-cache="default" >
             <transport stack="udp" node-name="demo" />              
             <replicated-cache name="repl" mode="SYNC" />
             <distributed-cache name="dist" mode="SYNC" owners="2" />  

             <local-cache name="demoClusterCache">
                <eviction strategy="LIRS" max-entries="10" />
            </local-cache>  

         </cache-container>    
</infinispan>

5. Здесь у нас есть файл jgroups.xml, если вам нужно настроить это кэширование в распределенной и кластерной среде, тогда вам нужно добавить это, также ниже приведен код для того же:

<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:org:jgroups"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.4.xsd">
    <!--
    Note that the buffer sizes here are very small, you'll definitely want higher values in production.
    But the Linux defaults are also very small, and using higher values here without changing the system
    settings would only result in startup warnings.14.96.226.125
     -->
     <UDP
            mcast_addr="${jgroups.udp.mcast_addr:228.8.8.8}"
            mcast_port="${jgroups.udp.mcast_port:45566}"
            tos="8"
            ucast_recv_buf_size="200k"
            ucast_send_buf_size="200k"
            mcast_recv_buf_size="200k"
            mcast_send_buf_size="200k"
            loopback="true"
            max_bundle_size="64000"
            max_bundle_timeout="30"
            ip_ttl="${jgroups.udp.ip_ttl:2}"
            enable_bundling="true"
            enable_diagnostics="false"
            bundler_type="old"

            thread_naming_pattern="pl"

            thread_pool.enabled="true"
            thread_pool.min_threads="2"
            thread_pool.max_threads="30"
            thread_pool.keep_alive_time="60000"
            thread_pool.queue_enabled="true"
            thread_pool.queue_max_size="100"
            thread_pool.rejection_policy="Discard"

            oob_thread_pool.enabled="true"
            oob_thread_pool.min_threads="2"
            oob_thread_pool.max_threads="30"
            oob_thread_pool.keep_alive_time="60000"
            oob_thread_pool.queue_enabled="false"
            oob_thread_pool.queue_max_size="100"
            oob_thread_pool.rejection_policy="Discard"
            /> 

    <PING timeout="3000" num_initial_members="3"/>
    <MERGE2 max_interval="30000" min_interval="10000"/>
    <FD_SOCK/>
    <FD_ALL timeout="15000"/>
    <VERIFY_SUSPECT timeout="5000"/>
    <!-- Commented when upgraded to 3.1.0.Alpha (remove eventually)
    <pbcast.NAKACK  exponential_backoff="0"
                    use_mcast_xmit="true"
                    retransmit_timeout="300,600,1200"
                    discard_delivered_msgs="true"/> -->
    <pbcast.NAKACK2
            xmit_interval="1000"
            xmit_table_num_rows="100"
            xmit_table_msgs_per_row="10000"
            xmit_table_max_compaction_time="10000"
            max_msg_batch_size="100"/>

    <!-- Commented when upgraded to 3.1.0.Alpha (remove eventually)
    <UNICAST timeout="300,600,1200"/>  -->
    <UNICAST2
            stable_interval="5000"
            xmit_interval="500"
            max_bytes="1m"
            xmit_table_num_rows="20"
            xmit_table_msgs_per_row="10000"
            xmit_table_max_compaction_time="10000"
            max_msg_batch_size="100"
            conn_expiry_timeout="0"/>
    <pbcast.STABLE stability_delay="500" desired_avg_gossip="5000" max_bytes="1m"/>
    <pbcast.GMS print_local_addr="false" join_timeout="3000" view_bundling="true"/>
    <UFC max_credits="200k" min_threshold="0.20"/>
    <MFC max_credits="200k" min_threshold="0.20"/>
    <FRAG2 frag_size="8000"  />
    <RSVP timeout="60000" resend_interval="500" ack_on_delivery="true" />
</config>

6. Выполните свой первый пример класса, у которого есть кешированные данные. Удачи

person G dangi    schedule 06.08.2015