Esempio n. 1
0
  /*
   * @Test public void locationTest() throws IOException { TachyonFile file =
   * TachyonFSTestUtils.createByteFile(mTfs, "/testFile", CacheType.STORE,
   * UnderStorageType.NO_PERSIST, 10); mFsShell.run(new String[] {"location", "/testFile"});
   *
   * FileInfo fileInfo = mTfs.getInfo(file); Assert.assertNotNull(fileInfo); List<String>
   * locationsList = tFile.getLocationHosts(); String[] commandParameters = new String[3 +
   * locationsList.size()]; commandParameters[0] = "location"; commandParameters[1] = "/testFile";
   * commandParameters[2] = String.valueOf(file.getFileId()); Iterator<String> iter =
   * locationsList.iterator(); int i = 3; while (iter.hasNext()) { commandParameters[i ++] =
   * iter.next(); } Assert.assertEquals(getCommandOutput(commandParameters), mOutput.toString()); }
   */
  @Test
  public void lsrTest() throws IOException, TException {
    FileInfo[] files = new FileInfo[4];

    TachyonFile fileA =
        TachyonFSTestUtils.createByteFile(
            mTfs, "/testRoot/testFileA", TachyonStorageType.STORE, UnderStorageType.NO_PERSIST, 10);
    files[0] = mTfs.getInfo(fileA);
    TachyonFSTestUtils.createByteFile(
        mTfs,
        "/testRoot/testDir/testFileB",
        TachyonStorageType.STORE,
        UnderStorageType.NO_PERSIST,
        20);
    files[1] = mTfs.getInfo(mTfs.open(new TachyonURI("/testRoot/testDir")));
    files[2] = mTfs.getInfo(mTfs.open(new TachyonURI("/testRoot/testDir/testFileB")));
    TachyonFile fileC =
        TachyonFSTestUtils.createByteFile(
            mTfs, "/testRoot/testFileC", TachyonStorageType.NO_STORE, UnderStorageType.PERSIST, 30);
    files[3] = mTfs.getInfo(fileC);
    mFsShell.run(new String[] {"lsr", "/testRoot"});
    String expected = "";
    String format = "%-10s%-25s%-15s%-5s\n";
    expected +=
        String.format(
            format,
            FormatUtils.getSizeFromBytes(10),
            TFsShell.convertMsToDate(files[0].getCreationTimeMs()),
            "In Memory",
            "/testRoot/testFileA");
    expected +=
        String.format(
            format,
            FormatUtils.getSizeFromBytes(0),
            TFsShell.convertMsToDate(files[1].getCreationTimeMs()),
            "",
            "/testRoot/testDir");
    expected +=
        String.format(
            format,
            FormatUtils.getSizeFromBytes(20),
            TFsShell.convertMsToDate(files[2].getCreationTimeMs()),
            "In Memory",
            "/testRoot/testDir/testFileB");
    expected +=
        String.format(
            format,
            FormatUtils.getSizeFromBytes(30),
            TFsShell.convertMsToDate(files[3].getCreationTimeMs()),
            "Not In Memory",
            "/testRoot/testFileC");
    Assert.assertEquals(expected, mOutput.toString());
  }
Esempio n. 2
0
 @Test
 public void lsrTest() throws IOException {
   int fileIdA =
       TachyonFSTestUtils.createByteFile(mTfs, "/testRoot/testFileA", WriteType.MUST_CACHE, 10);
   TachyonFile[] files = new TachyonFile[4];
   files[0] = mTfs.getFile(fileIdA);
   TachyonFSTestUtils.createByteFile(
       mTfs, "/testRoot/testDir/testFileB", WriteType.MUST_CACHE, 20);
   files[1] = mTfs.getFile(new TachyonURI("/testRoot/testDir"));
   files[2] = mTfs.getFile(new TachyonURI("/testRoot/testDir/testFileB"));
   int fileIdC =
       TachyonFSTestUtils.createByteFile(mTfs, "/testRoot/testFileC", WriteType.THROUGH, 30);
   files[3] = mTfs.getFile(fileIdC);
   mFsShell.ls(new String[] {"count", "/testRoot"});
   String expected = "";
   String format = "%-10s%-25s%-15s%-5s\n";
   expected +=
       String.format(
           format,
           FormatUtils.getSizeFromBytes(10),
           TFsShell.convertMsToDate(files[0].getCreationTimeMs()),
           "In Memory",
           "/testRoot/testFileA");
   expected +=
       String.format(
           format,
           FormatUtils.getSizeFromBytes(0),
           TFsShell.convertMsToDate(files[1].getCreationTimeMs()),
           "",
           "/testRoot/testDir");
   expected +=
       String.format(
           format,
           FormatUtils.getSizeFromBytes(30),
           TFsShell.convertMsToDate(files[3].getCreationTimeMs()),
           "Not In Memory",
           "/testRoot/testFileC");
   Assert.assertEquals(expected, mOutput.toString());
 }
Esempio n. 3
0
 /**
  * Displays information for all directories and files directly under the path specified in argv.
  *
  * @param path The TachyonURI path as the input of the command
  * @return 0 if command is successful, -1 if an error occurred.
  * @throws IOException
  */
 public int ls(TachyonURI path) throws IOException {
   List<FileInfo> files = listStatusSortedByIncreasingCreationTime(path);
   String format = "%-10s%-25s%-15s%-5s%n";
   for (FileInfo file : files) {
     String inMemory = "";
     if (!file.isFolder) {
       if (100 == file.inMemoryPercentage) {
         inMemory = "In Memory";
       } else {
         inMemory = "Not In Memory";
       }
     }
     System.out.format(
         format,
         FormatUtils.getSizeFromBytes(file.getLength()),
         convertMsToDate(file.getCreationTimeMs()),
         inMemory,
         file.getPath());
   }
   return 0;
 }