You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ra...@apache.org on 2009/05/14 02:01:49 UTC

svn commit: r774602 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/io/DeprecatedUTF8.java src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java

Author: rangadi
Date: Thu May 14 00:01:49 2009
New Revision: 774602

URL: http://svn.apache.org/viewvc?rev=774602&view=rev
Log:
HADOOP-5823. Added a new class DeprecatedUTF8 to help with removing
UTF8 related javac warnings. These warnings are removed in
FSEditLog.java as a use case. (Raghu Angadi)

Added:
    hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java
Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=774602&r1=774601&r2=774602&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu May 14 00:01:49 2009
@@ -346,6 +346,10 @@
    
     HADOOP-5792. To resolve jsp-2.1 jars through ivy (Giridharan Kesavan) 
 
+    HADOOP-5823. Added a new class DeprecatedUTF8 to help with removing
+    UTF8 related javac warnings. These warnings are removed in 
+    FSEditLog.java as a use case. (Raghu Angadi)
+
   OPTIMIZATIONS
 
     HADOOP-5595. NameNode does not need to run a replicator to choose a

Added: hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java?rev=774602&view=auto
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java (added)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java Thu May 14 00:01:49 2009
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.io;
+
+/**
+ * Wrapper for {@link UTF8}.
+ * This class should be used only when it is absolutely necessary
+ * to use {@link UTF8}. The only difference is that using this class
+ * does not require "@SupressWarning" annotation to avoid javac warning. 
+ * In stead the deprecation is implied in the class name.
+ */
+public class DeprecatedUTF8 extends UTF8 {
+  
+  public DeprecatedUTF8() {
+    super();
+  }
+
+  /** Construct from a given string. */
+  public DeprecatedUTF8(String string) {
+    super(string);
+  }
+
+  /** Construct from a given string. */
+  public DeprecatedUTF8(DeprecatedUTF8 utf8) {
+    super(utf8);
+  }
+}

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java?rev=774602&r1=774601&r2=774602&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java Thu May 14 00:01:49 2009
@@ -49,7 +49,7 @@
 import org.apache.hadoop.io.ArrayWritable;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.UTF8;
+import org.apache.hadoop.io.DeprecatedUTF8;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableFactories;
 import org.apache.hadoop.io.WritableFactory;
@@ -1088,32 +1088,32 @@
    */
   public void logOpenFile(String path, INodeFileUnderConstruction newNode) {
 
-    UTF8 nameReplicationPair[] = new UTF8[] { 
-      new UTF8(path), 
+    DeprecatedUTF8 nameReplicationPair[] = new DeprecatedUTF8[] { 
+      new DeprecatedUTF8(path), 
       FSEditLog.toLogReplication(newNode.getReplication()),
       FSEditLog.toLogLong(newNode.getModificationTime()),
       FSEditLog.toLogLong(newNode.getAccessTime()),
       FSEditLog.toLogLong(newNode.getPreferredBlockSize())};
     logEdit(OP_ADD,
-            new ArrayWritable(UTF8.class, nameReplicationPair), 
+            new ArrayWritable(DeprecatedUTF8.class, nameReplicationPair), 
             new ArrayWritable(Block.class, newNode.getBlocks()),
             newNode.getPermissionStatus(),
-            new UTF8(newNode.getClientName()),
-            new UTF8(newNode.getClientMachine()));
+            new DeprecatedUTF8(newNode.getClientName()),
+            new DeprecatedUTF8(newNode.getClientMachine()));
   }
 
   /** 
    * Add close lease record to edit log.
    */
   public void logCloseFile(String path, INodeFile newNode) {
-    UTF8 nameReplicationPair[] = new UTF8[] {
-      new UTF8(path),
+    DeprecatedUTF8 nameReplicationPair[] = new DeprecatedUTF8[] {
+      new DeprecatedUTF8(path),
       FSEditLog.toLogReplication(newNode.getReplication()),
       FSEditLog.toLogLong(newNode.getModificationTime()),
       FSEditLog.toLogLong(newNode.getAccessTime()),
       FSEditLog.toLogLong(newNode.getPreferredBlockSize())};
     logEdit(OP_CLOSE,
-            new ArrayWritable(UTF8.class, nameReplicationPair),
+            new ArrayWritable(DeprecatedUTF8.class, nameReplicationPair),
             new ArrayWritable(Block.class, newNode.getBlocks()),
             newNode.getPermissionStatus());
   }
@@ -1122,12 +1122,12 @@
    * Add create directory record to edit log
    */
   public void logMkDir(String path, INode newNode) {
-    UTF8 info[] = new UTF8[] {
-      new UTF8(path),
+    DeprecatedUTF8 info[] = new DeprecatedUTF8[] {
+      new DeprecatedUTF8(path),
       FSEditLog.toLogLong(newNode.getModificationTime()),
       FSEditLog.toLogLong(newNode.getAccessTime())
     };
-    logEdit(OP_MKDIR, new ArrayWritable(UTF8.class, info),
+    logEdit(OP_MKDIR, new ArrayWritable(DeprecatedUTF8.class, info),
         newNode.getPermissionStatus());
   }
   
@@ -1136,11 +1136,11 @@
    * TODO: use String parameters until just before writing to disk
    */
   void logRename(String src, String dst, long timestamp) {
-    UTF8 info[] = new UTF8[] { 
-      new UTF8(src),
-      new UTF8(dst),
+    DeprecatedUTF8 info[] = new DeprecatedUTF8[] { 
+      new DeprecatedUTF8(src),
+      new DeprecatedUTF8(dst),
       FSEditLog.toLogLong(timestamp)};
-    logEdit(OP_RENAME, new ArrayWritable(UTF8.class, info));
+    logEdit(OP_RENAME, new ArrayWritable(DeprecatedUTF8.class, info));
   }
   
   /** 
@@ -1148,7 +1148,7 @@
    */
   void logSetReplication(String src, short replication) {
     logEdit(OP_SET_REPLICATION, 
-            new UTF8(src), 
+            new DeprecatedUTF8(src), 
             FSEditLog.toLogReplication(replication));
   }
   
@@ -1158,30 +1158,30 @@
    * @param quota the directory size limit
    */
   void logSetQuota(String src, long nsQuota, long dsQuota) {
-    logEdit(OP_SET_QUOTA, new UTF8(src), 
+    logEdit(OP_SET_QUOTA, new DeprecatedUTF8(src), 
             new LongWritable(nsQuota), new LongWritable(dsQuota));
   }
 
   /**  Add set permissions record to edit log */
   void logSetPermissions(String src, FsPermission permissions) {
-    logEdit(OP_SET_PERMISSIONS, new UTF8(src), permissions);
+    logEdit(OP_SET_PERMISSIONS, new DeprecatedUTF8(src), permissions);
   }
 
   /**  Add set owner record to edit log */
   void logSetOwner(String src, String username, String groupname) {
-    UTF8 u = new UTF8(username == null? "": username);
-    UTF8 g = new UTF8(groupname == null? "": groupname);
-    logEdit(OP_SET_OWNER, new UTF8(src), u, g);
+    DeprecatedUTF8 u = new DeprecatedUTF8(username == null? "": username);
+    DeprecatedUTF8 g = new DeprecatedUTF8(groupname == null? "": groupname);
+    logEdit(OP_SET_OWNER, new DeprecatedUTF8(src), u, g);
   }
 
   /** 
    * Add delete file record to edit log
    */
   void logDelete(String src, long timestamp) {
-    UTF8 info[] = new UTF8[] { 
-      new UTF8(src),
+    DeprecatedUTF8 info[] = new DeprecatedUTF8[] { 
+      new DeprecatedUTF8(src),
       FSEditLog.toLogLong(timestamp)};
-    logEdit(OP_DELETE, new ArrayWritable(UTF8.class, info));
+    logEdit(OP_DELETE, new ArrayWritable(DeprecatedUTF8.class, info));
   }
 
   /** 
@@ -1195,19 +1195,19 @@
    * Add access time record to edit log
    */
   void logTimes(String src, long mtime, long atime) {
-    UTF8 info[] = new UTF8[] { 
-      new UTF8(src),
+    DeprecatedUTF8 info[] = new DeprecatedUTF8[] { 
+      new DeprecatedUTF8(src),
       FSEditLog.toLogLong(mtime),
       FSEditLog.toLogLong(atime)};
-    logEdit(OP_TIMES, new ArrayWritable(UTF8.class, info));
+    logEdit(OP_TIMES, new ArrayWritable(DeprecatedUTF8.class, info));
   }
   
-  static private UTF8 toLogReplication(short replication) {
-    return new UTF8(Short.toString(replication));
+  static private DeprecatedUTF8 toLogReplication(short replication) {
+    return new DeprecatedUTF8(Short.toString(replication));
   }
   
-  static private UTF8 toLogLong(long timestamp) {
-    return new UTF8(Long.toString(timestamp));
+  static private DeprecatedUTF8 toLogLong(long timestamp) {
+    return new DeprecatedUTF8(Long.toString(timestamp));
   }
 
   /**