示例#1
0
  @Override
  public void run() {
    Logger.debug((lock ? "Lock" : "Unlock") + " request received from " + from + " for " + key);
    boolean success = false;
    try {
      int localClock = LocalClock.get();
      if (senderClock > localClock) LocalClock.advance(senderClock);
      AbstractDistinguishable object =
          ((DTL2Directory) DirectoryManager.getManager()).getLocalObject(key);
      if (object != null) {
        if (!lock) {
          LockTable.unLock(object, null);
          Logger.debug("Remote Unlocked " + key);
          return;
        }

        LockTable.remoteLockResponse(object);
        Logger.debug("Remote Locked granted " + key);
        success = true;
      }
    } catch (TransactionException e) {
      Logger.debug("Remote Locked refused " + key);
    }
    try {
      CommunicationManager.getManager().send(from, new LockResponse(key, success, hashCode));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
示例#2
0
 public static void remoteUnlockRequest(GlobalObject key) {
   if (key == null) return;
   try {
     Logger.debug("Remote Lock release for " + key + " sent to " + key.getHome());
     CommunicationManager.getManager().send(key.getHome(), new LockRequest(key, false, 0));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
示例#3
0
 public static void remoteLockRequest(AbstractContext context, GlobalObject key) {
   int hashCode = context.hashCode();
   pendingLocks.put(hashCode, context);
   synchronized (context) {
     try {
       Logger.debug(
           "Request remote lock for " + key + " hashcode is " + hashCode + " for " + context);
       CommunicationManager.getManager().send(key.getHome(), new LockRequest(key, true, hashCode));
       context.wait();
       Logger.debug("Request remote lock come back...");
     } catch (InterruptedException e) {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   pendingLocks.remove(hashCode);
 }