/** Test <code>void read()</code>. Read from remote data server. */
  @Test
  public void readTest4() throws IOException, TachyonException {
    String uniqPath = PathUtils.uniqPath();
    for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
      TachyonFile f =
          TachyonFSTestUtils.createByteFile(mTfs, uniqPath + "/file_" + k, k, mWriteTachyon);

      long blockId = mTfs.getInfo(f).getBlockIds().get(0);
      BlockInfo info = TachyonBlockStore.get().getInfo(blockId);
      RemoteBlockInStream is =
          new RemoteBlockInStream(
              info.getBlockId(), info.getLength(), info.getLocations().get(0).getWorkerAddress());
      byte[] ret = new byte[k];
      int value = is.read();
      int cnt = 0;
      while (value != -1) {
        Assert.assertTrue(value >= 0);
        Assert.assertTrue(value < 256);
        ret[cnt++] = (byte) value;
        value = is.read();
      }
      Assert.assertEquals(cnt, k);
      Assert.assertTrue(BufferUtils.equalIncreasingByteArray(k, ret));
      is.close();
      Assert.assertTrue(mTfs.getInfo(f).getInMemoryPercentage() == 100);
    }
  }
Example #2
0
  /**
   * Displays the file's all blocks info
   *
   * @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 fileinfo(TachyonURI path) throws IOException {
    TachyonFile fd;
    FileInfo fInfo;
    try {
      fd = mTfs.open(path);
      if (fd == null) {
        System.out.println(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(path));
        return -1;
      }
      fInfo = mTfs.getInfo(fd);
    } catch (TachyonException e) {
      throw new IOException(e);
    }

    if (fInfo.isFolder) {
      System.out.println(path + " is a directory path so does not have file blocks.");
      return -1;
    }

    System.out.println(path + " with file id " + fd.getFileId() + " has the following blocks: ");
    for (long blockId : fInfo.getBlockIds()) {
      System.out.println(TachyonBlockStore.get().getInfo(blockId));
    }
    return 0;
  }
Example #3
0
 /**
  * Get the capacity of the TachyonFileSystem
  *
  * @return 0 if command is successful, -1 if an error occurred.
  */
 public int getCapacityBytes() {
   try {
     long capacityBytes = TachyonBlockStore.get().getCapacityBytes();
     System.out.println("Capacity Bytes: " + capacityBytes);
     return 0;
   } catch (IOException ioe) {
     return -1;
   }
 }
Example #4
0
 /**
  * Get number of bytes used in the TachyonFileSystem
  *
  * @return 0 if command is successful, -1 if an error occurred.
  */
 public int getUsedBytes() {
   try {
     long usedBytes = TachyonBlockStore.get().getUsedBytes();
     System.out.println("Used Bytes: " + usedBytes);
     return 0;
   } catch (IOException ioe) {
     return -1;
   }
 }
  @Override
  void runCommand(TachyonURI path) throws IOException {
    TachyonFile fd;
    FileInfo fInfo;
    try {
      fd = mTfs.open(path);
      fInfo = mTfs.getInfo(fd);
    } catch (TachyonException e) {
      throw new IOException(e.getMessage());
    }

    if (fInfo.isFolder) {
      throw new IOException(path + " is a directory path so does not have file blocks.");
    }

    System.out.println(fInfo);
    System.out.println("Containing the following blocks: ");
    for (long blockId : fInfo.getBlockIds()) {
      System.out.println(TachyonBlockStore.get().getInfo(blockId));
    }
  }
Example #6
0
  /**
   * Displays a list of hosts that have the file specified in argv stored.
   *
   * @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 location(TachyonURI path) throws IOException {
    TachyonFile fd;
    FileInfo fInfo;
    try {
      fd = mTfs.open(path);
      if (fd == null) {
        System.out.println(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(path));
        return -1;
      }
      fInfo = mTfs.getInfo(fd);
    } catch (TachyonException e) {
      throw new IOException(e);
    }

    System.out.println(path + " with file id " + fd.getFileId() + " is on nodes: ");
    for (long blockId : fInfo.getBlockIds()) {
      for (BlockLocation location : TachyonBlockStore.get().getInfo(blockId).getLocations()) {
        System.out.println(location.getWorkerAddress().getHost());
      }
    }
    return 0;
  }
  /** Test <code>void read(byte[] b, int off, int len)</code>. Read from remote data server. */
  @Test
  public void readTest6() throws IOException, TachyonException {
    String uniqPath = PathUtils.uniqPath();
    for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
      TachyonFile f =
          TachyonFSTestUtils.createByteFile(mTfs, uniqPath + "/file_" + k, k, mWriteTachyon);

      long blockId = mTfs.getInfo(f).getBlockIds().get(0);
      BlockInfo info = TachyonBlockStore.get().getInfo(blockId);
      RemoteBlockInStream is =
          new RemoteBlockInStream(
              info.getBlockId(), info.getLength(), info.getLocations().get(0).getWorkerAddress());
      byte[] ret = new byte[k / 2];
      int start = 0;
      while (start < k / 2) {
        int read = is.read(ret, 0, (k / 2) - start);
        Assert.assertTrue(BufferUtils.equalIncreasingByteArray(start, read, ret));
        start += read;
      }
      is.close();
      Assert.assertTrue(mTfs.getInfo(f).getInMemoryPercentage() == 100);
    }
  }
 @Override
 public void run(String... args) throws IOException {
   long capacityBytes = TachyonBlockStore.get().getCapacityBytes();
   System.out.println("Capacity Bytes: " + capacityBytes);
 }