hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r540727 - in /lucene/hadoop/trunk: ./ src/java/org/apache/hadoop/dfs/
Date Tue, 22 May 2007 20:03:42 GMT
Author: cutting
Date: Tue May 22 13:03:41 2007
New Revision: 540727

URL: http://svn.apache.org/viewvc?view=rev&rev=540727
Log:
HADOOP-1394.  Implement 'performance' code cleanups in HDFS suggested by findbugs.  Contributed
by Raghu.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/BlocksMap.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeID.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NamenodeFsck.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/PendingReplicationBlocks.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ReplicationTargetChooser.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/TransferFsImage.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue May 22 13:03:41 2007
@@ -54,6 +54,9 @@
  17. HADOOP-1406.  Plug a leak in MapReduce's use of metrics.
      (David Bowen via cutting)
 
+ 14. HADOOP-1394.  Implement "performance" code-cleanups in HDFS
+     suggested by findbugs.  (Raghu Angadi via cutting)
+
 
 Branch 0.13 (unreleased changes)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/BlocksMap.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/BlocksMap.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/BlocksMap.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/BlocksMap.java Tue May 22 13:03:41
2007
@@ -29,7 +29,7 @@
   /**
    * Internal class for block metadata.
    */
-  class BlockInfo {
+  static class BlockInfo {
     private FSDirectory.INode              inode;
       
     /** nodes could contain some null entries at the end, so 
@@ -40,7 +40,7 @@
     private Block                          block; //block that was inserted.   
   }
       
-  private class NodeIterator implements Iterator<DatanodeDescriptor> {
+  private static class NodeIterator implements Iterator<DatanodeDescriptor> {
     NodeIterator(DatanodeDescriptor[] nodes) {
       arr = nodes;
     }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java Tue May 22 13:03:41
2007
@@ -1240,7 +1240,7 @@
     }
 
     private LocatedBlock locateNewBlock() throws IOException {     
-      return namenode.create(src.toString(), clientName.toString(),
+      return namenode.create(src.toString(), clientName,
           overwrite, replication, blockSize);
     }
         
@@ -1252,8 +1252,7 @@
         long localstart = System.currentTimeMillis();
         while (true) {
           try {
-            return namenode.addBlock(src.toString(), 
-                                     clientName.toString());
+            return namenode.addBlock(src.toString(), clientName);
           } catch (RemoteException e) {
             if (--retries == 0 || 
                 !NotReplicatedYetException.class.getName().
@@ -1502,7 +1501,7 @@
         long localstart = System.currentTimeMillis();
         boolean fileComplete = false;
         while (!fileComplete) {
-          fileComplete = namenode.complete(src.toString(), clientName.toString());
+          fileComplete = namenode.complete(src.toString(), clientName);
           if (!fileComplete) {
             try {
               Thread.sleep(400);

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java Tue May 22 13:03:41 2007
@@ -126,7 +126,7 @@
   private static Thread dataNodeThread = null;
   String machineName;
 
-  private class DataNodeMetrics implements Updater {
+  private static class DataNodeMetrics implements Updater {
     private final MetricsRecord metricsRecord;
     private int bytesWritten = 0;
     private int bytesRead = 0;

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeID.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeID.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeID.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeID.java Tue May 22 13:03:41
2007
@@ -24,7 +24,7 @@
    * DatanodeID default constructor
    */
   public DatanodeID() {
-    this(new String(), new String(), -1);
+    this("", "", -1);
   }
 
   /**

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java Tue May 22 13:03:41
2007
@@ -345,7 +345,7 @@
     }
   }
     
-  class FSVolumeSet {
+  static class FSVolumeSet {
     FSVolume[] volumes = null;
     int curVolume = 0;
       

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java Tue May 22 13:03:41
2007
@@ -461,7 +461,7 @@
       if (isDir(dst)) {
         dstStr += "/" + new File(srcStr).getName();
       }
-      if (rootDir.getNode(dstStr.toString()) != null) {
+      if (rootDir.getNode(dstStr) != null) {
         NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
                                      +"failed to rename "+src+" to "+dstStr+ " because destination
exists");
         return false;
@@ -499,7 +499,7 @@
    */
   Block[] setReplication(String src, 
                          short replication,
-                         Vector<Integer> oldReplication
+                         int[] oldReplication
                          ) throws IOException {
     waitForReady();
     Block[] fileBlocks = unprotectedSetReplication(src, replication, oldReplication);
@@ -510,12 +510,11 @@
 
   Block[] unprotectedSetReplication( String src, 
                                      short replication,
-                                     Vector<Integer> oldReplication
+                                     int[] oldReplication
                                      ) throws IOException {
     if (oldReplication == null)
-      oldReplication = new Vector<Integer>();
-    oldReplication.setSize(1);
-    oldReplication.set(0, new Integer(-1));
+      oldReplication = new int[1];
+    oldReplication[0] = -1;
     Block[] fileBlocks = null;
     synchronized(rootDir) {
       INode fileNode = rootDir.getNode(src);
@@ -523,7 +522,7 @@
         return null;
       if (fileNode.isDir())
         return null;
-      oldReplication.set(0, new Integer(fileNode.blockReplication));
+      oldReplication[0] = fileNode.blockReplication;
       fileNode.blockReplication = replication;
       fileBlocks = fileNode.blocks;
     }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java Tue May 22 13:03:41
2007
@@ -510,12 +510,12 @@
       throw new SafeModeException("Cannot set replication for " + src, safeMode);
     verifyReplication(src, replication, null);
 
-    Vector<Integer> oldReplication = new Vector<Integer>();
+    int[] oldReplication = new int[1];
     Block[] fileBlocks;
     fileBlocks = dir.setReplication(src, replication, oldReplication);
     if (fileBlocks == null)  // file not found or is a directory
       return false;
-    int oldRepl = oldReplication.elementAt(0).intValue();
+    int oldRepl = oldReplication[0];
     if (oldRepl == replication) // the same replication
       return true;
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Tue May 22 13:03:41 2007
@@ -99,7 +99,7 @@
     format(conf, false);
   }
 
-  private class NameNodeMetrics implements Updater {
+  private static class NameNodeMetrics implements Updater {
     private final MetricsRecord metricsRecord;
     private int numFilesCreated = 0;
     private int numFilesOpened = 0;
@@ -166,7 +166,7 @@
 
     // The rpc-server port can be ephemeral... ensure we have the correct info
     this.nameNodeAddress = this.server.getListenerAddress(); 
-    conf.set("fs.default.name", new String(nameNodeAddress.getHostName() + ":" + nameNodeAddress.getPort()));
+    conf.set("fs.default.name", nameNodeAddress.getHostName() + ":" + nameNodeAddress.getPort());
     LOG.info("Namenode up at: " + this.nameNodeAddress);
 
     try {

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NamenodeFsck.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NamenodeFsck.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NamenodeFsck.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NamenodeFsck.java Tue May 22 13:03:41
2007
@@ -270,7 +270,7 @@
           continue;
         }
         if (fos == null) {
-          fos = dfs.create(new UTF8(target.toString() + "/" + chain), true);
+          fos = dfs.create(new UTF8(target + "/" + chain), true);
           if (fos != null) chain++;
         }
         if (fos == null) {
@@ -464,7 +464,7 @@
    *
    * @author Andrzej Bialecki
    */
-  public class FsckResult {
+  public static class FsckResult {
     private ArrayList<String> missingIds = new ArrayList<String>();
     private long missingSize = 0L;
     private long corruptFiles = 0L;

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/PendingReplicationBlocks.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/PendingReplicationBlocks.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/PendingReplicationBlocks.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/PendingReplicationBlocks.java Tue May
22 13:03:41 2007
@@ -142,7 +142,7 @@
    * block. It also records the number of replication
    * requests that are in progress.
    */
-  class PendingBlockInfo {
+  static class PendingBlockInfo {
     private long timeStamp;
     private int numReplicasInProgress;
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ReplicationTargetChooser.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ReplicationTargetChooser.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ReplicationTargetChooser.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ReplicationTargetChooser.java Tue May
22 13:03:41 2007
@@ -46,7 +46,7 @@
     this.logr = logr;
   }
     
-  private class NotEnoughReplicasException extends Exception {
+  private static class NotEnoughReplicasException extends Exception {
     NotEnoughReplicasException(String msg) {
       super(msg);
     }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/TransferFsImage.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/TransferFsImage.java?view=diff&rev=540727&r1=540726&r2=540727
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/TransferFsImage.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/TransferFsImage.java Tue May 22 13:03:41
2007
@@ -19,20 +19,10 @@
 
 import java.io.*;
 import java.net.*;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Random;
-import java.util.TreeSet;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.UTF8;
-
 
 /**
  * This class provides fetching a specified file from the NameNode.
@@ -40,7 +30,6 @@
  */
 class TransferFsImage implements FSConstants {
   
-  private HttpServletResponse response;
   private boolean isGetImage;
   private boolean isGetEdit;
   private boolean isPutImage;



Mime
View raw message