Java 类org.apache.hadoop.fs.shell.Count 实例源码

项目:hadoop-EAR    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
                     ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:hadoop-on-lustre    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
  ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:cumulus    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
  ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:RDFS    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
                     ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:hadoop-0.20    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
  ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:hortonworks-extension    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
  ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:hortonworks-extension    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
  ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:hadoop-gpu    文件:TestDFSShell.java   
private void runCount(String path, long dirs, long files, Configuration conf
  ) throws IOException {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
  PrintStream out = new PrintStream(bytes);
  PrintStream oldOut = System.out;
  System.setOut(out);
  Scanner in = null;
  String results = null;
  try {
    new Count(new String[]{path}, 0, conf).runAll();
    results = bytes.toString();
    in = new Scanner(results);
    assertEquals(dirs, in.nextLong());
    assertEquals(files, in.nextLong());
  } finally {
    if (in!=null) in.close();
    IOUtils.closeStream(out);
    System.setOut(oldOut);
    System.out.println("results:\n" + results);
  }
}
项目:hadoop-EAR    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:hadoop-on-lustre    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:cumulus    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new HdfsConfiguration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs.getUri(),
        localfs.getWorkingDirectory());
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:RDFS    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:hadoop-0.20    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:hortonworks-extension    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:hortonworks-extension    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}
项目:hadoop-gpu    文件:TestDFSShell.java   
public void testCount() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
  DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
  FsShell shell = new FsShell();
  shell.setConf(conf);

  try {
    String root = createTree(dfs, "count");

    // Verify the counts
    runCount(root, 2, 4, conf);
    runCount(root + "2", 2, 1, conf);
    runCount(root + "2/f1", 0, 1, conf);
    runCount(root + "2/sub", 1, 0, conf);

    final FileSystem localfs = FileSystem.getLocal(conf);
    Path localpath = new Path(TEST_ROOT_DIR, "testcount");
    localpath = localpath.makeQualified(localfs);
    localfs.mkdirs(localpath);

    final String localstr = localpath.toString();
    System.out.println("localstr=" + localstr);
    runCount(localstr, 1, 0, conf);
    assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
  } finally {
    try {
      dfs.close();
    } catch (Exception e) {
    }
    cluster.shutdown();
  }
}