4 Replies Latest reply: Feb 6, 2013 7:47 AM by Radoslav Husar RSS

Detect cluster node failure Jboss AS 7.1.1-Final

Manish Devraj Newbie

I have configured 2 node clusers in Jboss AS 7.1.1-Final. I am planning to use sticky sessions. Meanwhile I am also recording number of active online users in Infinispan cache with node IP from where that user session was created for reporting purpose.

 

 

I have taken care of scenarios for login/logout where I would clear our cache entries. Problem is if one of the server node goes down, I need to write clean up routine to clear such records of that node from cache too.

 

 

One of the option is to write a client and check at specific interval if server is alive otherwise trigger a clean up routine. This approach would work but I am looking for more cleaner approach if I could detect server node failure that gets notified to other live nodes then I could hit cleanup.

 

 

From console I know that it shows when server goes down or comes up. But what would be that listerner to listen to such events. Any thoughts?

  • 1. Re: Detect cluster node failure Jboss AS 7.1.1-Final
    Wolf-Dieter Fink Master

    I wonder wheter this can be achieved with an implementation which uses the management interface

  • 2. Re: Detect cluster node failure Jboss AS 7.1.1-Final
    Radoslav Husar Master

    I am not really sure what you want to achieve. If you want to delete data of the failed node, why replicated in the first place? Just use a local cache and if the node goes down the data is gone. If you need the data on other nodes, use REPL or DIST and data is accessible everywhere.

     

    Either way, to do what you want, you can just implement a cache listener that listens on evens of membership change like this:

     

    @ManagedBean
    @Listener
    public class MyBean {
    
    
       @Resource(lookup="java:jboss/infinispan/container/web")
       private EmbeddedCacheManager manager;
    
    
       @PostConstruct
       public void init() {
         manager.addListener(this);
       }
    
    
       @PreDestroy
       public void destroy() {
         manager.removeListener(this);
       }
    
    
       @ViewChanged
       public void viewChanged(ViewChangedEvent event) {
         // Insert your cleanup logic
       }
    }
    
  • 3. Re: Detect cluster node failure Jboss AS 7.1.1-Final
    Manish Devraj Newbie

    You are correct, but since I am using clustering the information is getting replicated across the cluster nodes. Problem is when my job runs to check active users from cache it will return all the records irrespective of the fact that one of the server who was handling the record has failed/crashed. In such scenario I would like to clean up the records of node that failed. You approach seems good to me, I am going to try and get back for others looking for similar solutions.

     

    Thank you

  • 4. Re: Detect cluster node failure Jboss AS 7.1.1-Final
    Radoslav Husar Master

    irrespective of the fact that one of the server who was handling the record has failed/crashed

    I still don't quite understand. That's the point of using clustering to achieve highly-available deployment. One of the core attributes of such system is faul tolerance, meaning in case of failure, system runs correctly further. So that's why no cleaning is neccessary. But I guess you have a specific use case.