/*
 * Licensed to the University of California, Berkeley under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package tachyon.worker.block.meta;

import java.util.UUID;

import tachyon.util.CommonUtils;

/**
 * Represents the metadata of a block in Tachyon managed storage.
 */
public class BlockMeta {
  private final long mBlockId;
  private final long mBlockSize;
  private final String mPath;
  private final String mTmpPath;

  public BlockMeta(long blockId, long blockSize, String localPath) {
    mBlockId = blockId;
    mBlockSize = blockSize;
    mPath = CommonUtils.concatPath(localPath, blockId);
    mTmpPath = CommonUtils.concatPath(localPath, UUID.randomUUID());
  }

  public long getBlockId() {
    return mBlockId;
  }

  public long getBlockSize() {
    return mBlockSize;
  }

  public String getPath() {
    return mPath;
  }

  public String getTmpPath() {
    return mTmpPath;
  }
}

@@ -833,22 +833,44 @@
 ort 
-java.util.UUID
+com.google.common.base.Preconditions
 ;%0A%0Ai
@@ -1034,38 +1034,32 @@
 ckId;%0A  private 
-final 
 long mBlockSize;
@@ -1073,59 +1073,61 @@
 ate 
-final String mPath;%0A  private final String mTmpPath
+StorageDir mDir;%0A  private boolean mCommitted = false
 ;%0A%0A 
@@ -1180,22 +1180,20 @@
 , St
-ring localPath
+orageDir dir
 ) %7B%0A
@@ -1253,125 +1253,44 @@
    m
-Path = CommonUtils.concatPath(localPath, blockId);%0A    mTmpPath = CommonUtils.concatPath(localPath, UUID.randomUUID()
+Dir = Preconditions.checkNotNull(dir
 );%0A 
@@ -1450,13 +1450,59 @@
 urn 
-mPath
+CommonUtils.concatPath(mDir.getDirPath(), mBlockId)
 ;%0A  
@@ -1527,24 +1527,35 @@
  getTmpPath(
+long userId
 ) %7B%0A    retu
@@ -1561,20 +1561,296 @@
 urn 
-mTmpPath;%0A  %7D
+CommonUtils.concatPath(mDir.getDirPath(), userId, mBlockId);%0A  %7D%0A%0A  public StorageDir getParentDir() %7B%0A    return mDir;%0A  %7D%0A%0A  public boolean commit() %7B%0A    if (mCommitted) %7B%0A      return false;%0A    %7D%0A    mCommitted = true;%0A  %7D%0A%0A  public boolean isCommitted() %7B%0A    return mCommitted;%0A  %7D%0A
 %0A%7D%0A

Update BlockMeta to take StorageDir as a constructor parameter