Example usage for org.apache.hadoop.fs.permission FsPermission UMASK_LABEL

List of usage examples for org.apache.hadoop.fs.permission FsPermission UMASK_LABEL

Introduction

In this page you can find the example usage for org.apache.hadoop.fs.permission FsPermission UMASK_LABEL.

Prototype

String UMASK_LABEL

To view the source code for org.apache.hadoop.fs.permission FsPermission UMASK_LABEL.

Click Source Link

Usage

From source file:com.thinkbiganalytics.nifi.v2.hdfs.CreateHDFSFolder.java

License:Apache License

@Override
protected void modifyConfig(ProcessContext context, Configuration config) {
    // Set umask once, to avoid thread safety issues doing it in onTrigger
    final PropertyValue umaskProp = context.getProperty(UMASK);
    final short dfsUmask = resolveUMask(umaskProp);

    short oldUmask = Short.parseShort(config.get(FsPermission.UMASK_LABEL), 8);
    if (oldUmask != dfsUmask) {
        FsPermission umask = FsPermission.createImmutable(dfsUmask);
        FsPermission.setUMask(config, umask);
    }/*from   w  w w. j a  va2s.co  m*/
}

From source file:org.apache.solr.core.backup.repository.HdfsBackupRepository.java

License:Apache License

@SuppressWarnings("rawtypes")
@Override//from www. java 2  s . co m
public void init(NamedList args) {
    this.config = args;

    // We don't really need this factory instance. But we want to initialize it here to
    // make sure that all HDFS related initialization is at one place (and not duplicated here).
    factory = new HdfsDirectoryFactory();
    factory.init(args);
    this.hdfsConfig = factory.getConf();

    // Configure the umask mode if specified.
    if (args.get(HDFS_UMASK_MODE_PARAM) != null) {
        String umaskVal = (String) args.get(HDFS_UMASK_MODE_PARAM);
        this.hdfsConfig.set(FsPermission.UMASK_LABEL, umaskVal);
    }

    String hdfsSolrHome = (String) Objects.requireNonNull(args.get(HdfsDirectoryFactory.HDFS_HOME),
            "Please specify " + HdfsDirectoryFactory.HDFS_HOME + " property.");
    Path path = new Path(hdfsSolrHome);
    while (path != null) { // Compute the path of root file-system (without requiring an additional system property).
        baseHdfsPath = path;
        path = path.getParent();
    }

    try {
        this.fileSystem = FileSystem.get(this.baseHdfsPath.toUri(), this.hdfsConfig);
    } catch (IOException e) {
        throw new SolrException(ErrorCode.SERVER_ERROR, e);
    }
}