2015-07-25 2 views
0

Comment nous pouvons configurer le cache dans jboss pae 6.3 serveur et l'utiliser dans autre application différente comme j2ee etcJboss-6.3 pae configuration mise en cache

S'il vous plaît aider ici .. !!

+0

Posez-vous la même question deux fois? http://stackoverflow.com/questions/31612928/how-to-configure-caching-in-jboss-eap-6-3-ga –

+0

Vous devriez être répondu plutôt que de voter ma question ...? pour votre aimable information cette question était pour la configuration "Groovy and Grails" et celle-ci est pour "General eclipse projects". –

Répondre

2

Mise en cache en utilisant la configuration jboss pae:

étapes

1) sous-système autonome intérieur -ha.xml de 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) Recherche de ceux-ci contenant de la mémoire cache de code en utilisant 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) Vous pouvez maintenant stocker des données dans ces objets de cache.

cache.put ("un", "deux"); divCache.put ("three", "four");

1

Salut, je l'ai fait "caching avec Infinispan dans EAP 6.3 Jboss"

Voici les étapes pour excursionnistes

  1. Besoin de créer un projet (Maven/Web dynamique).
  2. Si votre projet est un projet Maven ajouter une dépendance dans pom.xml quelle que soit la version dont vous avez besoin comme-

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

3.Créez exemple de classe dans votre projet et à l'intérieur qui ajoutent ce code snippet-

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.Now besoin d'ajouter ce "userInputCache dans votre infinispan.xml" fichier ci-dessous est le code pour excursionnistes

<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.Here nous avons fichier jgroups.xml également si vous devez configurer cette mise en cache sur l'environnement distribué et clusters doivent ensuite ajouter ce aussi ci-dessous est le code pour excursionnistes

<?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. exécuter votre première classe d'exemple que vous avez données mises en cache - Bonne chance