Author: szetszwo
Date: Wed Oct 26 18:28:20 2011
New Revision: 1189363
URL: http://svn.apache.org/viewvc?rev=1189363&view=rev
Log:
svn merge -c 1189361 from branch-0.20-security HDFS-2494.
Modified:
hadoop/common/branches/branch-0.20-security-205/ (props changed)
hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (contents,
props changed)
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/datanode/web/resources/DatanodeWebHdfsMethods.java
Propchange: hadoop/common/branches/branch-0.20-security-205/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 26 18:28:20 2011
@@ -1,6 +1,6 @@
/hadoop/common/branches/branch-0.20:826138,826568,829987,831184,833001,880632,898713,909245,909723,960946,990003,1044225
/hadoop/common/branches/branch-0.20-append:955380,955398,955448,956329
-/hadoop/common/branches/branch-0.20-security:1170042,1170087,1170997,1171137,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1174471,1175114,1176179,1176720,1177907,1179036,1179171,1179519,1179857,1183086,1183101,1183176,1183556,1186509,1187141,1189029
+/hadoop/common/branches/branch-0.20-security:1170042,1170087,1170997,1171137,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1174471,1175114,1176179,1176720,1177907,1179036,1179171,1179519,1179857,1183086,1183101,1183176,1183556,1186509,1187141,1189029,1189361
/hadoop/common/branches/branch-0.20-security-203:1096071,1097011,1097249,1097269,1097281,1097966,1098816,1098819,1098823,1098827,1098832,1098839,1098854,1098863,1099088,1099191,1099324,1099330,1099333,1102071,1128115
/hadoop/common/branches/branch-0.20-security-204:1128390,1147228,1148069,1149316,1154413
/hadoop/core/branches/branch-0.19:713112
Modified: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt?rev=1189363&r1=1189362&r2=1189363&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-205/CHANGES.txt Wed Oct 26
18:28:20 2011
@@ -31,6 +31,9 @@ Release 0.20.205.1 - unreleased
HDFS-2416. Distcp with a webhdfs uri on a secure cluster fails. (jitendra)
+ HDFS-2494. Close the streams and DFSClient in DatanodeWebHdfsMethods.
+ (Uma Maheswara Rao G via szetszwo)
+
Release 0.20.205.0 - 2011.10.06
NEW FEATURES
Propchange: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 26 18:28:20 2011
@@ -1,6 +1,6 @@
/hadoop/common/branches/branch-0.20/CHANGES.txt:826138,826568,829987,831184,833001,880632,898713,909245,909723,960946,990003,1044225
/hadoop/common/branches/branch-0.20-append/CHANGES.txt:955380,955398,955448,956329
-/hadoop/common/branches/branch-0.20-security/CHANGES.txt:1170042,1170087,1170997,1171137,1171181,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1173843,1174326,1174471,1174476,1174482,1175114,1176179,1176182,1176270,1176276,1176675,1176720,1177031,1177036,1177098,1177101,1177907,1178074,1179036,1179171,1179471,1179519,1179713,1179722,1179857,1179919,1183086,1183101,1183176,1183556,1186509,1187141,1189029
+/hadoop/common/branches/branch-0.20-security/CHANGES.txt:1170042,1170087,1170997,1171137,1171181,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1173843,1174326,1174471,1174476,1174482,1175114,1176179,1176182,1176270,1176276,1176675,1176720,1177031,1177036,1177098,1177101,1177907,1178074,1179036,1179171,1179471,1179519,1179713,1179722,1179857,1179919,1183086,1183101,1183176,1183556,1186509,1187141,1189029,1189361
/hadoop/common/branches/branch-0.20-security-203/CHANGES.txt:1096071,1097011,1097249,1097269,1097281,1097966,1098816,1098819,1098823,1098827,1098832,1098839,1098854,1098863,1099088,1099191,1099324,1099330,1099333,1102071,1128115
/hadoop/common/branches/branch-0.20-security-204/CHANGES.txt:1128390,1147228,1148069,1149316,1154413,1159730,1161741
/hadoop/core/branches/branch-0.18/CHANGES.txt:727226
Modified:
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/datanode/web/resources/DatanodeWebHdfsMethods.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/datanode/web/resources/DatanodeWebHdfsMethods.java?rev=1189363&r1=1189362&r2=1189363&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/datanode/web/resources/DatanodeWebHdfsMethods.java
(original)
+++
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/datanode/web/resources/DatanodeWebHdfsMethods.java
Wed Oct 26 18:28:20 2011
@@ -149,15 +149,21 @@ public class DatanodeWebHdfsMethods {
case CREATE:
{
final Configuration conf = new Configuration(datanode.getConf());
- final DFSClient dfsclient = new DFSClient(conf);
final int b = bufferSize.getValue(conf);
- final FSDataOutputStream out = new FSDataOutputStream(dfsclient.create(
- fullpath, permission.getFsPermission(), overwrite.getValue(),
- replication.getValue(conf), blockSize.getValue(conf), null, b),
null);
+ DFSClient dfsclient = new DFSClient(conf);
+ FSDataOutputStream out = null;
try {
+ out = new FSDataOutputStream(dfsclient.create(
+ fullpath, permission.getFsPermission(), overwrite.getValue(),
+ replication.getValue(conf), blockSize.getValue(conf), null, b),
null);
IOUtils.copyBytes(in, out, b);
- } finally {
out.close();
+ out = null;
+ dfsclient.close();
+ dfsclient = null;
+ } finally {
+ IOUtils.cleanup(LOG, out);
+ IOUtils.cleanup(LOG, dfsclient);
}
final String nnAddr = NameNode.getInfoServer(conf);
final URI uri = new URI(WebHdfsFileSystem.SCHEME + "://" + nnAddr +
fullpath);
@@ -220,13 +226,19 @@ public class DatanodeWebHdfsMethods {
case APPEND:
{
final Configuration conf = new Configuration(datanode.getConf());
- final DFSClient dfsclient = new DFSClient(conf);
final int b = bufferSize.getValue(conf);
- final FSDataOutputStream out = dfsclient.append(fullpath, b, null, null);
+ DFSClient dfsclient = new DFSClient(conf);
+ FSDataOutputStream out = null;
try {
+ out = dfsclient.append(fullpath, b, null, null);
IOUtils.copyBytes(in, out, b);
- } finally {
out.close();
+ out = null;
+ dfsclient.close();
+ dfsclient = null;
+ } finally {
+ IOUtils.cleanup(LOG, out);
+ IOUtils.cleanup(LOG, dfsclient);
}
return Response.ok().type(MediaType.APPLICATION_JSON).build();
}
@@ -294,18 +306,36 @@ public class DatanodeWebHdfsMethods {
case OPEN:
{
final int b = bufferSize.getValue(conf);
- final DFSDataInputStream in = new DFSClient.DFSDataInputStream(
- dfsclient.open(fullpath, b, true, null));
- in.seek(offset.getValue());
-
+ DFSDataInputStream in = null;
+ try {
+ in = new DFSClient.DFSDataInputStream(
+ dfsclient.open(fullpath, b, true, null));
+ in.seek(offset.getValue());
+ } catch(IOException ioe) {
+ IOUtils.cleanup(LOG, in);
+ IOUtils.cleanup(LOG, dfsclient);
+ throw ioe;
+ }
+ final DFSDataInputStream dis = in;
final StreamingOutput streaming = new StreamingOutput() {
@Override
public void write(final OutputStream out) throws IOException {
final Long n = length.getValue();
- if (n == null) {
- IOUtils.copyBytes(in, out, b);
- } else {
- IOUtils.copyBytes(in, out, n, b, false);
+ DFSDataInputStream dfsin = dis;
+ DFSClient client = dfsclient;
+ try {
+ if (n == null) {
+ IOUtils.copyBytes(dfsin, out, b);
+ } else {
+ IOUtils.copyBytes(dfsin, out, n, b, false);
+ }
+ dfsin.close();
+ dfsin = null;
+ client.close();
+ client = null;
+ } finally {
+ IOUtils.cleanup(LOG, dfsin);
+ IOUtils.cleanup(LOG, client);
}
}
};
@@ -317,7 +347,15 @@ public class DatanodeWebHdfsMethods {
}
case GETFILECHECKSUM:
{
- final MD5MD5CRC32FileChecksum checksum =
dfsclient.getFileChecksum(fullpath);
+ MD5MD5CRC32FileChecksum checksum = null;
+ DFSClient client = dfsclient;
+ try {
+ checksum = client.getFileChecksum(fullpath);
+ client.close();
+ client = null;
+ } finally {
+ IOUtils.cleanup(LOG, client);
+ }
final String js = JsonUtil.toJsonString(checksum);
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}