|
@@ -59,6 +59,7 @@ import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
|
|
import org.apache.hadoop.hdfs.util.ByteArray;
|
|
|
|
|
|
+import com.google.common.annotations.VisibleForTesting;
|
|
|
import com.google.common.base.Preconditions;
|
|
|
|
|
|
/*************************************************
|
|
@@ -173,6 +174,12 @@ public class FSDirectory implements Closeable {
|
|
|
writeUnlock();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //This is for testing purposes only
|
|
|
+ @VisibleForTesting
|
|
|
+ boolean isReady() {
|
|
|
+ return ready;
|
|
|
+ }
|
|
|
|
|
|
// exposed for unit tests
|
|
|
protected void setReady(boolean flag) {
|
|
@@ -2003,9 +2010,16 @@ public class FSDirectory implements Closeable {
|
|
|
* Reset the entire namespace tree.
|
|
|
*/
|
|
|
void reset() {
|
|
|
- rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
|
|
- getFSNamesystem().createFsOwnerPermissions(new FsPermission((short)0755)),
|
|
|
- Integer.MAX_VALUE, -1);
|
|
|
+ writeLock();
|
|
|
+ try {
|
|
|
+ setReady(false);
|
|
|
+ rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
|
|
+ getFSNamesystem().createFsOwnerPermissions(new FsPermission((short)0755)),
|
|
|
+ Integer.MAX_VALUE, -1);
|
|
|
+ nameCache.reset();
|
|
|
+ } finally {
|
|
|
+ writeUnlock();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|