[29/50] [abbrv] hadoop git commit: HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by Andras Bokor.

2016-07-25 Thread vvasudev
HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by 
Andras Bokor.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fcde6940
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fcde6940
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fcde6940

Branch: refs/heads/YARN-3926
Commit: fcde6940e0cbdedb1105007e4857137ecdfa1284
Parents: bd3dcf4
Author: Akira Ajisaka 
Authored: Thu Jul 21 11:25:28 2016 -0700
Committer: Akira Ajisaka 
Committed: Thu Jul 21 11:26:08 2016 -0700

--
 .../org/apache/hadoop/hdfs/MiniDFSCluster.java  |  7 ++-
 .../apache/hadoop/hdfs/TestMiniDFSCluster.java  | 53 +++-
 2 files changed, 24 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/fcde6940/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
index 3b3a88b..3bb3a10 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
@@ -136,7 +136,7 @@ import com.google.common.collect.Sets;
  */
 @InterfaceAudience.LimitedPrivate({"HBase", "HDFS", "Hive", "MapReduce", 
"Pig"})
 @InterfaceStability.Unstable
-public class MiniDFSCluster {
+public class MiniDFSCluster implements AutoCloseable {
 
   private static final String NAMESERVICE_ID_PREFIX = "nameserviceId";
   private static final Log LOG = LogFactory.getLog(MiniDFSCluster.class);
@@ -3057,4 +3057,9 @@ public class MiniDFSCluster {
   writer.close();
 }
   }
+
+  @Override
+  public void close() {
+shutdown();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fcde6940/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
index ec72d87..4d027dc 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
@@ -64,22 +64,17 @@ public class TestMiniDFSCluster {
   public void testClusterWithoutSystemProperties() throws Throwable {
 String oldPrp = System.getProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
 System.clearProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
-MiniDFSCluster cluster = null;
-try {
-  Configuration conf = new HdfsConfiguration();
-  File testDataCluster1 = new File(testDataPath, CLUSTER_1);
-  String c1Path = testDataCluster1.getAbsolutePath();
-  conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
-  cluster = new MiniDFSCluster.Builder(conf).build();
+Configuration conf = new HdfsConfiguration();
+File testDataCluster1 = new File(testDataPath, CLUSTER_1);
+String c1Path = testDataCluster1.getAbsolutePath();
+conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
+try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()){
   assertEquals(new File(c1Path + "/data"),
   new File(cluster.getDataDirectory()));
 } finally {
   if (oldPrp != null) {
 System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, oldPrp);
   }
-  if (cluster != null) {
-cluster.shutdown();
-  }
 }
   }
 
@@ -110,15 +105,12 @@ public class TestMiniDFSCluster {
 File testDataCluster5 = new File(testDataPath, CLUSTER_5);
 String c5Path = testDataCluster5.getAbsolutePath();
 conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c5Path);
-MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
-  .numDataNodes(1)
-  .checkDataNodeHostConfig(true)
-  .build();
-try {
+try (MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
+.numDataNodes(1)
+.checkDataNodeHostConfig(true)
+.build()) {
   assertEquals("DataNode hostname config not respected", "MYHOST",
   cluster5.getDataNodes().get(0).getDatanodeId().getHostName());
-} finally {
-  MiniDFSCluster.shutdownCluster(cluster5);
 }
   }
 
@@ -128,9 +120,8 @@ public class TestMiniDFSCluster {
 StorageType[][] storageType = new StorageType[][] {
 {StorageType.DISK, StorageType.ARCHIVE}, 

[35/50] [abbrv] hadoop git commit: HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by Andras Bokor.

2016-07-25 Thread vvasudev
HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by 
Andras Bokor.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fcde6940
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fcde6940
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fcde6940

Branch: refs/heads/YARN-4757
Commit: fcde6940e0cbdedb1105007e4857137ecdfa1284
Parents: bd3dcf4
Author: Akira Ajisaka 
Authored: Thu Jul 21 11:25:28 2016 -0700
Committer: Akira Ajisaka 
Committed: Thu Jul 21 11:26:08 2016 -0700

--
 .../org/apache/hadoop/hdfs/MiniDFSCluster.java  |  7 ++-
 .../apache/hadoop/hdfs/TestMiniDFSCluster.java  | 53 +++-
 2 files changed, 24 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/fcde6940/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
index 3b3a88b..3bb3a10 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
@@ -136,7 +136,7 @@ import com.google.common.collect.Sets;
  */
 @InterfaceAudience.LimitedPrivate({"HBase", "HDFS", "Hive", "MapReduce", 
"Pig"})
 @InterfaceStability.Unstable
-public class MiniDFSCluster {
+public class MiniDFSCluster implements AutoCloseable {
 
   private static final String NAMESERVICE_ID_PREFIX = "nameserviceId";
   private static final Log LOG = LogFactory.getLog(MiniDFSCluster.class);
@@ -3057,4 +3057,9 @@ public class MiniDFSCluster {
   writer.close();
 }
   }
+
+  @Override
+  public void close() {
+shutdown();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fcde6940/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
index ec72d87..4d027dc 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
@@ -64,22 +64,17 @@ public class TestMiniDFSCluster {
   public void testClusterWithoutSystemProperties() throws Throwable {
 String oldPrp = System.getProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
 System.clearProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
-MiniDFSCluster cluster = null;
-try {
-  Configuration conf = new HdfsConfiguration();
-  File testDataCluster1 = new File(testDataPath, CLUSTER_1);
-  String c1Path = testDataCluster1.getAbsolutePath();
-  conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
-  cluster = new MiniDFSCluster.Builder(conf).build();
+Configuration conf = new HdfsConfiguration();
+File testDataCluster1 = new File(testDataPath, CLUSTER_1);
+String c1Path = testDataCluster1.getAbsolutePath();
+conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
+try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()){
   assertEquals(new File(c1Path + "/data"),
   new File(cluster.getDataDirectory()));
 } finally {
   if (oldPrp != null) {
 System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, oldPrp);
   }
-  if (cluster != null) {
-cluster.shutdown();
-  }
 }
   }
 
@@ -110,15 +105,12 @@ public class TestMiniDFSCluster {
 File testDataCluster5 = new File(testDataPath, CLUSTER_5);
 String c5Path = testDataCluster5.getAbsolutePath();
 conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c5Path);
-MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
-  .numDataNodes(1)
-  .checkDataNodeHostConfig(true)
-  .build();
-try {
+try (MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
+.numDataNodes(1)
+.checkDataNodeHostConfig(true)
+.build()) {
   assertEquals("DataNode hostname config not respected", "MYHOST",
   cluster5.getDataNodes().get(0).getDatanodeId().getHostName());
-} finally {
-  MiniDFSCluster.shutdownCluster(cluster5);
 }
   }
 
@@ -128,9 +120,8 @@ public class TestMiniDFSCluster {
 StorageType[][] storageType = new StorageType[][] {
 {StorageType.DISK, StorageType.ARCHIVE}, 

hadoop git commit: HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by Andras Bokor.

2016-07-21 Thread aajisaka
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 7234fce25 -> 2f14d585c


HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by 
Andras Bokor.

(cherry picked from commit fcde6940e0cbdedb1105007e4857137ecdfa1284)
(cherry picked from commit 1222889f1a3b45df30c48a80d8c2bec7ad45ee43)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2f14d585
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2f14d585
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2f14d585

Branch: refs/heads/branch-2.8
Commit: 2f14d585c43d7ae206601621846199438b305dbf
Parents: 7234fce
Author: Akira Ajisaka 
Authored: Thu Jul 21 11:25:28 2016 -0700
Committer: Akira Ajisaka 
Committed: Thu Jul 21 11:28:46 2016 -0700

--
 .../org/apache/hadoop/hdfs/MiniDFSCluster.java  |  7 ++-
 .../apache/hadoop/hdfs/TestMiniDFSCluster.java  | 53 +++-
 2 files changed, 24 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2f14d585/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
index 651b703..3b9df70 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
@@ -137,7 +137,7 @@ import com.google.common.collect.Sets;
  */
 @InterfaceAudience.LimitedPrivate({"HBase", "HDFS", "Hive", "MapReduce", 
"Pig"})
 @InterfaceStability.Unstable
-public class MiniDFSCluster {
+public class MiniDFSCluster implements AutoCloseable {
 
   private static final String NAMESERVICE_ID_PREFIX = "nameserviceId";
   private static final Log LOG = LogFactory.getLog(MiniDFSCluster.class);
@@ -2959,4 +2959,9 @@ public class MiniDFSCluster {
   writer.close();
 }
   }
+
+  @Override
+  public void close() {
+shutdown();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2f14d585/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
index ec72d87..4d027dc 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
@@ -64,22 +64,17 @@ public class TestMiniDFSCluster {
   public void testClusterWithoutSystemProperties() throws Throwable {
 String oldPrp = System.getProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
 System.clearProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
-MiniDFSCluster cluster = null;
-try {
-  Configuration conf = new HdfsConfiguration();
-  File testDataCluster1 = new File(testDataPath, CLUSTER_1);
-  String c1Path = testDataCluster1.getAbsolutePath();
-  conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
-  cluster = new MiniDFSCluster.Builder(conf).build();
+Configuration conf = new HdfsConfiguration();
+File testDataCluster1 = new File(testDataPath, CLUSTER_1);
+String c1Path = testDataCluster1.getAbsolutePath();
+conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
+try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()){
   assertEquals(new File(c1Path + "/data"),
   new File(cluster.getDataDirectory()));
 } finally {
   if (oldPrp != null) {
 System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, oldPrp);
   }
-  if (cluster != null) {
-cluster.shutdown();
-  }
 }
   }
 
@@ -110,15 +105,12 @@ public class TestMiniDFSCluster {
 File testDataCluster5 = new File(testDataPath, CLUSTER_5);
 String c5Path = testDataCluster5.getAbsolutePath();
 conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c5Path);
-MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
-  .numDataNodes(1)
-  .checkDataNodeHostConfig(true)
-  .build();
-try {
+try (MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
+.numDataNodes(1)
+.checkDataNodeHostConfig(true)
+.build()) {
   assertEquals("DataNode hostname config not respected", "MYHOST",
   cluster5.getDataNodes().get(0).getDatanodeId().getHostName());
-} finally {
-  

hadoop git commit: HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by Andras Bokor.

2016-07-21 Thread aajisaka
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 419d6ce19 -> 1222889f1


HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by 
Andras Bokor.

(cherry picked from commit fcde6940e0cbdedb1105007e4857137ecdfa1284)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1222889f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1222889f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1222889f

Branch: refs/heads/branch-2
Commit: 1222889f1a3b45df30c48a80d8c2bec7ad45ee43
Parents: 419d6ce
Author: Akira Ajisaka 
Authored: Thu Jul 21 11:25:28 2016 -0700
Committer: Akira Ajisaka 
Committed: Thu Jul 21 11:28:19 2016 -0700

--
 .../org/apache/hadoop/hdfs/MiniDFSCluster.java  |  7 ++-
 .../apache/hadoop/hdfs/TestMiniDFSCluster.java  | 53 +++-
 2 files changed, 24 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/1222889f/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
index 8215b70..248c4f2 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
@@ -136,7 +136,7 @@ import com.google.common.collect.Sets;
  */
 @InterfaceAudience.LimitedPrivate({"HBase", "HDFS", "Hive", "MapReduce", 
"Pig"})
 @InterfaceStability.Unstable
-public class MiniDFSCluster {
+public class MiniDFSCluster implements AutoCloseable {
 
   private static final String NAMESERVICE_ID_PREFIX = "nameserviceId";
   private static final Log LOG = LogFactory.getLog(MiniDFSCluster.class);
@@ -2971,4 +2971,9 @@ public class MiniDFSCluster {
   writer.close();
 }
   }
+
+  @Override
+  public void close() {
+shutdown();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/1222889f/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
index ec72d87..4d027dc 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
@@ -64,22 +64,17 @@ public class TestMiniDFSCluster {
   public void testClusterWithoutSystemProperties() throws Throwable {
 String oldPrp = System.getProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
 System.clearProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
-MiniDFSCluster cluster = null;
-try {
-  Configuration conf = new HdfsConfiguration();
-  File testDataCluster1 = new File(testDataPath, CLUSTER_1);
-  String c1Path = testDataCluster1.getAbsolutePath();
-  conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
-  cluster = new MiniDFSCluster.Builder(conf).build();
+Configuration conf = new HdfsConfiguration();
+File testDataCluster1 = new File(testDataPath, CLUSTER_1);
+String c1Path = testDataCluster1.getAbsolutePath();
+conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
+try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()){
   assertEquals(new File(c1Path + "/data"),
   new File(cluster.getDataDirectory()));
 } finally {
   if (oldPrp != null) {
 System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, oldPrp);
   }
-  if (cluster != null) {
-cluster.shutdown();
-  }
 }
   }
 
@@ -110,15 +105,12 @@ public class TestMiniDFSCluster {
 File testDataCluster5 = new File(testDataPath, CLUSTER_5);
 String c5Path = testDataCluster5.getAbsolutePath();
 conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c5Path);
-MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
-  .numDataNodes(1)
-  .checkDataNodeHostConfig(true)
-  .build();
-try {
+try (MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
+.numDataNodes(1)
+.checkDataNodeHostConfig(true)
+.build()) {
   assertEquals("DataNode hostname config not respected", "MYHOST",
   cluster5.getDataNodes().get(0).getDatanodeId().getHostName());
-} finally {
-  MiniDFSCluster.shutdownCluster(cluster5);
 }
   }
 
@@ -128,9 +120,8 @@ 

hadoop git commit: HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by Andras Bokor.

2016-07-21 Thread aajisaka
Repository: hadoop
Updated Branches:
  refs/heads/trunk bd3dcf46e -> fcde6940e


HDFS-10287. MiniDFSCluster should implement AutoCloseable. Contributed by 
Andras Bokor.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fcde6940
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fcde6940
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fcde6940

Branch: refs/heads/trunk
Commit: fcde6940e0cbdedb1105007e4857137ecdfa1284
Parents: bd3dcf4
Author: Akira Ajisaka 
Authored: Thu Jul 21 11:25:28 2016 -0700
Committer: Akira Ajisaka 
Committed: Thu Jul 21 11:26:08 2016 -0700

--
 .../org/apache/hadoop/hdfs/MiniDFSCluster.java  |  7 ++-
 .../apache/hadoop/hdfs/TestMiniDFSCluster.java  | 53 +++-
 2 files changed, 24 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/fcde6940/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
index 3b3a88b..3bb3a10 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java
@@ -136,7 +136,7 @@ import com.google.common.collect.Sets;
  */
 @InterfaceAudience.LimitedPrivate({"HBase", "HDFS", "Hive", "MapReduce", 
"Pig"})
 @InterfaceStability.Unstable
-public class MiniDFSCluster {
+public class MiniDFSCluster implements AutoCloseable {
 
   private static final String NAMESERVICE_ID_PREFIX = "nameserviceId";
   private static final Log LOG = LogFactory.getLog(MiniDFSCluster.class);
@@ -3057,4 +3057,9 @@ public class MiniDFSCluster {
   writer.close();
 }
   }
+
+  @Override
+  public void close() {
+shutdown();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fcde6940/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
--
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
index ec72d87..4d027dc 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
@@ -64,22 +64,17 @@ public class TestMiniDFSCluster {
   public void testClusterWithoutSystemProperties() throws Throwable {
 String oldPrp = System.getProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
 System.clearProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA);
-MiniDFSCluster cluster = null;
-try {
-  Configuration conf = new HdfsConfiguration();
-  File testDataCluster1 = new File(testDataPath, CLUSTER_1);
-  String c1Path = testDataCluster1.getAbsolutePath();
-  conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
-  cluster = new MiniDFSCluster.Builder(conf).build();
+Configuration conf = new HdfsConfiguration();
+File testDataCluster1 = new File(testDataPath, CLUSTER_1);
+String c1Path = testDataCluster1.getAbsolutePath();
+conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
+try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()){
   assertEquals(new File(c1Path + "/data"),
   new File(cluster.getDataDirectory()));
 } finally {
   if (oldPrp != null) {
 System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, oldPrp);
   }
-  if (cluster != null) {
-cluster.shutdown();
-  }
 }
   }
 
@@ -110,15 +105,12 @@ public class TestMiniDFSCluster {
 File testDataCluster5 = new File(testDataPath, CLUSTER_5);
 String c5Path = testDataCluster5.getAbsolutePath();
 conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c5Path);
-MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
-  .numDataNodes(1)
-  .checkDataNodeHostConfig(true)
-  .build();
-try {
+try (MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
+.numDataNodes(1)
+.checkDataNodeHostConfig(true)
+.build()) {
   assertEquals("DataNode hostname config not respected", "MYHOST",
   cluster5.getDataNodes().get(0).getDatanodeId().getHostName());
-} finally {
-  MiniDFSCluster.shutdownCluster(cluster5);
 }
   }
 
@@ -128,9 +120,8 @@ public class TestMiniDFSCluster {
 StorageType[][] storageType = new