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/15 18:09:06 UTC
svn commit: r775210 - in /hadoop/core/trunk: ./
src/core/org/apache/hadoop/io/ src/hdfs/org/apache/hadoop/hdfs/
src/hdfs/org/apache/hadoop/hdfs/protocol/
src/hdfs/org/apache/hadoop/hdfs/server/balancer/
src/hdfs/org/apache/hadoop/hdfs/server/common/ sr...
Author: rangadi
Date: Fri May 15 16:09:05 2009
New Revision: 775210
URL: http://svn.apache.org/viewvc?rev=775210&view=rev
Log:
HADOOP-5838. Fix a few javac warnings in HDFS. (Raghu Angadi)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSUtil.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/AlreadyBeingCreatedException.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/DatanodeID.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/balancer/Balancer.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java
hadoop/core/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri May 15 16:09:05 2009
@@ -356,6 +356,8 @@
HADOOP-5721. Factor out EditLogFileInputStream and EditLogFileOutputStream
into independent classes. (Luca Telloli & Flavio Junqueira via shv)
+ HADOOP-5838. Fix a few javac warnings in HDFS. (Raghu Angadi)
+
OPTIMIZATIONS
HADOOP-5595. NameNode does not need to run a replicator to choose a
Modified: 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=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/io/DeprecatedUTF8.java Fri May 15 16:09:05 2009
@@ -18,13 +18,18 @@
package org.apache.hadoop.io;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
/**
* 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.
+ * does not require "@SuppressWarning" annotation to avoid javac warning.
+ * Instead the deprecation is implied in the class name.
*/
+@SuppressWarnings("deprecation")
public class DeprecatedUTF8 extends UTF8 {
public DeprecatedUTF8() {
@@ -40,4 +45,16 @@
public DeprecatedUTF8(DeprecatedUTF8 utf8) {
super(utf8);
}
+
+ /* The following two are the mostly commonly used methods.
+ * wrapping them so that editors do not complain about the deprecation.
+ */
+
+ public static String readString(DataInput in) throws IOException {
+ return UTF8.readString(in);
+ }
+
+ public static int writeString(DataOutput out, String s) throws IOException {
+ return UTF8.writeString(out, s);
+ }
}
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSUtil.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSUtil.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSUtil.java Fri May 15 16:09:05 2009
@@ -47,5 +47,35 @@
return true;
}
+ /**
+ * Utility class to facilitate junit test error simulation.
+ */
+ public static class ErrorSimulator {
+ private static boolean[] simulation = null; // error simulation events
+ public static void initializeErrorSimulationEvent(int numberOfEvents) {
+ simulation = new boolean[numberOfEvents];
+ for (int i = 0; i < numberOfEvents; i++) {
+ simulation[i] = false;
+ }
+ }
+
+ public static boolean getErrorSimulation(int index) {
+ if(simulation == null)
+ return false;
+ assert(index < simulation.length);
+ return simulation[index];
+ }
+
+ public static void setErrorSimulation(int index) {
+ assert(index < simulation.length);
+ simulation[index] = true;
+ }
+
+ public static void clearErrorSimulation(int index) {
+ assert(index < simulation.length);
+ simulation[index] = false;
+ }
+ }
+
}
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java Fri May 15 16:09:05 2009
@@ -58,7 +58,7 @@
public DistributedFileSystem() {
}
- /** @deprecated */
+ @Deprecated
public DistributedFileSystem(InetSocketAddress namenode,
Configuration conf) throws IOException {
initialize(NameNode.getUri(namenode), conf);
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/AlreadyBeingCreatedException.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/AlreadyBeingCreatedException.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/AlreadyBeingCreatedException.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/AlreadyBeingCreatedException.java Fri May 15 16:09:05 2009
@@ -25,6 +25,7 @@
* is being created, but is not closed yet.
*/
public class AlreadyBeingCreatedException extends IOException {
+ static final long serialVersionUID = 0x12308AD009L;
public AlreadyBeingCreatedException(String msg) {
super(msg);
}
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/DatanodeID.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/DatanodeID.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/DatanodeID.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/protocol/DatanodeID.java Fri May 15 16:09:05 2009
@@ -22,7 +22,7 @@
import java.io.DataOutput;
import java.io.IOException;
-import org.apache.hadoop.io.UTF8;
+import org.apache.hadoop.io.DeprecatedUTF8;
import org.apache.hadoop.io.WritableComparable;
/**
@@ -170,15 +170,15 @@
/////////////////////////////////////////////////
/** {@inheritDoc} */
public void write(DataOutput out) throws IOException {
- UTF8.writeString(out, name);
- UTF8.writeString(out, storageID);
+ DeprecatedUTF8.writeString(out, name);
+ DeprecatedUTF8.writeString(out, storageID);
out.writeShort(infoPort);
}
/** {@inheritDoc} */
public void readFields(DataInput in) throws IOException {
- name = UTF8.readString(in);
- storageID = UTF8.readString(in);
+ name = DeprecatedUTF8.readString(in);
+ storageID = DeprecatedUTF8.readString(in);
// the infoPort read could be negative, if the port is a large number (more
// than 15 bits in storage size (but less than 16 bits).
// So chop off the first two bytes (and hence the signed bits) before
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/balancer/Balancer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/balancer/Balancer.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/balancer/Balancer.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/balancer/Balancer.java Fri May 15 16:09:05 2009
@@ -641,7 +641,7 @@
*/
private long getBlockList() throws IOException {
BlockWithLocations[] newBlocks = namenode.getBlocks(datanode,
- (long)Math.min(MAX_BLOCKS_SIZE_TO_FETCH, blocksToReceive)).getBlocks();
+ Math.min(MAX_BLOCKS_SIZE_TO_FETCH, blocksToReceive)).getBlocks();
long bytesReceived = 0;
for (BlockWithLocations blk : newBlocks) {
bytesReceived += blk.getBlock().getNumBytes();
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java Fri May 15 16:09:05 2009
@@ -767,7 +767,7 @@
file.seek(0);
file.writeInt(FSConstants.LAYOUT_VERSION);
- org.apache.hadoop.io.UTF8.writeString(file, "");
+ org.apache.hadoop.io.DeprecatedUTF8.writeString(file, "");
file.writeBytes(messageForPreUpgradeVersion);
file.getFD().sync();
}
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java Fri May 15 16:09:05 2009
@@ -29,7 +29,7 @@
import org.apache.hadoop.hdfs.server.protocol.BlockCommand;
import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol;
import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.UTF8;
+import org.apache.hadoop.io.DeprecatedUTF8;
import org.apache.hadoop.io.WritableUtils;
/**************************************************
@@ -411,8 +411,8 @@
/** Serialization for FSEditLog */
void readFieldsFromFSEditLog(DataInput in) throws IOException {
- this.name = UTF8.readString(in);
- this.storageID = UTF8.readString(in);
+ this.name = DeprecatedUTF8.readString(in);
+ this.storageID = DeprecatedUTF8.readString(in);
this.infoPort = in.readShort() & 0x0000ffff;
this.capacity = in.readLong();
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java Fri May 15 16:09:05 2009
@@ -51,7 +51,7 @@
import org.apache.hadoop.hdfs.server.common.HdfsConstants.NamenodeRole;
import org.apache.hadoop.hdfs.server.common.HdfsConstants.NodeType;
import org.apache.hadoop.hdfs.server.common.HdfsConstants.StartupOption;
-import org.apache.hadoop.io.UTF8;
+import org.apache.hadoop.io.DeprecatedUTF8;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo;
@@ -410,7 +410,8 @@
StorageState curState = dataDirStates.get(sd);
switch(curState) {
case NON_EXISTENT:
- assert false : StorageState.NON_EXISTENT + " state cannot be here";
+ throw new IOException(StorageState.NON_EXISTENT +
+ " state cannot be here");
case NOT_FORMATTED:
LOG.info("Storage directory " + sd.getRoot() + " is not formatted.");
LOG.info("Formatting ...");
@@ -1839,7 +1840,7 @@
return dirs;
}
- static private final UTF8 U_STR = new UTF8();
+ static private final DeprecatedUTF8 U_STR = new DeprecatedUTF8();
// This should be reverted to package private once the ImageLoader
// code is moved into this package. This method should not be called
// by other code.
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java Fri May 15 16:09:05 2009
@@ -31,6 +31,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hdfs.DFSUtil.ErrorSimulator;
import org.apache.hadoop.hdfs.server.common.HdfsConstants;
import org.apache.hadoop.hdfs.server.common.InconsistentFSStateException;
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
@@ -91,35 +92,6 @@
+ "\nCheckpoint Dirs : " + checkpointDirs
+ "\nCheckpoint Edits Dirs: " + checkpointEditsDirs;
}
- /**
- * Utility class to facilitate junit test error simulation.
- */
- static class ErrorSimulator {
- private static boolean[] simulation = null; // error simulation events
- static void initializeErrorSimulationEvent(int numberOfEvents) {
- simulation = new boolean[numberOfEvents];
- for (int i = 0; i < numberOfEvents; i++) {
- simulation[i] = false;
- }
- }
-
- static boolean getErrorSimulation(int index) {
- if(simulation == null)
- return false;
- assert(index < simulation.length);
- return simulation[index];
- }
-
- static void setErrorSimulation(int index) {
- assert(index < simulation.length);
- simulation[index] = true;
- }
-
- static void clearErrorSimulation(int index) {
- assert(index < simulation.length);
- simulation[index] = false;
- }
- }
FSImage getFSImage() {
return checkpointImage;
@@ -315,7 +287,7 @@
// Tell the namenode to start logging transactions in a new edit file
// Returns a token that would be used to upload the merged image.
- CheckpointSignature sig = (CheckpointSignature)namenode.rollEditLog();
+ CheckpointSignature sig = namenode.rollEditLog();
// error simulation code for junit test
if (ErrorSimulator.getErrorSimulation(0)) {
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java Fri May 15 16:09:05 2009
@@ -25,7 +25,7 @@
import javax.servlet.http.HttpServletRequest;
import org.apache.hadoop.hdfs.protocol.FSConstants;
-import org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.ErrorSimulator;
+import org.apache.hadoop.hdfs.DFSUtil.ErrorSimulator;
/**
* This class provides fetching a specified file from the NameNode.
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java Fri May 15 16:09:05 2009
@@ -25,7 +25,7 @@
import org.apache.hadoop.hdfs.protocol.FSConstants;
import org.apache.hadoop.hdfs.server.common.Storage;
import org.apache.hadoop.hdfs.server.common.StorageInfo;
-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;
@@ -70,13 +70,13 @@
}
public void write(DataOutput out) throws IOException {
- UTF8.writeString(out, getBuildVersion());
+ DeprecatedUTF8.writeString(out, getBuildVersion());
super.write(out);
out.writeInt(getDistributedUpgradeVersion());
}
public void readFields(DataInput in) throws IOException {
- buildVersion = UTF8.readString(in);
+ buildVersion = DeprecatedUTF8.readString(in);
super.readFields(in);
distributedUpgradeVersion = in.readInt();
}
Modified: hadoop/core/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java?rev=775210&r1=775209&r2=775210&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java (original)
+++ hadoop/core/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java Fri May 15 16:09:05 2009
@@ -30,7 +30,7 @@
import org.apache.hadoop.hdfs.protocol.FSConstants.SafeModeAction;
import org.apache.hadoop.hdfs.server.common.Storage;
import org.apache.hadoop.hdfs.server.namenode.FSImage.NameNodeFile;
-import org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.ErrorSimulator;
+import org.apache.hadoop.hdfs.DFSUtil.ErrorSimulator;
import org.apache.hadoop.hdfs.server.common.HdfsConstants.StartupOption;
import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory;
import org.apache.hadoop.hdfs.server.namenode.FSImage.NameNodeDirType;