Java Code Examples for org.apache.hadoop.fs.permission.FsPermission#getDirDefault()

The following examples show how to use org.apache.hadoop.fs.permission.FsPermission#getDirDefault() . 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: CrailHadoopFileSystem.java    From incubator-crail with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus[] listStatus(Path path) throws FileNotFoundException, IOException {
	try {
		CrailNode node = dfs.lookup(path.toUri().getRawPath()).get();
		Iterator<String> iter = node.asContainer().listEntries();
		ArrayList<FileStatus> statusList = new ArrayList<FileStatus>();
		while(iter.hasNext()){
			String filepath = iter.next();
			CrailNode directFile = dfs.lookup(filepath).get();
			if (directFile != null){
				FsPermission permission = FsPermission.getFileDefault();
				if (directFile.getType().isDirectory()) {
					permission = FsPermission.getDirDefault();
				}
				FileStatus status = new FileStatus(directFile.getCapacity(), directFile.getType().isContainer(), CrailConstants.SHADOW_REPLICATION, CrailConstants.BLOCK_SIZE, directFile.getModificationTime(), directFile.getModificationTime(), permission, CrailConstants.USER, CrailConstants.USER, new Path(filepath).makeQualified(this.getUri(), this.workingDir));	
				statusList.add(status);
			}
		}
		FileStatus[] list = new FileStatus[statusList.size()];
		statusList.toArray(list);
		return list;
	} catch(Exception e){
		throw new FileNotFoundException(path.toUri().getRawPath());
	}
}
 
Example 2
Source File: CrailHadoopFileSystem.java    From incubator-crail with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus getFileStatus(Path path) throws IOException {
	statistics.incrementReadOps(1);
	CrailNode directFile = null;
	try {
		directFile = dfs.lookup(path.toUri().getRawPath()).get();
	} catch (Exception e) {
		throw new IOException(e);
	}
	if (directFile == null) {
		throw new FileNotFoundException("File does not exist: " + path);
	}
	FsPermission permission = FsPermission.getFileDefault();
	if (directFile.getType().isDirectory()) {
		permission = FsPermission.getDirDefault();
	}
	FileStatus status = new FileStatus(directFile.getCapacity(), directFile.getType().isContainer(), CrailConstants.SHADOW_REPLICATION, CrailConstants.BLOCK_SIZE, directFile.getModificationTime(), directFile.getModificationTime(), permission, CrailConstants.USER, CrailConstants.USER, path.makeQualified(this.getUri(), this.workingDir));
	return status;
}
 
Example 3
Source File: RawLocalFileSystem.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected boolean mkOneDirWithMode(Path p, File p2f, FsPermission permission)
    throws IOException {
  if (permission == null) {
    permission = FsPermission.getDirDefault();
  }
  permission = permission.applyUMask(FsPermission.getUMask(getConf()));
  if (Shell.WINDOWS && NativeIO.isAvailable()) {
    try {
      NativeIO.Windows.createDirectoryWithMode(p2f, permission.toShort());
      return true;
    } catch (IOException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug(String.format(
            "NativeIO.createDirectoryWithMode error, path = %s, mode = %o",
            p2f, permission.toShort()), e);
      }
      return false;
    }
  } else {
    boolean b = p2f.mkdir();
    if (b) {
      setPermission(p, permission);
    }
    return b;
  }
}
 
Example 4
Source File: CrailHDFS.java    From crail with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus getFileStatus(Path path) throws AccessControlException, FileNotFoundException, UnresolvedLinkException, IOException {
	CrailNode directFile = null;
	try {
		directFile = dfs.lookup(path.toUri().getRawPath()).get();
	} catch(Exception e){
		throw new IOException(e);
	}
	if (directFile == null){
		throw new FileNotFoundException("filename " + path);
	}
	
	FsPermission permission = FsPermission.getFileDefault();
	if (directFile.getType().isDirectory()) {
		permission = FsPermission.getDirDefault();
	}		
	FileStatus status = new FileStatus(directFile.getCapacity(), directFile.getType().isContainer(), CrailConstants.SHADOW_REPLICATION, CrailConstants.BLOCK_SIZE, directFile.getModificationTime(), directFile.getModificationTime(), permission, CrailConstants.USER, CrailConstants.USER, path.makeQualified(this.getUri(), this.workingDir));
	return status;
}
 
Example 5
Source File: CrailHDFS.java    From crail with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus[] listStatus(Path path) throws AccessControlException, FileNotFoundException, UnresolvedLinkException, IOException {
	try {
		CrailNode node = dfs.lookup(path.toUri().getRawPath()).get();
		Iterator<String> iter = node.asContainer().listEntries();
		ArrayList<FileStatus> statusList = new ArrayList<FileStatus>();
		while(iter.hasNext()){
			String filepath = iter.next();
			CrailNode directFile = dfs.lookup(filepath).get();
			if (directFile != null){
				FsPermission permission = FsPermission.getFileDefault();
				if (directFile.getType().isDirectory()) {
					permission = FsPermission.getDirDefault();
				}
				FileStatus status = new FileStatus(directFile.getCapacity(), directFile.getType().isContainer(), CrailConstants.SHADOW_REPLICATION, CrailConstants.BLOCK_SIZE, directFile.getModificationTime(), directFile.getModificationTime(), permission, CrailConstants.USER, CrailConstants.USER, new Path(filepath).makeQualified(this.getUri(), workingDir));	
				statusList.add(status);
			}
		}
		FileStatus[] list = new FileStatus[statusList.size()];
		statusList.toArray(list);
		return list;
	} catch(Exception e){
		throw new FileNotFoundException(path.toUri().getRawPath());
	}
}
 
Example 6
Source File: CrailHadoopFileSystem.java    From crail with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus[] listStatus(Path path) throws FileNotFoundException, IOException {
	try {
		CrailNode node = dfs.lookup(path.toUri().getRawPath()).get();
		Iterator<String> iter = node.asContainer().listEntries();
		ArrayList<FileStatus> statusList = new ArrayList<FileStatus>();
		while(iter.hasNext()){
			String filepath = iter.next();
			CrailNode directFile = dfs.lookup(filepath).get();
			if (directFile != null){
				FsPermission permission = FsPermission.getFileDefault();
				if (directFile.getType().isDirectory()) {
					permission = FsPermission.getDirDefault();
				}
				FileStatus status = new FileStatus(directFile.getCapacity(), directFile.getType().isContainer(), CrailConstants.SHADOW_REPLICATION, CrailConstants.BLOCK_SIZE, directFile.getModificationTime(), directFile.getModificationTime(), permission, CrailConstants.USER, CrailConstants.USER, new Path(filepath).makeQualified(this.getUri(), this.workingDir));	
				statusList.add(status);
			}
		}
		FileStatus[] list = new FileStatus[statusList.size()];
		statusList.toArray(list);
		return list;
	} catch(Exception e){
		throw new FileNotFoundException(path.toUri().getRawPath());
	}
}
 
Example 7
Source File: CrailHadoopFileSystem.java    From crail with Apache License 2.0 6 votes vote down vote up
@Override
public FileStatus getFileStatus(Path path) throws IOException {
	CrailNode directFile = null;
	try {
		directFile = dfs.lookup(path.toUri().getRawPath()).get();
	} catch (Exception e) {
		throw new IOException(e);
	}
	if (directFile == null) {
		throw new FileNotFoundException("File does not exist: " + path);
	}
	FsPermission permission = FsPermission.getFileDefault();
	if (directFile.getType().isDirectory()) {
		permission = FsPermission.getDirDefault();
	}
	FileStatus status = new FileStatus(directFile.getCapacity(), directFile.getType().isContainer(), CrailConstants.SHADOW_REPLICATION, CrailConstants.BLOCK_SIZE, directFile.getModificationTime(), directFile.getModificationTime(), permission, CrailConstants.USER, CrailConstants.USER, path.makeQualified(this.getUri(), this.workingDir));
	return status;
}