Пример #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();
    }
  }