incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [39/45] git commit: Trying to automatically detect the correct perm mask for the HDFS minicluster.
Date Sat, 28 Sep 2013 02:12:25 GMT
Trying to automatically detect the correct perm mask for the HDFS minicluster.


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

Branch: refs/heads/apache-blur-0.2
Commit: f5a37996e742ec7a59de861263474928ab98a8c0
Parents: 27664e1
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Sep 21 21:55:46 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Sep 21 21:55:46 2013 -0400

----------------------------------------------------------------------
 .../test/java/org/apache/blur/MiniCluster.java  | 30 ++++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f5a37996/blur-core/src/test/java/org/apache/blur/MiniCluster.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/MiniCluster.java b/blur-core/src/test/java/org/apache/blur/MiniCluster.java
index c97bcaa..f99f2c7 100644
--- a/blur-core/src/test/java/org/apache/blur/MiniCluster.java
+++ b/blur-core/src/test/java/org/apache/blur/MiniCluster.java
@@ -63,7 +63,10 @@ import org.apache.blur.thrift.util.BlurThriftHelper;
 import org.apache.blur.utils.BlurUtil;
 import org.apache.blur.zookeeper.ZooKeeperClient;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
@@ -480,22 +483,19 @@ public class MiniCluster {
   }
 
   public void startDfs(Configuration conf, boolean format, String path) {
-    Properties properties = System.getProperties();
-
-//    Set<Object> keySet = properties.keySet();
-//    for (Object k : keySet) {
-//      String key = k.toString();
-//      if (key.contains("os")) {
-//        String value = properties.getProperty(key);
-//        System.out.println("Key [" + key + "] Value [" + value + "]");
-//      }
-//    }
-
-    String osName = properties.getProperty("os.name").toLowerCase();
-//    System.out.println("os.name=" + osName);
-    if (osName.contains("linux")) {
-      conf.set("dfs.datanode.data.dir.perm", "775");
+    String perm;
+    Path p = new Path(new File("./target").getAbsolutePath());
+    try {
+      FileSystem fileSystem = p.getFileSystem(conf);
+      FileStatus fileStatus = fileSystem.getFileStatus(p);
+      FsPermission permission = fileStatus.getPermission();
+      perm = permission.getUserAction().ordinal() + "" + permission.getGroupAction().ordinal()
+ ""
+          + permission.getOtherAction().ordinal();
+    } catch (IOException e) {
+      throw new RuntimeException(e);
     }
+    LOG.info("dfs.datanode.data.dir.perm=" + perm);
+    conf.set("dfs.datanode.data.dir.perm", perm);
     System.setProperty("test.build.data", path);
     try {
       cluster = new MiniDFSCluster(conf, 1, true, (String[]) null);


Mime
View raw message