org.apache.hadoop.fs.shell.Count Java Examples

The following examples show how to use org.apache.hadoop.fs.shell.Count. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestDFSShell.java    From RDFS with Apache License 2.0 5 votes vote down vote up
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();
  }
}
 
Example #2
Source File: TestDFSShell.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
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();
  }
}
 
Example #3
Source File: FsShell.java    From hadoop-gpu with Apache License 2.0 4 votes vote down vote up
/**
 * Displays format of commands.
 * 
 */
private static void printUsage(String cmd) {
  String prefix = "Usage: java " + FsShell.class.getSimpleName();
  if ("-fs".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [-fs <local | file system URI>]");
  } else if ("-conf".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [-conf <configuration file>]");
  } else if ("-D".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [-D <[property=value>]");
  } else if ("-ls".equals(cmd) || "-lsr".equals(cmd) ||
             "-du".equals(cmd) || "-dus".equals(cmd) ||
             "-touchz".equals(cmd) || "-mkdir".equals(cmd) ||
             "-text".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [" + cmd + " <path>]");
  } else if (Count.matches(cmd)) {
    System.err.println(prefix + " [" + Count.USAGE + "]");
  } else if ("-rm".equals(cmd) || "-rmr".equals(cmd)) {
    System.err.println("Usage: java FsShell [" + cmd + 
                         " [-skipTrash] <src>]");
  } else if ("-mv".equals(cmd) || "-cp".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [" + cmd + " <src> <dst>]");
  } else if ("-put".equals(cmd) || "-copyFromLocal".equals(cmd) ||
             "-moveFromLocal".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [" + cmd + " <localsrc> ... <dst>]");
  } else if ("-get".equals(cmd)) {
    System.err.println("Usage: java FsShell [" + GET_SHORT_USAGE + "]"); 
  } else if ("-copyToLocal".equals(cmd)) {
    System.err.println("Usage: java FsShell [" + COPYTOLOCAL_SHORT_USAGE+ "]"); 
  } else if ("-moveToLocal".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [" + cmd + " [-crc] <src> <localdst>]");
  } else if ("-cat".equals(cmd)) {
    System.err.println("Usage: java FsShell" + 
                       " [" + cmd + " <src>]");
  } else if ("-setrep".equals(cmd)) {
    System.err.println("Usage: java FsShell [" + SETREP_SHORT_USAGE + "]");
  } else if ("-test".equals(cmd)) {
    System.err.println("Usage: java FsShell" +
                       " [-test -[ezd] <path>]");
  } else if ("-stat".equals(cmd)) {
    System.err.println("Usage: java FsShell" +
                       " [-stat [format] <path>]");
  } else if ("-tail".equals(cmd)) {
    System.err.println("Usage: java FsShell [" + TAIL_USAGE + "]");
  } else {
    System.err.println("Usage: java FsShell");
    System.err.println("           [-ls <path>]");
    System.err.println("           [-lsr <path>]");
    System.err.println("           [-du <path>]");
    System.err.println("           [-dus <path>]");
    System.err.println("           [" + Count.USAGE + "]");
    System.err.println("           [-mv <src> <dst>]");
    System.err.println("           [-cp <src> <dst>]");
    System.err.println("           [-rm [-skipTrash] <path>]");
    System.err.println("           [-rmr [-skipTrash] <path>]");
    System.err.println("           [-expunge]");
    System.err.println("           [-put <localsrc> ... <dst>]");
    System.err.println("           [-copyFromLocal <localsrc> ... <dst>]");
    System.err.println("           [-moveFromLocal <localsrc> ... <dst>]");
    System.err.println("           [" + GET_SHORT_USAGE + "]");
    System.err.println("           [-getmerge <src> <localdst> [addnl]]");
    System.err.println("           [-cat <src>]");
    System.err.println("           [-text <src>]");
    System.err.println("           [" + COPYTOLOCAL_SHORT_USAGE + "]");
    System.err.println("           [-moveToLocal [-crc] <src> <localdst>]");
    System.err.println("           [-mkdir <path>]");
    System.err.println("           [" + SETREP_SHORT_USAGE + "]");
    System.err.println("           [-touchz <path>]");
    System.err.println("           [-test -[ezd] <path>]");
    System.err.println("           [-stat [format] <path>]");
    System.err.println("           [" + TAIL_USAGE + "]");
    System.err.println("           [" + FsShellPermissions.CHMOD_USAGE + "]");      
    System.err.println("           [" + FsShellPermissions.CHOWN_USAGE + "]");
    System.err.println("           [" + FsShellPermissions.CHGRP_USAGE + "]");
    System.err.println("           [-help [cmd]]");
    System.err.println();
    ToolRunner.printGenericCommandUsage(System.err);
  }
}