|
@@ -76,7 +76,7 @@ import org.apache.hadoop.util.ReflectionUtils;
|
|
|
*
|
|
|
***************************************************/
|
|
|
@InterfaceAudience.Private
|
|
|
-public class FSDataset implements FSDatasetInterface {
|
|
|
+class FSDataset implements FSDatasetInterface {
|
|
|
|
|
|
/**
|
|
|
* A node type that can be built into a tree reflecting the
|
|
@@ -374,7 +374,7 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
*/
|
|
|
File createTmpFile(Block b) throws IOException {
|
|
|
File f = new File(tmpDir, b.getBlockName());
|
|
|
- return FSDataset.createTmpFile(b, f);
|
|
|
+ return DatanodeUtil.createTmpFile(b, f);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -383,7 +383,7 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
*/
|
|
|
File createRbwFile(Block b) throws IOException {
|
|
|
File f = new File(rbwDir, b.getBlockName());
|
|
|
- return FSDataset.createTmpFile(b, f);
|
|
|
+ return DatanodeUtil.createTmpFile(b, f);
|
|
|
}
|
|
|
|
|
|
File addBlock(Block b, File f) throws IOException {
|
|
@@ -537,15 +537,15 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
}
|
|
|
|
|
|
/** Return storage directory corresponding to the volume */
|
|
|
- public File getDir() {
|
|
|
+ File getDir() {
|
|
|
return currentDir.getParentFile();
|
|
|
}
|
|
|
|
|
|
- public File getCurrentDir() {
|
|
|
+ File getCurrentDir() {
|
|
|
return currentDir;
|
|
|
}
|
|
|
|
|
|
- public File getRbwDir(String bpid) throws IOException {
|
|
|
+ File getRbwDir(String bpid) throws IOException {
|
|
|
BlockPoolSlice bp = getBlockPoolSlice(bpid);
|
|
|
return bp.getRbwDir();
|
|
|
}
|
|
@@ -1086,26 +1086,6 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
return new MetaDataInputStream(new FileInputStream(checksumFile),
|
|
|
checksumFile.length());
|
|
|
}
|
|
|
-
|
|
|
- static File createTmpFile(Block b, File f) throws IOException {
|
|
|
- if (f.exists()) {
|
|
|
- throw new IOException("Unexpected problem in creating temporary file for "+
|
|
|
- b + ". File " + f + " should not be present, but is.");
|
|
|
- }
|
|
|
- // Create the zero-length temp file
|
|
|
- //
|
|
|
- boolean fileCreated = false;
|
|
|
- try {
|
|
|
- fileCreated = f.createNewFile();
|
|
|
- } catch (IOException ioe) {
|
|
|
- throw (IOException)new IOException(DISK_ERROR +f).initCause(ioe);
|
|
|
- }
|
|
|
- if (!fileCreated) {
|
|
|
- throw new IOException("Unexpected problem in creating temporary file for "+
|
|
|
- b + ". File " + f + " should be creatable, but is already present.");
|
|
|
- }
|
|
|
- return f;
|
|
|
- }
|
|
|
|
|
|
private final DataNode datanode;
|
|
|
final FSVolumeSet volumes;
|
|
@@ -1247,7 +1227,7 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
/**
|
|
|
* Get File name for a given block.
|
|
|
*/
|
|
|
- public File getBlockFile(ExtendedBlock b) throws IOException {
|
|
|
+ private File getBlockFile(ExtendedBlock b) throws IOException {
|
|
|
return getBlockFile(b.getBlockPoolId(), b.getLocalBlock());
|
|
|
}
|
|
|
|
|
@@ -1321,7 +1301,7 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
* @throws ReplicaNotFoundException if no entry is in the map or
|
|
|
* there is a generation stamp mismatch
|
|
|
*/
|
|
|
- private ReplicaInfo getReplicaInfo(ExtendedBlock b)
|
|
|
+ ReplicaInfo getReplicaInfo(ExtendedBlock b)
|
|
|
throws ReplicaNotFoundException {
|
|
|
ReplicaInfo info = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock());
|
|
|
if (info == null) {
|
|
@@ -1457,19 +1437,6 @@ public class FSDataset implements FSDatasetInterface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private final static String DISK_ERROR = "Possible disk error on file creation: ";
|
|
|
- /** Get the cause of an I/O exception if caused by a possible disk error
|
|
|
- * @param ioe an I/O exception
|
|
|
- * @return cause if the I/O exception is caused by a possible disk error;
|
|
|
- * null otherwise.
|
|
|
- */
|
|
|
- static IOException getCauseIfDiskError(IOException ioe) {
|
|
|
- if (ioe.getMessage()!=null && ioe.getMessage().startsWith(DISK_ERROR)) {
|
|
|
- return (IOException)ioe.getCause();
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
@Override // FSDatasetInterface
|
|
|
public synchronized ReplicaInPipelineInterface append(ExtendedBlock b,
|