Search in sources :

Example 1 with BlobStoreAclHandler

use of org.apache.storm.blobstore.BlobStoreAclHandler in project storm by apache.

the class HdfsBlobStore method prepareInternal.

/**
     * Allow a Hadoop Configuration to be passed for testing. If it's null then the hadoop configs
     * must be in your classpath.
     */
protected void prepareInternal(Map conf, String overrideBase, Configuration hadoopConf) {
    this.conf = conf;
    if (overrideBase == null) {
        overrideBase = (String) conf.get(Config.BLOBSTORE_DIR);
    }
    if (overrideBase == null) {
        throw new RuntimeException("You must specify a blobstore directory for HDFS to use!");
    }
    LOG.debug("directory is: {}", overrideBase);
    try {
        // if a HDFS keytab/principal have been supplied login, otherwise assume they are
        // logged in already or running insecure HDFS.
        String principal = (String) conf.get(Config.BLOBSTORE_HDFS_PRINCIPAL);
        String keyTab = (String) conf.get(Config.BLOBSTORE_HDFS_KEYTAB);
        if (principal != null && keyTab != null) {
            UserGroupInformation.loginUserFromKeytab(principal, keyTab);
        } else {
            if (principal == null && keyTab != null) {
                throw new RuntimeException("You must specify an HDFS principal to go with the keytab!");
            } else {
                if (principal != null && keyTab == null) {
                    throw new RuntimeException("You must specify HDFS keytab go with the principal!");
                }
            }
        }
    } catch (IOException e) {
        throw new RuntimeException("Error logging in from keytab!", e);
    }
    Path baseDir = new Path(overrideBase, BASE_BLOBS_DIR_NAME);
    try {
        if (hadoopConf != null) {
            _hbs = new HdfsBlobStoreImpl(baseDir, conf, hadoopConf);
        } else {
            _hbs = new HdfsBlobStoreImpl(baseDir, conf);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    _localSubject = getHadoopUser();
    _aclHandler = new BlobStoreAclHandler(conf);
}
Also used : Path(org.apache.hadoop.fs.Path) IOException(java.io.IOException) BlobStoreAclHandler(org.apache.storm.blobstore.BlobStoreAclHandler)

Example 2 with BlobStoreAclHandler

use of org.apache.storm.blobstore.BlobStoreAclHandler in project storm by apache.

the class HdfsBlobStore method prepareInternal.

/**
 * Allow a Hadoop Configuration to be passed for testing. If it's null then the hadoop configs
 * must be in your classpath.
 */
protected void prepareInternal(Map<String, Object> conf, String overrideBase, Configuration hadoopConf) {
    this.conf = conf;
    if (overrideBase == null) {
        overrideBase = (String) conf.get(Config.BLOBSTORE_DIR);
    }
    if (overrideBase == null) {
        throw new RuntimeException("You must specify a blobstore directory for HDFS to use!");
    }
    LOG.debug("directory is: {}", overrideBase);
    // Login to hdfs
    localSubject = HadoopLoginUtil.loginHadoop(conf);
    aclHandler = new BlobStoreAclHandler(conf);
    Path baseDir = new Path(overrideBase, BASE_BLOBS_DIR_NAME);
    try {
        if (hadoopConf != null) {
            hbs = new HdfsBlobStoreImpl(baseDir, conf, hadoopConf);
        } else {
            hbs = new HdfsBlobStoreImpl(baseDir, conf);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) BlobStoreAclHandler(org.apache.storm.blobstore.BlobStoreAclHandler) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 Path (org.apache.hadoop.fs.Path)2 BlobStoreAclHandler (org.apache.storm.blobstore.BlobStoreAclHandler)2