Java Code Examples for org.apache.hadoop.fs.FileStatus#getAccessTime()

The following examples show how to use org.apache.hadoop.fs.FileStatus#getAccessTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseTestHttpFSWith.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void testSetTimes() throws Exception {
  if (!isLocalFS()) {
    FileSystem fs = FileSystem.get(getProxiedFSConf());
    Path path = new Path(getProxiedFSTestDir(), "foo.txt");
    OutputStream os = fs.create(path);
    os.write(1);
    os.close();
    FileStatus status1 = fs.getFileStatus(path);
    fs.close();
    long at = status1.getAccessTime();
    long mt = status1.getModificationTime();

    fs = getHttpFSFileSystem();
    fs.setTimes(path, mt - 10, at - 20);
    fs.close();

    fs = FileSystem.get(getProxiedFSConf());
    status1 = fs.getFileStatus(path);
    fs.close();
    long atNew = status1.getAccessTime();
    long mtNew = status1.getModificationTime();
    Assert.assertEquals(mtNew, mt - 10);
    Assert.assertEquals(atNew, at - 20);
  }
}
 
Example 2
Source File: BaseTestHttpFSWith.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void testSetTimes() throws Exception {
  if (!isLocalFS()) {
    FileSystem fs = FileSystem.get(getProxiedFSConf());
    Path path = new Path(getProxiedFSTestDir(), "foo.txt");
    OutputStream os = fs.create(path);
    os.write(1);
    os.close();
    FileStatus status1 = fs.getFileStatus(path);
    fs.close();
    long at = status1.getAccessTime();
    long mt = status1.getModificationTime();

    fs = getHttpFSFileSystem();
    fs.setTimes(path, mt - 10, at - 20);
    fs.close();

    fs = FileSystem.get(getProxiedFSConf());
    status1 = fs.getFileStatus(path);
    fs.close();
    long atNew = status1.getAccessTime();
    long mtNew = status1.getModificationTime();
    Assert.assertEquals(mtNew, mt - 10);
    Assert.assertEquals(atNew, at - 20);
  }
}
 
Example 3
Source File: HadoopFileSystem.java    From jsr203-hadoop with Apache License 2.0 6 votes vote down vote up
public void setTimes(byte[] bs, FileTime mtime, FileTime atime, FileTime ctime) throws IOException
{
	org.apache.hadoop.fs.Path hp = new HadoopPath(this, bs).getRawResolvedPath();
	long mtime_millis = 0;
	long atime_millis = 0;
   // Get actual value
	if (mtime == null || atime == null)
	{
		FileStatus stat = this.fs.getFileStatus(hp);
     mtime_millis = stat.getModificationTime();
		atime_millis = stat.getAccessTime();
	}
   if (mtime != null) {
     mtime_millis = mtime.toMillis();
   }
   if (atime != null) {
     atime_millis = atime.toMillis();
   }
	this.fs.setTimes(hp, mtime_millis, atime_millis);
}
 
Example 4
Source File: NTFSLocalFileSystem.java    From elasticsearch-hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus getFileStatus(Path f) throws IOException {
    // it's the RawFS in place which messes things up as it dynamically returns the permissions...
    // workaround by doing a copy
    FileStatus fs = super.getFileStatus(f);

    // work-around for Hive 0.14
    if (SCRATCH_DIR.equals(f.toString())) {
        System.out.println("Faking scratch dir permissions on Windows...");

        return new FileStatus(fs.getLen(), fs.isDir(), fs.getReplication(), fs.getBlockSize(),
                fs.getModificationTime(), fs.getAccessTime(), SCRATCH_DIR_PERMS, fs.getOwner(), fs.getGroup(),
                fs.getPath());
        // this doesn't work since the RawFS impl has its own algo that does the lookup dynamically
        //fs.getPermission().fromShort((short) 777);
    }
    return fs;
}
 
Example 5
Source File: ContainerFileSystem.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Transform remote file status to local.
 */
private static FileStatus transform(FileStatus input, String containerName) {
  return new FileStatus(input.getLen(),
          input.isDirectory(),
          input.getReplication(),
          input.getBlockSize(),
          input.getModificationTime(),
          input.getAccessTime(),
          input.getPermission(),
          input.getOwner(),
          input.getGroup(),
          transform(input.getPath(), containerName));
}
 
Example 6
Source File: InLineFileSystem.java    From hudi with Apache License 2.0 5 votes vote down vote up
@Override
public FileStatus getFileStatus(Path inlinePath) throws IOException {
  Path outerPath = InLineFSUtils.getOuterfilePathFromInlinePath(inlinePath);
  FileSystem outerFs = outerPath.getFileSystem(conf);
  FileStatus status = outerFs.getFileStatus(outerPath);
  FileStatus toReturn = new FileStatus(InLineFSUtils.length(inlinePath), status.isDirectory(), status.getReplication(), status.getBlockSize(),
      status.getModificationTime(), status.getAccessTime(), status.getPermission(), status.getOwner(),
      status.getGroup(), inlinePath);
  return toReturn;
}
 
Example 7
Source File: FileStatusEntity.java    From Eagle with Apache License 2.0 5 votes vote down vote up
public FileStatusEntity(FileStatus status) throws IOException {
    //this.path = status.getPath();
    this.length = status.getLen();
    this.isdir = status.isDirectory();
    this.block_replication = status.getReplication();
    this.blocksize = status.getBlockSize();
    this.modification_time = status.getModificationTime();
    this.access_time = status.getAccessTime();
    this.permission = status.getPermission();
    this.owner = status.getOwner();
    this.group = status.getGroup();
    if(status.isSymlink()) {
        this.symlink = status.getSymlink();
    }
}
 
Example 8
Source File: FileStatusEntity.java    From eagle with Apache License 2.0 5 votes vote down vote up
public FileStatusEntity(FileStatus status) throws IOException {
    //this.path = status.getPath();
    this.length = status.getLen();
    this.isdir = status.isDirectory();
    this.block_replication = status.getReplication();
    this.blocksize = status.getBlockSize();
    this.modification_time = status.getModificationTime();
    this.access_time = status.getAccessTime();
    this.permission = status.getPermission();
    this.owner = status.getOwner();
    this.group = status.getGroup();
    if(status.isSymlink()) {
        this.symlink = status.getSymlink();
    }
}
 
Example 9
Source File: InstrumentedFileSystemUtils.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Replace the scheme of the input {@link FileStatus} if it matches the string to replace.
 */
public static FileStatus replaceScheme(FileStatus st, String replace, String replacement) {
  if (replace != null && replace.equals(replacement)) {
    return st;
  }
  try {
    return new FileStatus(st.getLen(), st.isDir(), st.getReplication(), st.getBlockSize(), st.getModificationTime(),
        st.getAccessTime(), st.getPermission(), st.getOwner(), st.getGroup(), st.isSymlink() ? st.getSymlink() : null,
        replaceScheme(st.getPath(), replace, replacement));
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
 
Example 10
Source File: FileStatusExtended.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public FileStatusExtended(FileStatus stat, Block[] blocks, String leaseHolder) {
  super(stat.getLen(), stat.isDir(), stat.getReplication(),
      stat.getBlockSize(), stat.getModificationTime(), stat.getAccessTime(),
      stat.getPermission(), stat.getOwner(), stat.getGroup(), 
      stat.getPath());
  this.blocks = blocks;
  this.leaseHolder = (leaseHolder == null) ? "" : leaseHolder;
}
 
Example 11
Source File: HadoopIgfsSecondaryFileSystemTestAdapter.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public T2<Long, Long> times(String path) throws IOException {
    FileStatus status = get().getFileStatus(new Path(path));

    return new T2<>(status.getModificationTime(), status.getAccessTime());
}
 
Example 12
Source File: TestHFileCleaner.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * @param file to check
 * @return loggable information about the file
 */
private String getFileStats(Path file, FileSystem fs) throws IOException {
  FileStatus status = fs.getFileStatus(file);
  return "File" + file + ", mtime:" + status.getModificationTime() + ", atime:"
      + status.getAccessTime();
}