Code example for CountDownLatch

0
import org.hornetq.api.core.client.TopologyMember; 
 
final class BackupTopologyListener implements ClusterTopologyListener 
{ 
 
   private final CountDownLatch latch = new CountDownLatch(1);
   private final String ownId;
   private static final int WAIT_TIMEOUT = 60;
 
   public BackupTopologyListener(String ownId)
   { 
      this.ownId = ownId;
   } 
 
   @Override 
   public void nodeUP(TopologyMember topologyMember, boolean last)
   { 
      final String nodeID = topologyMember.getNodeId();
 
      if (ownId.equals(nodeID) && topologyMember.getBackup() != null)
         latch.countDown();