Package tachyon

Examples of tachyon.TachyonURI


   */
  @Test
  public void writeTest3() throws IOException, InvalidPathException, FileAlreadyExistException {
    for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
      for (WriteType op : WriteType.values()) {
        writeTest3Util(new TachyonURI("/root/testFile_" + k + "_" + op), op, k);
      }
    }
  }
View Full Code Here


   * @throws InterruptedException
   */
  @Test
  public void longWriteChangesUserId() throws IOException, InvalidPathException,
      FileAlreadyExistException, InterruptedException {
    TachyonURI filePath = new TachyonURI("/root/testFile");
    WriteType op = WriteType.THROUGH;
    int len = 2;
    int fileId = mTfs.createFile(filePath);
    long origId = mTfs.getUserId();
    TachyonFile file = mTfs.getFile(fileId);
View Full Code Here

  public void replaceHostNameTest() throws UnknownHostException {
    Assert.assertEquals(NetworkUtils.replaceHostName(TachyonURI.EMPTY_URI), TachyonURI.EMPTY_URI);
    Assert.assertEquals(NetworkUtils.replaceHostName(null), null);

    TachyonURI[] paths =
        new TachyonURI[] { new TachyonURI("hdfs://localhost:9000/dir"),
            new TachyonURI("hdfs://localhost/dir"), new TachyonURI("hdfs://localhost/"),
            new TachyonURI("hdfs://localhost"), new TachyonURI("file:///dir"),
            new TachyonURI("/dir"), new TachyonURI("anythingElse") };

    for (TachyonURI path : paths) {
      Assert.assertEquals(NetworkUtils.replaceHostName(path), path);
    }
  }
View Full Code Here

        mUfs.mkdirs(inclusion, true);
      }
      CommonUtils.touch(mUnderfsAddress + inclusion + "/1");
    }

    UfsUtils.loadUnderFs(mTfs, new TachyonURI(TachyonURI.SEPARATOR), new TachyonURI(mUnderfsAddress
        + TachyonURI.SEPARATOR), new PrefixList("tachyon;exclusions", ";"));

    List<String> paths = null;
    for (String exclusion : exclusions) {
      try {
View Full Code Here

    synchronized (mRootLock) {
      List<TachyonURI> ret = new ArrayList<TachyonURI>();
      ret.add(path);
      if (inode.isDirectory()) {
        for (Inode child : ((InodeFolder) inode).getChildren()) {
          TachyonURI childUri = path.join(child.getName());
          if (recursive) {
            ret.addAll(_ls(child, childUri, recursive));
          } else {
            ret.add(childUri);
          }
View Full Code Here

   * @throws InvalidPathException if the source path is a prefix of the destination
   */
  public boolean _rename(int fileId, TachyonURI dstPath, long opTimeMs)
      throws FileDoesNotExistException, InvalidPathException {
    synchronized (mRootLock) {
      TachyonURI srcPath = getPath(fileId);
      if (srcPath.equals(dstPath)) {
        return true;
      }
      if (srcPath.isRoot() || dstPath.isRoot()) {
        return false;
      }
      String[] srcComponents = CommonUtils.getPathComponents(srcPath.toString());
      String[] dstComponents = CommonUtils.getPathComponents(dstPath.toString());
      // We can't rename a path to one of its subpaths, so we check for that, by making sure
      // srcComponents isn't a prefix of dstComponents.
      if (srcComponents.length < dstComponents.length) {
        boolean isPrefix = true;
        for (int prefixInd = 0; prefixInd < srcComponents.length; prefixInd ++) {
          if (!srcComponents[prefixInd].equals(dstComponents[prefixInd])) {
            isPrefix = false;
            break;
          }
        }
        if (isPrefix) {
          throw new InvalidPathException("Failed to rename: " + srcPath + " is a prefix of "
              + dstPath);
        }
      }

      TachyonURI srcParent = srcPath.getParent();
      TachyonURI dstParent = dstPath.getParent();

      // We traverse down to the source and destinations' parent paths
      Inode srcParentInode = getInode(srcParent);
      if (srcParentInode == null || !srcParentInode.isDirectory()) {
        return false;
View Full Code Here

    Queue<Pair<InodeFolder, TachyonURI>> nodesQueue =
        new LinkedList<Pair<InodeFolder, TachyonURI>>();
    synchronized (mRootLock) {
      // TODO: Verify we want to use absolute path.
      nodesQueue.add(
          new Pair<InodeFolder, TachyonURI>(mRoot, new TachyonURI(TachyonURI.SEPARATOR)));
      while (!nodesQueue.isEmpty()) {
        Pair<InodeFolder, TachyonURI> tPair = nodesQueue.poll();
        InodeFolder tFolder = tPair.getFirst();
        TachyonURI curUri = tPair.getSecond();

        Set<Inode> children = tFolder.getChildren();
        for (Inode tInode : children) {
          TachyonURI newUri = curUri.join(tInode.getName());
          if (tInode.isDirectory()) {
            nodesQueue.add(new Pair<InodeFolder, TachyonURI>((InodeFolder) tInode, newUri));
          } else if (((InodeFile) tInode).isFullyInMemory()) {
            ret.add(newUri);
          }
View Full Code Here

   * @return the path of the inode
   */
  private TachyonURI getPath(Inode inode) {
    synchronized (mRootLock) {
      if (inode.getId() == 1) {
        return new TachyonURI(TachyonURI.SEPARATOR);
      }
      if (inode.getParentId() == 1) {
        return new TachyonURI(TachyonURI.SEPARATOR + inode.getName());
      }
      return getPath(mFileIdToInodes.get(inode.getParentId())).join(inode.getName());
    }
  }
View Full Code Here

      // file doesn't exist yet, so create it
      int fileId = client.createFile(filePath);
      file = client.getFile(fileId);
    } else if (deleteIfExists) {
      // file exists, so delete it and recreate
      client.delete(new TachyonURI(file.getPath()), false);

      int fileId = client.createFile(filePath);
      file = client.getFile(fileId);
    }
    return file;
View Full Code Here

  public static void main(final String[] args) throws IOException {
    if (args.length < 2 || args.length > 6) {
      usage();
    }

    Utils.runExample(new BasicNonByteBufferOperations(new TachyonURI(args[0]), new TachyonURI(
        args[1]), Utils.option(args, 2, WriteType.MUST_CACHE), Utils.option(args, 3,
        ReadType.NO_CACHE), Utils.option(args, 4, true), Utils.option(args, 5, 20)));
  }
View Full Code Here

TOP

Related Classes of tachyon.TachyonURI

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.