Repository: incubator-blur Updated Branches: refs/heads/master 5a92790e9 -> ecabd6af3
Various small fixes to mini cluster. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/52e638cc Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/52e638cc Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/52e638cc Branch: refs/heads/master Commit: 52e638cc027316db86fe93ad6d002b718bc8ff37 Parents: 5a92790 Author: Aaron McCurry <[email protected]> Authored: Mon Mar 30 10:37:51 2015 -0400 Committer: Aaron McCurry <[email protected]> Committed: Mon Mar 30 10:37:51 2015 -0400 ---------------------------------------------------------------------- .../test/java/org/apache/blur/MiniCluster.java | 66 +++++++++++++------- 1 file changed, 44 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/52e638cc/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 601548b..26a4734 100644 --- a/blur-core/src/test/java/org/apache/blur/MiniCluster.java +++ b/blur-core/src/test/java/org/apache/blur/MiniCluster.java @@ -768,32 +768,54 @@ public class MiniCluster { startDfs(conf, true, path); } - public void startDfs(Configuration conf, boolean format, String path) { - _conf = conf; - String perm; - Path p = new Path(new File(path).getAbsolutePath()); - try { - FileSystem fileSystem = p.getFileSystem(conf); - if (!fileSystem.exists(p)) { - if (!fileSystem.mkdirs(p)) { - throw new RuntimeException("Could not create path [" + path + "]"); + public void startDfs(final Configuration conf, final boolean format, final String path) { + startDfs(conf, format, path, null); + } + + public void startDfs(final Configuration conf, final boolean format, final String path, final String[] racks) { + Thread thread = new Thread(group, new Runnable() { + @SuppressWarnings("deprecation") + @Override + public void run() { + _conf = conf; + String perm; + Path p = new Path(new File(path).getAbsolutePath()); + try { + FileSystem fileSystem = p.getFileSystem(conf); + if (!fileSystem.exists(p)) { + if (!fileSystem.mkdirs(p)) { + throw new RuntimeException("Could not create path [" + path + "]"); + } + } + 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 { + if (racks == null) { + cluster = new MiniDFSCluster(conf, 1, format, racks); + } else { + cluster = new MiniDFSCluster(conf, racks.length, format, racks); + } + } catch (Exception e) { + LOG.error("error opening file system", e); + throw new RuntimeException(e); } } - 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); + }); + thread.start(); try { - cluster = new MiniDFSCluster(conf, 1, true, (String[]) null); + thread.join(); cluster.waitActive(); - } catch (Exception e) { - LOG.error("error opening file system", e); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { throw new RuntimeException(e); } }
