1 package org.objectweb.perseus.concurrency.distributed.globallock; 2 3 import org.objectweb.perseus.concurrency.distributed.util.action.KillNode; 4 import org.objectweb.perseus.distribution.api.DistResServiceManager; 5 6 import java.util.Iterator ; 7 import java.util.Set ; 8 import java.util.HashSet ; 9 import java.io.Serializable ; 10 11 35 public class KillNodeAndWait extends KillNode 36 implements GlobalLockInterceptor.FailureListener { 37 Set notHandled = new HashSet (); 38 public KillNodeAndWait(String name, DistResServiceManager drsm, Object node, 39 Serializable resId) { 40 super(name, drsm, node); 41 Set nodes = new HashSet (drsm.getLocalNodes()); 42 nodes.remove(node); 43 for (Iterator it = nodes.iterator(); it.hasNext();) { 44 Object n = it.next(); 45 notHandled.add(n); 46 Object ui = drsm.getUserService(n).getUser(resId); 47 ((UserInterceptor) ui).setFailureListener(this); 48 49 } 50 } 51 52 public synchronized void perform() throws Exception { 53 super.perform(); 54 while (!notHandled.isEmpty()) { 55 wait(); 56 } 57 em.notifyEvent(endEvent, true); 58 } 59 60 public synchronized void handle(Serializable resId, Serializable nodeId) { 61 notHandled.remove(nodeId); 62 if (notHandled.isEmpty()) notify(); 63 } 64 } 65 | Popular Tags |