[
https://issues.apache.org/jira/browse/HDFS-14315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16779512#comment-16779512
]
Masatake Iwasaki commented on HDFS-14315:
-----------------------------------------
{code:java}
if (oldBR != -1) {
- if (oldBR > targetReplication) {
+ //File is likely in snapshots. Decreasing replication factor, but not
the requested value
+ if (oldBR > targetReplication && targetReplication > replication) {
+ FSDirectory.LOG.info("Decreasing replication from {} to {} for {} " +
+ "whereas requested value is {}. The file is
likely in snapshots",
+ oldBR, targetReplication, iip.getPath(),
replication, targetReplication);
+ //File is not in snapshots. Decreasing replication factor
+ } else if (oldBR > targetReplication){
FSDirectory.LOG.info("Decreasing replication from {} to {} for {}",
oldBR, targetReplication, iip.getPath());
{code}
The comment and log message should not mention snapshot.
INodeFile#getPreferredBlockReplication would be fixed due to additional reason
for adjusting number of replicas. My suggestion is just always logging given
replication rather than adding conditionals like this.
{code:java}
FSDirectory.LOG.info(
"Decreasing replication from {} to {} (over {}) for {}",
oldBR, targetReplication, replication, iip.getPath());
{code}
> Add more detailed log message when decreasing replication factor < max in
> snapshots
> -----------------------------------------------------------------------------------
>
> Key: HDFS-14315
> URL: https://issues.apache.org/jira/browse/HDFS-14315
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: hdfs
> Affects Versions: 3.1.2
> Reporter: Daisuke Kobayashi
> Assignee: Daisuke Kobayashi
> Priority: Minor
> Attachments: HDFS-14315.000.patch, HDFS-14315.001.patch
>
>
> When changing replication factor for a given file, the following 3 types of
> logging appear in the namenode log, but more detailed message would be useful
> especially when the file is in snapshot(s).
> {noformat}
> Decreasing replication from X to Y for FILE
> Increasing replication from X to Y for FILE
> Replication remains unchanged at X for FILE
> {noformat}
> I have added additional log messages as well as further test scenarios to
> org.apache.hadoop.hdfs.server.namenode.snapshot.TestSnapshotReplication#testReplicationWithSnapshot.
> The test sequence is:
> 1) A file is created with replication factor 1 (there are 5 datanodes)
> 2) Take a snapshot and increase the factor by 1. Continue this loop up to 5.
> 3) Setrep back to 3, but the target replication is decided to 4, which is the
> maximum in snapshots.
> {noformat}
> 2019-02-25 17:17:26,800 [IPC Server handler 9 on default port 55726] INFO
> namenode.FSDirectory (FSDirAttrOp.java:unprotectedSetReplication(408)) -
> Decreasing replication from 5 to 4 for /TestSnapshot/sub1/file1. Requested
> value is 3, but 4 is the maximum in snapshots
> {noformat}
> 4) Setrep to 3 again, but it's unchanged as follows. Both 3) and 4) are
> expected.
> {noformat}
> 2019-02-25 17:17:26,804 [IPC Server handler 6 on default port 55726] INFO
> namenode.FSDirectory (FSDirAttrOp.java:unprotectedSetReplication(420)) -
> Replication remains unchanged at 4 for /TestSnapshot/sub1/file1 . Requested
> value is 3, but 4 is the maximum in snapshots.
> {noformat}
> 5) Make sure the number of replicas in datanodes remains 4.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]