|
@@ -48,18 +48,18 @@ class FSDirectory implements FSConstants, Closeable {
|
|
final FSNamesystem namesystem;
|
|
final FSNamesystem namesystem;
|
|
final INodeDirectoryWithQuota rootDir;
|
|
final INodeDirectoryWithQuota rootDir;
|
|
FSImage fsImage;
|
|
FSImage fsImage;
|
|
- boolean ready = false;
|
|
|
|
|
|
+ private boolean ready = false;
|
|
// Metrics record
|
|
// Metrics record
|
|
private MetricsRecord directoryMetrics = null;
|
|
private MetricsRecord directoryMetrics = null;
|
|
|
|
|
|
/** Access an existing dfs name directory. */
|
|
/** Access an existing dfs name directory. */
|
|
- public FSDirectory(FSNamesystem ns, Configuration conf) throws IOException {
|
|
|
|
|
|
+ FSDirectory(FSNamesystem ns, Configuration conf) {
|
|
this(new FSImage(), ns, conf);
|
|
this(new FSImage(), ns, conf);
|
|
fsImage.setCheckpointDirectories(FSImage.getCheckpointDirs(conf, null),
|
|
fsImage.setCheckpointDirectories(FSImage.getCheckpointDirs(conf, null),
|
|
FSImage.getCheckpointEditsDirs(conf, null));
|
|
FSImage.getCheckpointEditsDirs(conf, null));
|
|
}
|
|
}
|
|
|
|
|
|
- public FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf) throws IOException {
|
|
|
|
|
|
+ FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf) {
|
|
rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
|
rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
|
ns.createFsOwnerPermissions(new FsPermission((short)0755)),
|
|
ns.createFsOwnerPermissions(new FsPermission((short)0755)),
|
|
Integer.MAX_VALUE, -1);
|
|
Integer.MAX_VALUE, -1);
|
|
@@ -497,7 +497,7 @@ class FSDirectory implements FSConstants, Closeable {
|
|
* @return the number of bytes
|
|
* @return the number of bytes
|
|
* @throws IOException if it is a directory or does not exist.
|
|
* @throws IOException if it is a directory or does not exist.
|
|
*/
|
|
*/
|
|
- public long getPreferredBlockSize(String filename) throws IOException {
|
|
|
|
|
|
+ long getPreferredBlockSize(String filename) throws IOException {
|
|
synchronized (rootDir) {
|
|
synchronized (rootDir) {
|
|
INode fileNode = rootDir.getNode(filename);
|
|
INode fileNode = rootDir.getNode(filename);
|
|
if (fileNode == null) {
|
|
if (fileNode == null) {
|
|
@@ -560,7 +560,7 @@ class FSDirectory implements FSConstants, Closeable {
|
|
/**
|
|
/**
|
|
* Remove the file from management, return blocks
|
|
* Remove the file from management, return blocks
|
|
*/
|
|
*/
|
|
- public INode delete(String src) {
|
|
|
|
|
|
+ INode delete(String src) {
|
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
|
NameNode.stateChangeLog.debug("DIR* FSDirectory.delete: "+src);
|
|
NameNode.stateChangeLog.debug("DIR* FSDirectory.delete: "+src);
|
|
}
|
|
}
|
|
@@ -574,8 +574,8 @@ class FSDirectory implements FSConstants, Closeable {
|
|
}
|
|
}
|
|
|
|
|
|
/** Return if a directory is empty or not **/
|
|
/** Return if a directory is empty or not **/
|
|
- public boolean isDirEmpty(String src) {
|
|
|
|
- boolean dirNotEmpty = true;
|
|
|
|
|
|
+ boolean isDirEmpty(String src) {
|
|
|
|
+ boolean dirNotEmpty = true;
|
|
if (!isDir(src)) {
|
|
if (!isDir(src)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -697,7 +697,7 @@ class FSDirectory implements FSConstants, Closeable {
|
|
* This function is admittedly very inefficient right now. We'll
|
|
* This function is admittedly very inefficient right now. We'll
|
|
* make it better later.
|
|
* make it better later.
|
|
*/
|
|
*/
|
|
- public FileStatus[] getListing(String src) {
|
|
|
|
|
|
+ FileStatus[] getListing(String src) {
|
|
String srcs = normalizePath(src);
|
|
String srcs = normalizePath(src);
|
|
|
|
|
|
synchronized (rootDir) {
|
|
synchronized (rootDir) {
|
|
@@ -786,7 +786,7 @@ class FSDirectory implements FSConstants, Closeable {
|
|
/**
|
|
/**
|
|
* Check whether the filepath could be created
|
|
* Check whether the filepath could be created
|
|
*/
|
|
*/
|
|
- public boolean isValidToCreate(String src) {
|
|
|
|
|
|
+ boolean isValidToCreate(String src) {
|
|
String srcs = normalizePath(src);
|
|
String srcs = normalizePath(src);
|
|
synchronized (rootDir) {
|
|
synchronized (rootDir) {
|
|
if (srcs.startsWith("/") &&
|
|
if (srcs.startsWith("/") &&
|
|
@@ -802,7 +802,7 @@ class FSDirectory implements FSConstants, Closeable {
|
|
/**
|
|
/**
|
|
* Check whether the path specifies a directory
|
|
* Check whether the path specifies a directory
|
|
*/
|
|
*/
|
|
- public boolean isDir(String src) {
|
|
|
|
|
|
+ boolean isDir(String src) {
|
|
synchronized (rootDir) {
|
|
synchronized (rootDir) {
|
|
INode node = rootDir.getNode(normalizePath(src));
|
|
INode node = rootDir.getNode(normalizePath(src));
|
|
return node != null && node.isDirectory();
|
|
return node != null && node.isDirectory();
|