Package tachyon.client

Examples of tachyon.client.TachyonFile


    LOG.info("getFileStatus(" + path + "): HDFS Path: " + hdfsPath + " TPath: " + mTachyonHeader
        + tPath);
    if (useHdfs()) {
      fromHdfsToTachyon(tPath);
    }
    TachyonFile file = mTFS.getFile(tPath);
    if (file == null) {
      LOG.info("File does not exist: " + path);
      throw new FileNotFoundException("File does not exist: " + path);
    }

    FileStatus ret =
        new FileStatus(file.length(), file.isDirectory(), file.getDiskReplication(),
            file.getBlockSizeByte(), file.getCreationTimeMs(), file.getCreationTimeMs(), null,
            null, null, new Path(mTachyonHeader + tPath));
    return ret;
  }
View Full Code Here


    fos.write(toWrite);
    fos.close();
    mFsShell.copyFromLocal(new String[] {"copyFromLocal", testFile.getAbsolutePath(), "/testFile"});
    Assert.assertEquals(getCommandOutput(new String[] {"copyFromLocal", testFile.getAbsolutePath(),
        "/testFile"}), mOutput.toString());
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/testFile"));
    Assert.assertNotNull(tFile);
    Assert.assertEquals(SIZE_BYTES, tFile.length());
    InStream tfis = tFile.getInStream(ReadType.NO_CACHE);
    byte read[] = new byte[SIZE_BYTES];
    tfis.read(read);
    Assert.assertTrue(TestUtils.equalIncreasingByteArray(SIZE_BYTES, read));
  }
View Full Code Here

    File testFile = generateFileContent("/testDir/testFile", TestUtils.getIncreasingByteArray(10));
    generateFileContent("/testDir/testDirInner/testFile2", TestUtils.getIncreasingByteArray(10, 20));
    mFsShell.copyFromLocal(new String[] {"copyFromLocal", testFile.getParent(), "/testDir"});
    Assert.assertEquals(getCommandOutput(new String[] {"copyFromLocal", testFile.getParent(),
        "/testDir"}), mOutput.toString());
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/testDir/testFile"));
    TachyonFile tFile2 = mTfs.getFile(new TachyonURI("/testDir/testDirInner/testFile2"));
    Assert.assertNotNull(tFile);
    Assert.assertNotNull(tFile2);
    Assert.assertEquals(10, tFile.length());
    Assert.assertEquals(20, tFile2.length());
    byte[] read = readContent(tFile, 10);
    Assert.assertTrue(TestUtils.equalIncreasingByteArray(10, read));
    read = readContent(tFile2, 20);
    Assert.assertTrue(TestUtils.equalIncreasingByteArray(10, 20, read));
  }
View Full Code Here

    mFsShell.copyFromLocal(new String[] {"copyFromLocal", testFile.getPath(), tachyonURI});
    String cmdOut =
        getCommandOutput(new String[] {"copyFromLocal", testFile.getPath(), tachyonURI});
    // then
    assertThat(cmdOut, equalTo(mOutput.toString()));
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/destFileURI"));
    assertThat(tFile.length(), equalTo(10L));
    byte[] read = readContent(tFile, 10);
    assertThat(TestUtils.equalIncreasingByteArray(10, read), equalTo(true));
  }
View Full Code Here

  @Test
  public void fileinfoTest() throws IOException {
    int fileId = TestUtils.createByteFile(mTfs, "/testFile", WriteType.MUST_CACHE, 10);
    mFsShell.fileinfo(new String[] {"fileinfo", "/testFile"});
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/testFile"));
    Assert.assertNotNull(tFile);
    List<ClientBlockInfo> blocks = mTfs.getFileBlocks(fileId);
    String[] commandParameters = new String[3 + blocks.size()];
    commandParameters[0] = "fileinfo";
    commandParameters[1] = "/testFile";
View Full Code Here

  @Test
  public void locationTest() throws IOException {
    int fileId = TestUtils.createByteFile(mTfs, "/testFile", WriteType.MUST_CACHE, 10);
    mFsShell.location(new String[] {"location", "/testFile"});
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/testFile"));
    Assert.assertNotNull(tFile);
    List<String> locationsList = tFile.getLocationHosts();
    String[] commandParameters = new String[3 + locationsList.size()];
    commandParameters[0] = "location";
    commandParameters[1] = "/testFile";
    commandParameters[2] = String.valueOf(fileId);
    Iterator<String> iter = locationsList.iterator();
View Full Code Here

  }

  @Test
  public void mkdirComplexPathTest() throws IOException {
    mFsShell.mkdir(new String[] {"mkdir", "/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"});
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"));
    Assert.assertNotNull(tFile);
    Assert.assertEquals(getCommandOutput(new String[] {"mkdir",
        "/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"}), mOutput.toString());
    Assert.assertTrue(tFile.isDirectory());
  }
View Full Code Here

  }

  @Test
  public void mkdirShortPathTest() throws IOException {
    mFsShell.mkdir(new String[] {"mkdir", "/root/testFile1"});
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/root/testFile1"));
    Assert.assertNotNull(tFile);
    Assert.assertEquals(getCommandOutput(new String[] {"mkdir", "/root/testFile1"}),
        mOutput.toString());
    Assert.assertTrue(tFile.isDirectory());
  }
View Full Code Here

  public void mkdirTest() throws IOException {
    String qualifiedPath =
        "tachyon://" + NetworkUtils.getLocalHostName() + ":" + mLocalTachyonCluster.getMasterPort()
            + "/root/testFile1";
    mFsShell.mkdir(new String[] {"mkdir", qualifiedPath});
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/root/testFile1"));
    Assert.assertNotNull(tFile);
    Assert
        .assertEquals(getCommandOutput(new String[] {"mkdir", qualifiedPath}), mOutput.toString());
    Assert.assertTrue(tFile.isDirectory());
  }
View Full Code Here

  @Test
  public void touchTest() throws IOException {
    String[] argv = new String[] {"touch", "/testFile"};
    mFsShell.touch(argv);
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/testFile"));
    Assert.assertNotNull(tFile);
    Assert.assertEquals(getCommandOutput(argv), mOutput.toString());
    Assert.assertTrue(tFile.isFile());
  }
View Full Code Here

TOP

Related Classes of tachyon.client.TachyonFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.