[
https://issues.apache.org/jira/browse/HDFS-9252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14962134#comment-14962134
]
Colin Patrick McCabe commented on HDFS-9252:
--------------------------------------------
Thanks, [~eddyxu].
{code}
+ if (blockFile.equals(listdir[j])) {
{code}
It seems like
{{blockFile.getCanonicalPath().equals(listdir[j].getCanonicalPath())}} would be
better. See http://stackoverflow.com/questions/8930859/java-file-equals
{code}
140
141 /**
142 * Get the length of the underlying data file.
143 */
144 long getDataLength(ExtendedBlock eb) throws IOException;
145
146 /**
147 * Get the generation stamp from the persistent stored metadata file.
148 */
149 long getPersistentGenerationStamp(ExtendedBlock block) throws
IOException;
{code}
The {{ExtendedBlock}} structure has both a length and a genstamp field. Maybe
it would be clearer if these methods were named {{getStoredDataLength}} and
{{getStoredGenerationStamp}}? Also the Javadoc should make it clear that they
are getting the stored length and genstamp, and probably avoid references to
"the underlying file" (some {{FSDatasetSpi}} implementations don't use files)
{code}
820 assertEquals(utils.getPersistentGenerationStamp(newBlock.getBlock()),
821 newBlock.getBlock().getGenerationStamp());
{code}
Hmm. It seems like the order is reversed here, right? In {{assertEquals}},
the thing that we "expect" to see should come first, not second.
> Change TestFileTruncate to use FsDatasetTestUtils to get block file size and
> genstamp.
> --------------------------------------------------------------------------------------
>
> Key: HDFS-9252
> URL: https://issues.apache.org/jira/browse/HDFS-9252
> Project: Hadoop HDFS
> Issue Type: Improvement
> Affects Versions: 2.7.1
> Reporter: Lei (Eddy) Xu
> Assignee: Lei (Eddy) Xu
> Attachments: HDFS-9252.00.patch
>
>
> {{TestFileTruncate}} verifies block size and genstamp by directly accessing
> the local filesystem, e.g.:
> {code}
> assertTrue(cluster.getBlockMetadataFile(dn0,
> newBlock.getBlock()).getName().endsWith(
> newBlock.getBlock().getGenerationStamp() + ".meta"));
> {code}
> Lets abstract the fsdataset-special logic behind FsDatasetTestUtils.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)