package tachyon.worker.block;

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * A ReadWrite Lock to guard one block. There should be only one lock per block.
 */
public class BlockLock implements ReadWriteLock {
  public enum BlockLockType {
    READ,  // A read lock
    WRITE,  // A write lock
  }

  static final AtomicLong mBlockLockId = new AtomicLong(0);

  private final ReentrantReadWriteLock mLock;
  /** The block Id this lock guards **/
  private final long mBlockId;
  /** The unique id of each lock **/
  private final long mLockId;

  public BlockLock(long blockId) {
    mBlockId = blockId;
    mLockId = mBlockLockId.incrementAndGet();
    mLock = new ReentrantReadWriteLock();
  }

  public long getBlockId() {
    return mBlockId;
  }

  public long getLockId() {
    return mLockId;
  }

  @Override
  public Lock readLock() {
    return mLock.readLock();
  }

  @Override
  public Lock writeLock() {
    return mLock.writeLock();
  }
}

@@ -451,69 +451,8 @@
  %7D%0A%0A
-  static final AtomicLong mBlockLockId = new AtomicLong(0);%0A%0A
   pr
@@ -493,16 +493,16 @@
  mLock;%0A
+
   /** Th
@@ -568,75 +568,9 @@
 Id;%0A
-  /** The unique id of each lock **/%0A  private final long mLockId;
 %0A
+
 %0A  p
@@ -629,54 +629,8 @@
 Id;%0A
-    mLockId = mBlockLockId.incrementAndGet();%0A
     
@@ -693,32 +693,32 @@
  getBlockId() %7B%0A
+
     return mBloc
@@ -731,61 +731,8 @@
  %7D%0A%0A
-  public long getLockId() %7B%0A    return mLockId;%0A  %7D%0A%0A
   @O

Remove unused lockId field from BlockLock