hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r923467 - in /hadoop/hdfs/trunk: ./ src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ src/java/org/apache/hadoop/hdfs/ src/java/org/apache/hadoop/hdfs/protocol/ src/java/org/apache/hadoop/hdfs/server/common/ src/java/org/apache/ha...
Date Mon, 15 Mar 2010 22:20:18 GMT
Author: suresh
Date: Mon Mar 15 22:20:17 2010
New Revision: 923467

URL: http://svn.apache.org/viewvc?rev=923467&view=rev
Log:
HDFS-968. Use StringBuilder instead of StringBuffer for better performance. Contributed by
Kay Kay.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUtil.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HsftpFileSystem.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/common/Storage.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Mon Mar 15 22:20:17 2010
@@ -31,6 +31,8 @@ Trunk (unreleased changes)
     symlink feature added in HADOOP-6421 (Eli Collins via Sanjay Radia)
 
   IMPROVEMENTS
+    HDFS-968. Use StringBuilder instead of StringBuffer for better
+    performance. (Kay Kay via suresh)
     
     HDFS-703. Replace current fault injection implementation with one
     from (cos)

Modified: hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUtil.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUtil.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUtil.java
(original)
+++ hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUtil.java
Mon Mar 15 22:20:17 2010
@@ -189,7 +189,7 @@ public class ProxyUtil {
         connection = openConnection(hostname, sslPort, path);
         connection.connect();
         if (LOG.isDebugEnabled()) {
-          StringBuffer sb = new StringBuffer();
+          StringBuilder sb = new StringBuilder();
           X509Certificate[] clientCerts = (X509Certificate[]) connection
               .getLocalCertificates();
           if (clientCerts != null) {
@@ -279,7 +279,7 @@ public class ProxyUtil {
     long curTime = curDate.getTime();
     if (serverCerts != null) {
       for (X509Certificate cert : serverCerts) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         sb.append("\n Server certificate Subject Name: "
             + cert.getSubjectX500Principal().getName());
         Date expDate = cert.getNotAfter();

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HsftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HsftpFileSystem.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HsftpFileSystem.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HsftpFileSystem.java Mon Mar 15 22:20:17
2010
@@ -140,7 +140,7 @@ public class HsftpFileSystem extends Hft
           for (X509Certificate cert : clientCerts) {
             long expTime = cert.getNotAfter().getTime();
             if (expTime < expTimeThreshold) {
-              StringBuffer sb = new StringBuffer();
+              StringBuilder sb = new StringBuilder();
               sb.append("\n Client certificate "
                   + cert.getSubjectX500Principal().getName());
               int dayOffSet = (int) ((expTime - System.currentTimeMillis()) / MM_SECONDS_PER_DAY);

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java Mon Mar 15
22:20:17 2010
@@ -166,7 +166,7 @@ public class DatanodeInfo extends Datano
   
   /** A formatted string for reporting the status of the DataNode. */
   public String getDatanodeReport() {
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
     long c = getCapacity();
     long r = getRemaining();
     long u = getDfsUsed();
@@ -203,7 +203,7 @@ public class DatanodeInfo extends Datano
 
   /** A formatted string for printing the status of the DataNode. */
   public String dumpDatanode() {
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
     long c = getCapacity();
     long r = getRemaining();
     long u = getDfsUsed();

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/common/Storage.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/common/Storage.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/common/Storage.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/common/Storage.java Mon Mar 15
22:20:17 2010
@@ -181,7 +181,7 @@ public abstract class Storage extends St
    * generate storage list (debug line)
    */
   public String listStorageDirectories() {
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
     for (StorageDirectory sd : storageDirs) {
       buf.append(sd.getRoot() + "(" + sd.getStorageDirType() + ");");
     }

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java Mon Mar
15 22:20:17 2010
@@ -642,7 +642,7 @@ public class FSDataset implements FSCons
     }
       
     public String toString() {
-      StringBuffer sb = new StringBuffer();
+      StringBuilder sb = new StringBuilder();
       for (int idx = 0; idx < volumes.length; idx++) {
         sb.append(volumes[idx].toString());
         if (idx != volumes.length - 1) { sb.append(","); }

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java Mon
Mar 15 22:20:17 2010
@@ -893,7 +893,7 @@ public class BlockManager {
           replIndex--;
         }
         if (NameNode.stateChangeLog.isInfoEnabled()) {
-          StringBuffer targetList = new StringBuffer("datanode(s)");
+          StringBuilder targetList = new StringBuilder("datanode(s)");
           for (int k = 0; k < targets.length; k++) {
             targetList.append(' ');
             targetList.append(targets[k].getName());
@@ -1390,7 +1390,7 @@ public class BlockManager {
     int curExpectedReplicas = getReplication(block);
     INode fileINode = blocksMap.getINode(block);
     Iterator<DatanodeDescriptor> nodeIter = blocksMap.nodeIterator(block);
-    StringBuffer nodeList = new StringBuffer();
+    StringBuilder nodeList = new StringBuilder();
     while (nodeIter.hasNext()) {
       DatanodeDescriptor node = nodeIter.next();
       nodeList.append(node.name);
@@ -1582,7 +1582,7 @@ public class BlockManager {
       dn.addBlocksToBeInvalidated(blocksToInvalidate);
 
       if (NameNode.stateChangeLog.isInfoEnabled()) {
-        StringBuffer blockList = new StringBuffer();
+        StringBuilder blockList = new StringBuilder();
         for (Block blk : blocksToInvalidate) {
           blockList.append(' ');
           blockList.append(blk);

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java Mon
Mar 15 22:20:17 2010
@@ -220,7 +220,7 @@ public class NamenodeFsck {
     long missize = 0;
     int underReplicatedPerFile = 0;
     int misReplicatedPerFile = 0;
-    StringBuffer report = new StringBuffer();
+    StringBuilder report = new StringBuilder();
     int i = 0;
     for (LocatedBlock lBlk : blocks.getLocatedBlocks()) {
       Block block = lBlk.getBlock();
@@ -278,7 +278,7 @@ public class NamenodeFsck {
       } else {
         report.append(" repl=" + locs.length);
         if (showLocations || showRacks) {
-          StringBuffer sb = new StringBuffer("[");
+          StringBuilder sb = new StringBuilder("[");
           for (int j = 0; j < locs.length; j++) {
             if (j > 0) { sb.append(", "); }
             if (showRacks)
@@ -573,7 +573,7 @@ public class NamenodeFsck {
     
     /** {@inheritDoc} */
     public String toString() {
-      StringBuffer res = new StringBuffer();
+      StringBuilder res = new StringBuilder();
       res.append("Status: " + (isHealthy() ? "HEALTHY" : "CORRUPT"));
       res.append("\n Total size:\t" + totalSize + " B");
       if (totalOpenFilesSize != 0) 

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java
(original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java
Mon Mar 15 22:20:17 2010
@@ -140,7 +140,7 @@ class TransferFsImage implements FSConst
   static void getFileClient(String fsName, String id, File[] localPath)
     throws IOException {
     byte[] buf = new byte[BUFFER_SIZE];
-    StringBuffer str = new StringBuffer("http://"+fsName+"/getimage?");
+    StringBuilder str = new StringBuilder("http://"+fsName+"/getimage?");
     str.append(id);
 
     //

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java?rev=923467&r1=923466&r2=923467&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java Mon Mar 15 22:20:17
2010
@@ -103,7 +103,7 @@ public class DFSck extends Configured im
       return -1;
     }
 
-    final StringBuffer url = new StringBuffer("http://");
+    final StringBuilder url = new StringBuilder("http://");
     url.append(getConf().get(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, 
                              DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_DEFAULT));
     url.append("/fsck?ugi=").append(ugi.getShortUserName()).append("&path=");



Mime
View raw message