hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nemo Chen (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS
Date Sat, 13 Aug 2016 05:11:20 GMT

     [ https://issues.apache.org/jira/browse/HDFS-10752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Nemo Chen updated HDFS-10752:
-----------------------------
    Description: 
As per conversation with [~vrushalic], we merged HDFS-10749, HDFS-10750, HDFS-10751, HDFS-10753,
 under this issue.
---
HDFS-10749
*Method invocation in logs can be replaced by variable*
Similar to the fix for HDFS-409. In file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java

In code block:
{code:borderStyle=solid}
lastQueuedSeqno = currentPacket.getSeqno();
if (DFSClient.LOG.isDebugEnabled()) {
    DFSClient.LOG.debug("Queued packet " + currentPacket.getSeqno());
}
{code}
currentPacket.getSeqno() is better to be replaced by variable lastQueuedSeqno.
---
*Print variable in byte*
Similar to the fix for HBASE-623, in file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java

In the following method, the log printed variable data (in byte[]). A possible fix is add
Bytes.toString(data).
{code}
/**
   * Write the batch of edits to the local copy of the edit logs.
   */
  private void logEditsLocally(long firstTxId, int numTxns, byte[] data) {
    long expectedTxId = editLog.getLastWrittenTxId() + 1;
    Preconditions.checkState(firstTxId == expectedTxId,
        "received txid batch starting at %s but expected txn %s",
        firstTxId, expectedTxId);
    editLog.setNextTxId(firstTxId + numTxns - 1);
    editLog.logEdit(data.length, data);
    editLog.logSync();
  }
{code}
----

----
*MethodInvocation replaced by variable due to toString method*
Similar to the fix in HADOOP-6419, in file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CorruptReplicasMap.java

in line 76, the blk.getBlockName() method invocation is invoked on variable blk. "blk" is
the class instance of Block.

{code}
void addToCorruptReplicasMap(Block blk, DatanodeDescriptor dn,
      String reason, Reason reasonCode) {
...
NameNode.blockStateChangeLog.info(
          "BLOCK NameSystem.addToCorruptReplicasMap: {} added as corrupt on "
              + "{} by {} {}", blk.getBlockName(), dn, Server.getRemoteIp(),
          reasonText);
{code}

In file: hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java
{code}
  @Override
  public String toString() {
    return getBlockName() + "_" + getGenerationStamp();
  }
{code}
The toString() method contain not only getBlockName() but also getGenerationStamp which may
be helpful for debugging purpose. Therefore blk.getBlockName() can be replaced by blk

  was:
As per conversation with [~vrushalic], we merged HDFS-10749, HDFS-10750, HDFS-10751, HDFS-10753,
 under this issue.
*Print variable in byte*
Similar to the fix for HBASE-623, in file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java

In the following method, the log printed variable data (in byte[]). A possible fix is add
Bytes.toString(data).
{code}
/**
   * Write the batch of edits to the local copy of the edit logs.
   */
  private void logEditsLocally(long firstTxId, int numTxns, byte[] data) {
    long expectedTxId = editLog.getLastWrittenTxId() + 1;
    Preconditions.checkState(firstTxId == expectedTxId,
        "received txid batch starting at %s but expected txn %s",
        firstTxId, expectedTxId);
    editLog.setNextTxId(firstTxId + numTxns - 1);
    editLog.logEdit(data.length, data);
    editLog.logSync();
  }
{code}
----
*Method invocation in logs can be replaced by variable*
Similar to the fix for HDFS-409. In file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java

In code block:
{code:borderStyle=solid}
lastQueuedSeqno = currentPacket.getSeqno();
if (DFSClient.LOG.isDebugEnabled()) {
    DFSClient.LOG.debug("Queued packet " + currentPacket.getSeqno());
}
{code}
currentPacket.getSeqno() is better to be replaced by variable lastQueuedSeqno.
----
*MethodInvocation replaced by variable due to toString method*
Similar to the fix in HADOOP-6419, in file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CorruptReplicasMap.java

in line 76, the blk.getBlockName() method invocation is invoked on variable blk. "blk" is
the class instance of Block.

{code}
void addToCorruptReplicasMap(Block blk, DatanodeDescriptor dn,
      String reason, Reason reasonCode) {
...
NameNode.blockStateChangeLog.info(
          "BLOCK NameSystem.addToCorruptReplicasMap: {} added as corrupt on "
              + "{} by {} {}", blk.getBlockName(), dn, Server.getRemoteIp(),
          reasonText);
{code}

In file: hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java
{code}
  @Override
  public String toString() {
    return getBlockName() + "_" + getGenerationStamp();
  }
{code}
The toString() method contain not only getBlockName() but also getGenerationStamp which may
be helpful for debugging purpose. Therefore blk.getBlockName() can be replaced by blk


> Several log refactoring/improvement suggestion in HDFS
> ------------------------------------------------------
>
>                 Key: HDFS-10752
>                 URL: https://issues.apache.org/jira/browse/HDFS-10752
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 2.7.2
>            Reporter: Nemo Chen
>              Labels: easyfix, easytest
>
> As per conversation with [~vrushalic], we merged HDFS-10749, HDFS-10750, HDFS-10751,
HDFS-10753,  under this issue.
> ---
> HDFS-10749
> *Method invocation in logs can be replaced by variable*
> Similar to the fix for HDFS-409. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
> In code block:
> {code:borderStyle=solid}
> lastQueuedSeqno = currentPacket.getSeqno();
> if (DFSClient.LOG.isDebugEnabled()) {
>     DFSClient.LOG.debug("Queued packet " + currentPacket.getSeqno());
> }
> {code}
> currentPacket.getSeqno() is better to be replaced by variable lastQueuedSeqno.
> ---
> *Print variable in byte*
> Similar to the fix for HBASE-623, in file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java
> In the following method, the log printed variable data (in byte[]). A possible fix is
add Bytes.toString(data).
> {code}
> /**
>    * Write the batch of edits to the local copy of the edit logs.
>    */
>   private void logEditsLocally(long firstTxId, int numTxns, byte[] data) {
>     long expectedTxId = editLog.getLastWrittenTxId() + 1;
>     Preconditions.checkState(firstTxId == expectedTxId,
>         "received txid batch starting at %s but expected txn %s",
>         firstTxId, expectedTxId);
>     editLog.setNextTxId(firstTxId + numTxns - 1);
>     editLog.logEdit(data.length, data);
>     editLog.logSync();
>   }
> {code}
> ----
> ----
> *MethodInvocation replaced by variable due to toString method*
> Similar to the fix in HADOOP-6419, in file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CorruptReplicasMap.java
> in line 76, the blk.getBlockName() method invocation is invoked on variable blk. "blk"
is the class instance of Block.
> {code}
> void addToCorruptReplicasMap(Block blk, DatanodeDescriptor dn,
>       String reason, Reason reasonCode) {
> ...
> NameNode.blockStateChangeLog.info(
>           "BLOCK NameSystem.addToCorruptReplicasMap: {} added as corrupt on "
>               + "{} by {} {}", blk.getBlockName(), dn, Server.getRemoteIp(),
>           reasonText);
> {code}
> In file: hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java
> {code}
>   @Override
>   public String toString() {
>     return getBlockName() + "_" + getGenerationStamp();
>   }
> {code}
> The toString() method contain not only getBlockName() but also getGenerationStamp which
may be helpful for debugging purpose. Therefore blk.getBlockName() can be replaced by blk



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org


Mime
View raw message