hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject [04/17] hadoop git commit: YARN-4365. FileSystemNodeLabelStore should check for root dir existence on startup. Contributed by Kuhu Shukla (cherry picked from commit f5acf94ecafb301a0cc8e8f91f19c8bcbc8da701)
Date Wed, 13 Jan 2016 22:29:32 GMT
YARN-4365. FileSystemNodeLabelStore should check for root dir existence on startup. Contributed
by Kuhu Shukla
(cherry picked from commit f5acf94ecafb301a0cc8e8f91f19c8bcbc8da701)

Conflicts:

	hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java

(cherry picked from commit b68f527b9fee64e3c92766befe9544f780f1347e)


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

Branch: refs/heads/branch-2.7.2
Commit: 4e84a8bd3091cd46f85c15a32bfcfb8ce14f639a
Parents: 4765a65
Author: Jason Lowe <jlowe@apache.org>
Authored: Tue Nov 24 23:52:46 2015 +0000
Committer: Vinod Kumar Vavilapalli (I am also known as @tshooter.) <vinodkv@apache.org>
Committed: Wed Jan 13 11:29:26 2016 -0800

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  6 ++++
 .../nodelabels/FileSystemNodeLabelsStore.java   |  6 ++--
 .../TestFileSystemNodeLabelsStore.java          | 29 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e84a8bd/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 61e14f5..fd2c6e3 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -882,6 +882,12 @@ Release 2.6.3 - UNRELEASED
     YARN-4348. ZKRMStateStore.syncInternal shouldn't wait for sync completion for
     avoiding blocking ZK's event thread. (ozawa)
 
+    YARN-4365. FileSystemNodeLabelStore should check for root dir existence on
+    startup (Kuhu Shukla via jlowe)
+
+    YARN-4365. FileSystemNodeLabelStore should check for root dir existence on
+    startup (Kuhu Shukla via jlowe)
+
 Release 2.6.2 - 2015-10-28
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e84a8bd/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
index 6e685ee..7648690 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
@@ -84,7 +84,9 @@ public class FileSystemNodeLabelsStore extends NodeLabelsStore {
     setFileSystem(conf);
 
     // mkdir of root dir path
-    fs.mkdirs(fsWorkingPath);
+    if (!fs.exists(fsWorkingPath)) {
+      fs.mkdirs(fsWorkingPath);
+    }
   }
 
   @Override
@@ -97,7 +99,7 @@ public class FileSystemNodeLabelsStore extends NodeLabelsStore {
     }
   }
 
-  private void setFileSystem(Configuration conf) throws IOException {
+  void setFileSystem(Configuration conf) throws IOException {
     Configuration confCopy = new Configuration(conf);
     confCopy.setBoolean("dfs.client.retry.policy.enabled", true);
     String retryPolicy =

http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e84a8bd/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
index 56da848..be4e70d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
@@ -24,6 +24,8 @@ import java.util.Arrays;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.event.InlineDispatcher;
 import org.junit.After;
@@ -32,6 +34,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableMap;
+import org.mockito.Mockito;
 
 public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
   MockNodeLabelManager mgr = null;
@@ -273,4 +276,30 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase
{
         Arrays.asList("p2", "p4", "p6", "p7", "p8", "p9")));
     mgr.stop();
   }
+
+  @Test
+  public void testRootMkdirOnInitStore() throws Exception {
+    final FileSystem mockFs = Mockito.mock(FileSystem.class);
+    FileSystemNodeLabelsStore mockStore = new FileSystemNodeLabelsStore(mgr) {
+      void setFileSystem(Configuration conf) throws IOException {
+        fs = mockFs;
+      }
+    };
+    mockStore.fs = mockFs;
+    verifyMkdirsCount(mockStore, true, 0);
+    verifyMkdirsCount(mockStore, false, 1);
+    verifyMkdirsCount(mockStore, true, 1);
+    verifyMkdirsCount(mockStore, false, 2);
+  }
+
+  private void verifyMkdirsCount(FileSystemNodeLabelsStore store,
+                                 boolean existsRetVal, int expectedNumOfCalls)
+      throws Exception {
+    Mockito.when(store.fs.exists(Mockito.any(
+        Path.class))).thenReturn(existsRetVal);
+    store.init(conf);
+    Mockito.verify(store.fs,Mockito.times(
+        expectedNumOfCalls)).mkdirs(Mockito.any(Path
+        .class));
+  }
 }


Mime
View raw message