HDFS-8051. FsVolumeList#addVolume should release volume reference if not put it into BlockScanner. (Lei (Eddy) Xu via Colin P. McCabe)
This commit is contained in:
parent
023133cef9
commit
ef591b1d6a
@ -1376,6 +1376,9 @@ Release 2.7.0 - UNRELEASED
|
|||||||
HDFS-7996. After swapping a volume, BlockReceiver reports
|
HDFS-7996. After swapping a volume, BlockReceiver reports
|
||||||
ReplicaNotFoundException (Lei (Eddy) Xu via Colin P. McCabe)
|
ReplicaNotFoundException (Lei (Eddy) Xu via Colin P. McCabe)
|
||||||
|
|
||||||
|
HDFS-8051. FsVolumeList#addVolume should release volume reference if not
|
||||||
|
put it into BlockScanner. (Lei (Eddy) Xu via Colin P. McCabe)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
|
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
|
||||||
|
|
||||||
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode
|
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.VolumeChoosingPolicy;
|
import org.apache.hadoop.hdfs.server.datanode.fsdataset.VolumeChoosingPolicy;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.BlockScanner;
|
import org.apache.hadoop.hdfs.server.datanode.BlockScanner;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
||||||
|
import org.apache.hadoop.io.IOUtils;
|
||||||
import org.apache.hadoop.util.DiskChecker.DiskErrorException;
|
import org.apache.hadoop.util.DiskChecker.DiskErrorException;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
|
|
||||||
@ -292,6 +293,10 @@ void addVolume(FsVolumeReference ref) {
|
|||||||
}
|
}
|
||||||
if (blockScanner != null) {
|
if (blockScanner != null) {
|
||||||
blockScanner.addVolumeScanner(ref);
|
blockScanner.addVolumeScanner(ref);
|
||||||
|
} else {
|
||||||
|
// If the volume is not put into a volume scanner, it does not need to
|
||||||
|
// hold the reference.
|
||||||
|
IOUtils.cleanup(FsDatasetImpl.LOG, ref);
|
||||||
}
|
}
|
||||||
// If the volume is used to replace a failed volume, it needs to reset the
|
// If the volume is used to replace a failed volume, it needs to reset the
|
||||||
// volume failure info for this volume.
|
// volume failure info for this volume.
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class TestFsVolumeList {
|
public class TestFsVolumeList {
|
||||||
@ -101,4 +102,22 @@ public void testCheckDirsWithClosedVolume() throws IOException {
|
|||||||
// checkDirs() should ignore the 2nd volume since it is closed.
|
// checkDirs() should ignore the 2nd volume since it is closed.
|
||||||
volumeList.checkDirs();
|
volumeList.checkDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReleaseVolumeRefIfNoBlockScanner() throws IOException {
|
||||||
|
FsVolumeList volumeList = new FsVolumeList(
|
||||||
|
Collections.<VolumeFailureInfo>emptyList(), null, blockChooser);
|
||||||
|
File volDir = new File(baseDir, "volume-0");
|
||||||
|
volDir.mkdirs();
|
||||||
|
FsVolumeImpl volume = new FsVolumeImpl(dataset, "storage-id", volDir,
|
||||||
|
conf, StorageType.DEFAULT);
|
||||||
|
FsVolumeReference ref = volume.obtainReference();
|
||||||
|
volumeList.addVolume(ref);
|
||||||
|
try {
|
||||||
|
ref.close();
|
||||||
|
fail("Should throw exception because the reference is closed in "
|
||||||
|
+ "VolumeList#addVolume().");
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user