示例#1
0
 void doCall(AbstractRemotelyCallable callable, List<Address> targets, boolean ignoreThis) {
   List<AsyncRemotelyBooleanOp> calls = new ArrayList<AsyncRemotelyBooleanOp>(targets.size());
   for (final Address target : targets) {
     boolean skip = ignoreThis && thisAddress.equals(target);
     if (!skip) {
       AsyncRemotelyBooleanOp op = new AsyncRemotelyBooleanOp(callable, target, false);
       op.execute();
       calls.add(op);
     }
   }
   for (AsyncRemotelyBooleanOp call : calls) {
     if (!call.getResultAsBoolean(5)) {
       targets.remove(call.getTarget());
     }
   }
 }
 List<Edge> detectDeadlock() {
   Collection<Map<String, MapLockState>> collection =
       (Collection<Map<String, MapLockState>>) callOnAllMembers(new LockInformationCallable());
   List<Vertex> graph = new ArrayList<Vertex>();
   for (Map<String, MapLockState> mapLockStateMap : collection) {
     for (MapLockState map : mapLockStateMap.values()) {
       for (Object key : map.getLockOwners().keySet()) {
         Vertex owner = new Vertex(map.getLockOwners().get(key));
         Vertex requester = new Vertex(map.getLockRequested().get(key));
         int index = graph.indexOf(owner);
         if (index >= 0) {
           owner = graph.get(index);
         } else {
           graph.add(owner);
         }
         index = graph.indexOf(requester);
         if (index >= 0) {
           requester = graph.get(index);
         } else {
           graph.add(requester);
         }
         Edge edge = new Edge();
         edge.from = requester;
         edge.to = owner;
         edge.key = key;
         edge.mapName = map.getMapName();
         edge.globalLock = map.isGlobalLock();
         owner.addIncoming(edge);
         requester.addOutgoing(edge);
       }
     }
   }
   List<Edge> list = new ArrayList<Edge>();
   if (graph != null && graph.size() > 0) {
     try {
       graph.get(0).visit(list);
     } catch (RuntimeException e) {
     }
   }
   return list;
 }