public int getVersion(Data key) {
   LockResourceImpl lock = locks.get(key);
   if (lock != null) {
     return lock.getVersion();
   }
   return -1;
 }
 public AwaitOperation pollExpiredAwaitOp(Data key) {
   LockResourceImpl lock = locks.get(key);
   if (lock == null) {
     return null;
   } else {
     return lock.pollExpiredAwaitOp();
   }
 }
 public ConditionKey getSignalKey(Data key) {
   LockResourceImpl lock = locks.get(key);
   if (lock == null) {
     return null;
   } else {
     return lock.getSignalKey();
   }
 }
 @Override
 public boolean extendLeaseTime(Data key, String caller, long threadId, long leaseTime) {
   LockResourceImpl lock = locks.get(key);
   if (lock == null) {
     return false;
   }
   return lock.extendLeaseTime(caller, threadId, leaseTime);
 }
 @Override
 public boolean canAcquireLock(Data key, String caller, long threadId) {
   LockResourceImpl lock = locks.get(key);
   if (lock == null) {
     return true;
   } else {
     return lock.canAcquireLock(caller, threadId);
   }
 }
 @Override
 public void writeData(ObjectDataOutput out) throws IOException {
   out.writeObject(namespace);
   out.writeInt(backupCount);
   out.writeInt(asyncBackupCount);
   int len = locks.size();
   out.writeInt(len);
   if (len > 0) {
     for (LockResourceImpl lock : locks.values()) {
       lock.writeData(out);
     }
   }
 }
 @Override
 public boolean forceUnlock(Data key) {
   LockResourceImpl lock = locks.get(key);
   if (lock == null) {
     return false;
   } else {
     lock.clear();
     if (lock.isRemovable()) {
       locks.remove(key);
       lock.cancelEviction();
     }
     return true;
   }
 }
 @Override
 public void readData(ObjectDataInput in) throws IOException {
   namespace = in.readObject();
   backupCount = in.readInt();
   asyncBackupCount = in.readInt();
   int len = in.readInt();
   if (len > 0) {
     for (int i = 0; i < len; i++) {
       LockResourceImpl lock = new LockResourceImpl();
       lock.readData(in);
       lock.setLockStore(this);
       locks.put(lock.getKey(), lock);
     }
   }
 }
  @Override
  public boolean unlock(Data key, String caller, long threadId, long referenceId) {
    LockResourceImpl lock = locks.get(key);
    if (lock == null) {
      return false;
    }

    boolean result = false;
    if (lock.canAcquireLock(caller, threadId)) {
      if (lock.unlock(caller, threadId, referenceId)) {
        result = true;
      }
    }
    if (lock.isRemovable()) {
      locks.remove(key);
    }
    return result;
  }
 @Override
 public boolean txnLock(Data key, String caller, long threadId, long referenceId, long leaseTime) {
   LockResourceImpl lock = getLock(key);
   return lock.lock(caller, threadId, referenceId, leaseTime, true);
 }
 public void registerExpiredAwaitOp(AwaitOperation awaitResponse) {
   Data key = awaitResponse.getKey();
   LockResourceImpl lock = getLock(key);
   lock.registerExpiredAwaitOp(awaitResponse);
 }
 public void removeSignalKey(ConditionKey conditionKey) {
   LockResourceImpl lock = locks.get(conditionKey.getKey());
   if (lock != null) {
     lock.removeSignalKey(conditionKey);
   }
 }
 public void registerSignalKey(ConditionKey conditionKey) {
   LockResourceImpl lock = getLock(conditionKey.getKey());
   lock.registerSignalKey(conditionKey);
 }
 public int getAwaitCount(Data key, String conditionId) {
   LockResourceImpl lock = getLock(key);
   return lock.getAwaitCount(conditionId);
 }
 public boolean startAwaiting(Data key, String conditionId, String caller, long threadId) {
   LockResourceImpl lock = getLock(key);
   return lock.startAwaiting(conditionId, caller, threadId);
 }
 @Override
 public boolean isTransactionallyLocked(Data key) {
   LockResourceImpl lock = locks.get(key);
   return lock != null && lock.isTransactional() && lock.isLocked();
 }