[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-10-19 Thread Arpit Agarwal (JIRA)

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

Arpit Agarwal updated HDFS-10752:
-
   Resolution: Fixed
 Hadoop Flags: Reviewed
Fix Version/s: 3.0.0-alpha2
   2.8.0
   Status: Resolved  (was: Patch Available)

Committed for 2.8.0. Thanks for the contribution [~hanishakoneru]!

> 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
>Assignee: Hanisha Koneru
>  Labels: easyfix, easytest
> Fix For: 2.8.0, 3.0.0-alpha2
>
> Attachments: HDFS-10752.000.patch
>
>
> 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.
> 
> HDFS-10750
> Similar to the fix for AVRO-115. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
> in line 695, the logging code:
> {code:borderStyle=solid}
> LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
> {code}
> In the same class, there is a method in line 907:
> {code:borderStyle=solid}
>   /**
>* @return NameNode RPC address
>*/
>   public InetSocketAddress getNameNodeAddress() {
> return rpcServer.getRpcAddress();
>   }
> {code}
> We can tell that rpcServer.getRpcAddress() could be replaced by  method 
> getNameNodeAddress() for the case of readability and simplicity
> 
> HDFS-10751
> Similar to the fix for AVRO-115. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtxCache.java
> in line 72, the logging code:
> {code:borderStyle=solid}
> LOG.trace("openFileMap size:" + openFileMap.size());
> {code}
> In the same class, there is a method in line 189:
> {code:borderStyle=solid}
>   int size() {
> return openFileMap.size();
>   }
> {code}
> We can tell that openFileMap.size() could be replaced by  method size() for 
> the case of readability and simplicity
> 
> *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}
> 
> 
> HDFS-10753
> *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)


[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-10-17 Thread Hanisha Koneru (JIRA)

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

Hanisha Koneru updated HDFS-10752:
--
Status: Patch Available  (was: Open)

> 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
>Assignee: Hanisha Koneru
>  Labels: easyfix, easytest
> Attachments: HDFS-10752.000.patch
>
>
> 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.
> 
> HDFS-10750
> Similar to the fix for AVRO-115. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
> in line 695, the logging code:
> {code:borderStyle=solid}
> LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
> {code}
> In the same class, there is a method in line 907:
> {code:borderStyle=solid}
>   /**
>* @return NameNode RPC address
>*/
>   public InetSocketAddress getNameNodeAddress() {
> return rpcServer.getRpcAddress();
>   }
> {code}
> We can tell that rpcServer.getRpcAddress() could be replaced by  method 
> getNameNodeAddress() for the case of readability and simplicity
> 
> HDFS-10751
> Similar to the fix for AVRO-115. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtxCache.java
> in line 72, the logging code:
> {code:borderStyle=solid}
> LOG.trace("openFileMap size:" + openFileMap.size());
> {code}
> In the same class, there is a method in line 189:
> {code:borderStyle=solid}
>   int size() {
> return openFileMap.size();
>   }
> {code}
> We can tell that openFileMap.size() could be replaced by  method size() for 
> the case of readability and simplicity
> 
> *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}
> 
> 
> HDFS-10753
> *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-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-10-17 Thread Hanisha Koneru (JIRA)

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

Hanisha Koneru updated HDFS-10752:
--
Attachment: HDFS-10752.000.patch

- HDFS-10749 already resolved
- Replaced _rpcServer.getRpcAddress()_ with the method _getNameNodeAddress()_ 
in NameNode.java
- Replaced _openFileMap.size()_ with the method _size()_ in 
OpenFileCtxCache.java
- Replaced _blk.getBlockName()_ with the _blk (toString())_ in 
CorruptReplicasMap.java

> 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
>Assignee: Hanisha Koneru
>  Labels: easyfix, easytest
> Attachments: HDFS-10752.000.patch
>
>
> 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.
> 
> HDFS-10750
> Similar to the fix for AVRO-115. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
> in line 695, the logging code:
> {code:borderStyle=solid}
> LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
> {code}
> In the same class, there is a method in line 907:
> {code:borderStyle=solid}
>   /**
>* @return NameNode RPC address
>*/
>   public InetSocketAddress getNameNodeAddress() {
> return rpcServer.getRpcAddress();
>   }
> {code}
> We can tell that rpcServer.getRpcAddress() could be replaced by  method 
> getNameNodeAddress() for the case of readability and simplicity
> 
> HDFS-10751
> Similar to the fix for AVRO-115. In file:
> hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtxCache.java
> in line 72, the logging code:
> {code:borderStyle=solid}
> LOG.trace("openFileMap size:" + openFileMap.size());
> {code}
> In the same class, there is a method in line 189:
> {code:borderStyle=solid}
>   int size() {
> return openFileMap.size();
>   }
> {code}
> We can tell that openFileMap.size() could be replaced by  method size() for 
> the case of readability and simplicity
> 
> *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}
> 
> 
> HDFS-10753
> *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 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-12 Thread Nemo Chen (JIRA)

 [ 
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.

HDFS-10750
Similar to the fix for AVRO-115. In file:

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

in line 695, the logging code:
{code:borderStyle=solid}
LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
{code}

In the same class, there is a method in line 907:
{code:borderStyle=solid}
  /**
   * @return NameNode RPC address
   */
  public InetSocketAddress getNameNodeAddress() {
return rpcServer.getRpcAddress();
  }
{code}


We can tell that rpcServer.getRpcAddress() could be replaced by  method 
getNameNodeAddress() for the case of readability and simplicity


HDFS-10751
Similar to the fix for AVRO-115. In file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtxCache.java

in line 72, the logging code:
{code:borderStyle=solid}
LOG.trace("openFileMap size:" + openFileMap.size());
{code}
In the same class, there is a method in line 189:
{code:borderStyle=solid}
  int size() {
return openFileMap.size();
  }
{code}


We can tell that openFileMap.size() could be replaced by  method size() for the 
case of readability and simplicity


*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}



HDFS-10753
*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.
---
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.
---
HDFS-10750
Similar to the fix for AVRO-115. In file:

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

in line 695, the logging code:
{code:borderStyle=solid}
LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
{code}

In the same class, there is 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-12 Thread Nemo Chen (JIRA)

 [ 
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.
---
HDFS-10750
Similar to the fix for AVRO-115. In file:

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

in line 695, the logging code:
{code:borderStyle=solid}
LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
{code}

In the same class, there is a method in line 907:
{code:borderStyle=solid}
  /**
   * @return NameNode RPC address
   */
  public InetSocketAddress getNameNodeAddress() {
return rpcServer.getRpcAddress();
  }
{code}


We can tell that rpcServer.getRpcAddress() could be replaced by  method 
getNameNodeAddress() for the case of readability and simplicity

---
HDFS-10751
Similar to the fix for AVRO-115. In file:

hadoop-rel-release-2.7.2/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtxCache.java

in line 72, the logging code:
{code:borderStyle=solid}
LOG.trace("openFileMap size:" + openFileMap.size());
{code}
In the same class, there is a method in line 189:
{code:borderStyle=solid}
  int size() {
return openFileMap.size();
  }
{code}


We can tell that openFileMap.size() could be replaced by  method size() for the 
case of readability and simplicity

---
*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}



HDFS-10753
*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.
---
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.
---
HDFS-10750
Similar to the fix for AVRO-115. In file:

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

in line 695, the logging code:
{code:borderStyle=solid}
LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
{code}

In the same class, there is a 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-12 Thread Nemo Chen (JIRA)

 [ 
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}



HDFS-10753
*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.
---
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: 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-12 Thread Nemo Chen (JIRA)

 [ 
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.
---
HDFS-10750
Similar to the fix for AVRO-115. In file:

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

in line 695, the logging code:
{code:borderStyle=solid}
LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
{code}

In the same class, there is a method in line 907:
{code:borderStyle=solid}
  /**
   * @return NameNode RPC address
   */
  public InetSocketAddress getNameNodeAddress() {
return rpcServer.getRpcAddress();
  }
{code}


We can tell that rpcServer.getRpcAddress() could be replaced by  method 
getNameNodeAddress() for the case of readability and simplicity

---
HDFS-10751


---
*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}



HDFS-10753
*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.
---
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}



HDFS-10753
*MethodInvocation replaced by variable due to 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-12 Thread Nemo Chen (JIRA)

 [ 
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: 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-12 Thread Nemo Chen (JIRA)

 [ 
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.
*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

  was:
As per conversation with [~vrushalic], we merged HDFS-10753, HDFS-10749 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: 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-11 Thread Nemo Chen (JIRA)

 [ 
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-10753, HDFS-10749 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

  was:
*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();
  }

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-11 Thread Nemo Chen (JIRA)

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

Nemo Chen updated HDFS-10752:
-
Description: 
*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

  was:
*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}

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.

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 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-11 Thread Nemo Chen (JIRA)

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

Nemo Chen updated HDFS-10752:
-
Description: 
*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}

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.

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:
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}

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.

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
> 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-11 Thread Nemo Chen (JIRA)

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

Nemo Chen updated HDFS-10752:
-
Description: 
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}

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.

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:
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}


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.



> 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
>
> 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}
> 
> Similar to the fix for HDFS-409. In file:
> 

[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-11 Thread Nemo Chen (JIRA)

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

Nemo Chen updated HDFS-10752:
-
Description: 
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}


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.


  was:
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}


> 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
>
> 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}
> 
> 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.



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

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



[jira] [Updated] (HDFS-10752) Several log refactoring/improvement suggestion in HDFS

2016-08-11 Thread Nemo Chen (JIRA)

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

Nemo Chen updated HDFS-10752:
-
Summary: Several log refactoring/improvement suggestion in HDFS  (was: 
Variable in byte printed directly in hdfs)

> 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
>
> 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}



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

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