Java Code Examples for org.apache.kylin.common.KylinConfig#streamToProps()

The following examples show how to use org.apache.kylin.common.KylinConfig#streamToProps() . 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: MetaDumpUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static KylinConfig loadKylinConfigFromHdfs(String uri) {
    if (uri == null)
        throw new IllegalArgumentException("StorageUrl should not be null");
    if (!uri.contains("@hdfs"))
        throw new IllegalArgumentException("StorageUrl should like @hdfs schema");
    logger.info("Ready to load KylinConfig from uri: {}", uri);
    StorageURL url = StorageURL.valueOf(uri);
    String metaDir = url.getParameter("path") + "/" + KylinConfig.KYLIN_CONF_PROPERTIES_FILE;
    Path path = new Path(metaDir);
    try (InputStream is = path.getFileSystem(HadoopUtil.getCurrentConfiguration()).open(new Path(metaDir))) {
        Properties prop = KylinConfig.streamToProps(is);
        return KylinConfig.createKylinConfig(prop);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 2
Source File: AbstractHadoopJob.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static KylinConfig loadKylinConfigFromHdfs(String uri) {
    if (uri == null)
        throw new IllegalArgumentException("meta url should not be null");

    if (!uri.contains("@hdfs"))
        throw new IllegalArgumentException("meta url should like @hdfs schema");

    if (kylinConfigCache.get(uri) != null) {
        logger.info("KylinConfig cached for : {}", uri);
        return kylinConfigCache.get(uri);
    }

    logger.info("Ready to load KylinConfig from uri: {}", uri);
    KylinConfig config;
    FileSystem fs;
    String realHdfsPath = StorageURL.valueOf(uri).getParameter("path") + "/" + KylinConfig.KYLIN_CONF_PROPERTIES_FILE;
    try {
        fs = HadoopUtil.getFileSystem(realHdfsPath);
        InputStream is = fs.open(new Path(realHdfsPath));
        Properties prop = KylinConfig.streamToProps(is);
        config = KylinConfig.createKylinConfig(prop);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    kylinConfigCache.put(uri, config);
    return config;
}
 
Example 3
Source File: AbstractHadoopJob.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static KylinConfig loadKylinConfigFromHdfs(String uri) {
    if (uri == null)
        throw new IllegalArgumentException("meta url should not be null");

    if (!uri.contains("@hdfs"))
        throw new IllegalArgumentException("meta url should like @hdfs schema");

    if (kylinConfigCache.get(uri) != null) {
        logger.info("KylinConfig cached for : {}", uri);
        return kylinConfigCache.get(uri);
    }

    logger.info("Ready to load KylinConfig from uri: {}", uri);
    KylinConfig config;
    FileSystem fs;
    String realHdfsPath = StorageURL.valueOf(uri).getParameter("path") + "/" + KylinConfig.KYLIN_CONF_PROPERTIES_FILE;
    try {
        fs = HadoopUtil.getFileSystem(realHdfsPath);
        InputStream is = fs.open(new Path(realHdfsPath));
        Properties prop = KylinConfig.streamToProps(is);
        config = KylinConfig.createKylinConfig(prop);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    kylinConfigCache.put(uri, config);
    return config;
}