private boolean lockPrimaryStateReadLock(boolean tryLock) {
    Lock primaryMoveReadLock = getBucketAdvisor().getPrimaryMoveReadLock();
    for (;;) {
      boolean interrupted = Thread.interrupted();
      try {
        // Get the lock. If we have to wait here, it's because
        // this VM is actively becoming "not primary". We don't want
        // to throw an exception until this VM is actually no longer
        // primary, so we wait here for not primary to complete.
        if (tryLock) {
          boolean locked = primaryMoveReadLock.tryLock();
          if (!locked) {
            return false;
          }
        } else {
          primaryMoveReadLock.lockInterruptibly();
        }
        break; // success
      } catch (InterruptedException e) {
        interrupted = true;
        cache.getCancelCriterion().checkCancelInProgress(null);
        // don't throw InternalGemFireError to fix bug 40102
      } finally {
        if (interrupted) {
          Thread.currentThread().interrupt();
        }
      }
    }

    return true;
  }
lock this bucket

@param tryLock - whether to use tryLock (true) or a blocking lock (false)
@return true if locks were obtained and are still held
geode-core/src/main/java/org/apache/geode/internal/cache/BucketRegion.java