Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.FileStatus


        throws IOException {
      // check if the tokenJob file is there..
      Path skPath = new Path(systemDirectory,
          jobId.toString()+"/"+TokenCache.JOB_TOKEN_HDFS_FILE);
     
      FileStatus status = null;
      long jobTokenSize = -1;
      status = systemFS.getFileStatus(skPath); //throws FileNotFoundException
      jobTokenSize = status.getLen();
     
      Path localJobTokenFile =
          lDirAlloc.getLocalPathForWrite(getLocalJobTokenFile(user,
              jobId.toString()), jobTokenSize, fConf);
   
View Full Code Here


                                   ") total_size(" + cbsize + ") listuri(" +
                                   srcfilelist + ")");
      }
      Path src = new Path(srcfilelist);
      FileSystem fs = src.getFileSystem(job);
      FileStatus srcst = fs.getFileStatus(src);

      ArrayList<FileSplit> splits = new ArrayList<FileSplit>(numSplits);
      LongWritable key = new LongWritable();
      FilePair value = new FilePair();
      final long targetsize = cbsize / numSplits;
      long pos = 0L;
      long last = 0L;
      long acc = 0L;
      long cbrem = srcst.getLen();
      SequenceFile.Reader sl = null;
      try {
        sl = new SequenceFile.Reader(fs, src, job);
        for (; sl.next(key, value); last = sl.getPosition()) {
          // if adding this split would put this split past the target size,
View Full Code Here

        if (!destFileSys.mkdirs(absdst.getParent())) {
          throw new IOException("Failed to create parent dir: " + absdst.getParent());
        }
        rename(tmpfile, absdst);

        FileStatus dststat = destFileSys.getFileStatus(absdst);
        if (dststat.getLen() != srcstat.getLen()) {
          destFileSys.delete(absdst, false);
          throw new IOException("File size not matched: copied "
              + bytesString(dststat.getLen()) + " to dst (=" + absdst
              + ") but expected " + bytesString(srcstat.getLen())
              + " from " + srcstat.getPath());       
        }
        updatePermissions(srcstat, dststat);
      }
View Full Code Here

      JobID jobId, FileSystem fs, Configuration conf, Path jobSubmitDir)
  throws IOException {
    long maxMetaInfoSize = conf.getLong("mapreduce.jobtracker.split.metainfo.maxsize",
        10000000L);
    Path metaSplitFile = JobSubmissionFiles.getJobSplitMetaFile(jobSubmitDir);
    FileStatus fStatus = fs.getFileStatus(metaSplitFile);
    if (maxMetaInfoSize > 0 && fStatus.getLen() > maxMetaInfoSize) {
      throw new IOException("Split metadata size exceeded " +
          maxMetaInfoSize +". Aborting job " + jobId);
    }
    FSDataInputStream in = fs.open(metaSplitFile);
    byte[] header = new byte[JobSplit.META_SPLIT_FILE_HEADER.length];
View Full Code Here

     */
    public void map(LongWritable key,
                    FilePair value,
                    OutputCollector<WritableComparable<?>, Text> out,
                    Reporter reporter) throws IOException {
      final FileStatus srcstat = value.input;
      final Path relativedst = new Path(value.output);
      try {
        copy(srcstat, relativedst, out, reporter);
      } catch (IOException e) {
        ++failcount;
View Full Code Here

      // we do a recursive ls on these paths
      // and then write them to the input file
      // one at a time
      for (Path src: srcPaths) {
        ArrayList<FileStatusDir> allFiles = new ArrayList<FileStatusDir>();
        FileStatus fstatus = fs.getFileStatus(src);
        FileStatusDir fdir = new FileStatusDir(fstatus, null);
        recursivels(fs, fdir, allFiles);
        for (FileStatusDir statDir: allFiles) {
          FileStatus stat = statDir.getFileStatus();
          String toWrite = "";
          long len = stat.isDir()? 0:stat.getLen();
          if (stat.isDir()) {
            toWrite = "" + relPathToRoot(stat.getPath(), parentPath) + " dir ";
            //get the children
            FileStatus[] list = statDir.getChildren();
            StringBuffer sbuff = new StringBuffer();
            sbuff.append(toWrite);
            for (FileStatus stats: list) {
              sbuff.append(stats.getPath().getName() + " ");
            }
            toWrite = sbuff.toString();
          }
          else {
            toWrite +=  relPathToRoot(stat.getPath(), parentPath) + " file ";
          }
          srcWriter.append(new LongWritable(len), new
              Text(toWrite));
          srcWriter.sync();
          numFiles++;
View Full Code Here

      if (filelist != null) {
        buff.append(filelist.length).append("_");
        for (String s : filelist) {
          crc32.update(new String(s).getBytes());
          FileStatus fstatus=null;
          try {
            fstatus=this.fileStatus(s) ;
          } catch (Throwable e) {
            fstatus=null;
            logger.error("fileStatus", e);
          }
          if(fstatus!=null)
          {
            filesize += fstatus.getLen();
            filemodify = Math.max(filemodify, fstatus.getModificationTime());
          }

       
        }
      }
View Full Code Here

      create();
  }

  boolean isDir = false;
  try {
      FileStatus status = fs.getFileStatus(directory);
      if (status != null) {
    isDir = status.isDir();
      }
  } catch (IOException e) {
      // file does not exist, isDir already set to false
  }
  if (!isDir) {
View Full Code Here

      fs.mkdirs(directory);
  }

  boolean isDir = false;
  try {
      FileStatus status = fs.getFileStatus(directory);
      if (status != null) {
    isDir = status.isDir();
      }
  } catch (IOException e) {
      // file does not exist, isDir already set to false
  }
  if (!isDir) {
View Full Code Here

    {
      boolean isnotrealtime=false;
      try{
      if(fs.exists(hdfsPartionShardPath))
      {
        FileStatus fstat=fs.getFileStatus(hdfsPartionShardPath);//针对云梯,要判断是文件还是目录
        if(!fstat.isDir())
        {
          isnotrealtime=true;
        }
      }else{
        isnotrealtime=true;
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.