1 Reply Latest reply on Feb 10, 2009 9:07 PM by burnison

    Node Removal In mvcc-entity Cache Through JMX Console

    frank.stillford

      When using the Entity Tree Cache in JBoss 4.2.2.GA, the JMX bean makes available a remove(String) method, that, when invoked, removes a given node from the cache.

      Following the JBoss 5.0.0.GA cache article (available: http://www.jboss.org/community/docs/DOC-13200), I have migrated to the mvcc-entity cache. Unfortunately, I am unable to find a way to remove nodes from this cache without redeploying the application. Being able to remove nodes (in particular, those cached as read-only) from the cache is a critical need when redeployment in a production environment is not a viable option.

      Is this functionality still available with the mvcc-entity cache? If not, are there any similar alternatives or workarounds?

        • 1. Re: Node Removal In mvcc-entity Cache Through JMX Console

           

          "frank.stillford" wrote:
          ... If not, are there any similar alternatives or workarounds?


          I have not found a way to invalidate entities out-of-the-box, but you can create your own MBean to accomplish the task. You can get a handle on the CacheManager through JNDI, and you can obtain a reference to the entity cache thusly:

          public void remove(String jndi, String cacheName, String node) throws Exception
          {
           CacheManager cm = null;
           Cache<?, ?> c = null;
          
           try{
           cm = this.getCacheManager(jndi);
           c = cm.getCache(cacheName, false);
           c.removeNode(node);
           } finally{
           if(c != null){
           try {
           cm.releaseCache(cacheName);
           } catch (NamingException ex) {
           }
           }
           }
          }
          
          
          private CacheManager getCacheManager(String jndi) throws NamingException
          {
           Context ic = null;
          
           try{
           ic = new InitialContext();
           return (CacheManager)ic.lookup(jndi);
           } finally {
           if(ic != null) {
           try {
           ic.close();
           } catch (NamingException ex) {
           }
           }
           }
          }
          


          By default, the cache manager is bound to java:/CacheManager.

          Regards,

          Richard Burnison