Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.FileStatus


    if (extraBlockSize > 0 && extraBlockSize < blockSize) {
      blocks.add(new BlockLocation(new String[]{"names"+i}, new String[]{"hosts"+i}, offset, extraBlockSize));
      offset += extraBlockSize;
    }

    FileStatus mStatus = mock(FileStatus.class);
    Path mPath = mock(Path.class);
    FileSystem mFs = mock(FileSystem.class);
    when(mStatus.getLen()).thenReturn(offset);
    when(mStatus.getBlockSize()).thenReturn(blockSize);
    when(mFs.getFileStatus(mPath)).thenReturn(mStatus);

    when(mFs.getFileBlockLocations((FileStatus)any(), anyLong(), anyLong())).thenAnswer(new Answer<BlockLocation[]>() {

      @Override
View Full Code Here


    public FileStatus[] listStatus(Path pathPattern) throws IOException {
      ArrayList<FileStatus> files = new ArrayList<FileStatus>();
      long modTime = 150;
      for (int j = 0; j<unique; j++) {
        for (int i = 0; i<count; i++) {
          files.add(new FileStatus(10, false, 1, 150, modTime++, new Path("/foo/base-fakeuuid-" + j + "-"+ i + ".extension.tmp")));
        }
      }
      return files.toArray(new FileStatus[0]);
    }
View Full Code Here

      }
      return Collections.emptySet();
    }
    // previous exists() should make sure we don't
    // get FileNotFoundException
    FileStatus fileStatus = fs.getFileStatus(rootDir);
    if (!fileStatus.isDir()) {
      // Complain louder if it exists but is no directory.
      if (log.isWarnEnabled()) {
        log.warn("Skipping [" + rootDir.toUri().getPath() + "] because it does not denote a directory");
      }
      return Collections.emptySet();
View Full Code Here

      exists = fs.exists(path);
    } catch (Exception ex) {
    }
    this.exists = exists;

    FileStatus status = null;
    try {
      status = fs.getFileStatus(path);
    } catch (Exception ex) {
    }
    this.status = status;
View Full Code Here

          for (FileStatus status : fileStatus) {
            results.put(status.getPath(), srcFs.getContentSummary(status.getPath()).getLength());
          }
        }
        else {
          FileStatus items[] = srcFs.listStatus(FileUtil.stat2Paths(fileStatus, srcPath));
          if (ObjectUtils.isEmpty(items) && (!srcFs.exists(srcPath))) {
            throw new HadoopException("Cannot access " + src + ": No such file or directory.");
          }
          for (FileStatus status : items) {
            Long size = (status.isDir() ? srcFs.getContentSummary(status.getPath()).getLength() : status.getLen());
View Full Code Here

  public void mkdir(String... uris) {
    for (String src : uris) {
      try {
        Path p = new Path(src);
        FileSystem srcFs = getFS(p);
        FileStatus fstatus = null;
        try {
          fstatus = srcFs.getFileStatus(p);
          if (fstatus.isDir()) {
            throw new IllegalStateException("Cannot create directory " + src + ": File exists");
          }
          else {
            throw new IllegalStateException(src + " exists but is not a directory");
          }
View Full Code Here

        if (srcs.length > 1 && !isDstDir) {
          throw new IllegalArgumentException("When moving multiple files, destination should be a directory.");
        }
        for (Path s : srcs) {
          if (!srcFs.rename(s, dstPath)) {
            FileStatus srcFstatus = null;
            FileStatus dstFstatus = null;
            try {
              srcFstatus = srcFs.getFileStatus(s);
            } catch (FileNotFoundException e) {
              // ignore
            }
            try {
              dstFstatus = dstFs.getFileStatus(dstPath);
            } catch (IOException e) {
            }
            if ((srcFstatus != null) && (dstFstatus != null)) {
              if (srcFstatus.isDir() && !dstFstatus.isDir()) {
                throw new IllegalArgumentException("cannot overwrite non directory " + dstPath
                    + " with directory " + s);
              }
            }
            throw new HadoopException("Failed to rename " + s + " to " + dstPath);
View Full Code Here

      try {
        Path src = new Path(uri);
        FileSystem srcFs = getFS(src);

        for (Path p : FileUtil.stat2Paths(srcFs.globStatus(src), src)) {
          FileStatus status = srcFs.getFileStatus(p);
          if (status.isDir() && !recursive) {
            throw new IllegalStateException("Cannot remove directory \"" + src
                + "\", if recursive deletion was not specified");
          }
          if (!skipTrash) {
            try {
View Full Code Here

        boolean waitUntilDone = (secondsToWait == 0);
        long timeLeft = TimeUnit.SECONDS.toMillis(secondsToWait);

        for (Path path : waitList) {
          FileSystem srcFs = getFS(path);
          FileStatus status = srcFs.getFileStatus(path);
          long len = status.getLen();

          boolean done = false;

          while (!done) {
            BlockLocation[] locations = srcFs.getFileBlockLocations(status, 0, len);
View Full Code Here

        throw new HadoopException("Cannot set replication for " + src);
      }
    }
    else {
      if (recursive) {
        FileStatus items[] = srcFs.listStatus(src);
        if (!ObjectUtils.isEmpty(items)) {
          for (FileStatus status : items) {
            setrep(replication, recursive, srcFs, status.getPath(), waitList);
          }
        }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.fs.FileStatus

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.