From d7c6e8fcf99265204f2ab7ec071974c14ac97fe4 Mon Sep 17 00:00:00 2001 From: Prabhu Joseph Date: Thu, 11 Apr 2019 21:13:18 +0530 Subject: [PATCH] YARN-7537 --- .../storage/common/HBaseTimelineStorageUtils.java | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/HBaseTimelineStorageUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/HBaseTimelineStorageUtils.java index f4cd6fb..cffdac9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/HBaseTimelineStorageUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/HBaseTimelineStorageUtils.java @@ -17,11 +17,13 @@ package org.apache.hadoop.yarn.server.timelineservice.storage.common; -import java.net.MalformedURLException; -import java.net.URL; +import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.client.Query; @@ -40,7 +42,6 @@ private HBaseTimelineStorageUtils() { } - /** * @param conf YARN configuration. Used to see if there is an explicit config * pointing to the HBase config file to read. It should not be null @@ -48,28 +49,42 @@ private HBaseTimelineStorageUtils() { * @return a configuration with the HBase configuration from the classpath, * optionally overwritten by the timeline service configuration URL if * specified. - * @throws MalformedURLException if a timeline service HBase configuration URL - * is specified but is a malformed URL. + * @throws IOException if a timeline service HBase configuration URL + * is specified but unable to read it. */ public static Configuration getTimelineServiceHBaseConf(Configuration conf) - throws MalformedURLException { + throws IOException { if (conf == null) { throw new NullPointerException(); } Configuration hbaseConf; - String timelineServiceHBaseConfFileURL = + String timelineServiceHBaseConfFilePath = conf.get(YarnConfiguration.TIMELINE_SERVICE_HBASE_CONFIGURATION_FILE); - if (timelineServiceHBaseConfFileURL != null - && timelineServiceHBaseConfFileURL.length() > 0) { + + if (timelineServiceHBaseConfFilePath != null + && timelineServiceHBaseConfFilePath.length() > 0) { LOG.info("Using hbase configuration at " + - timelineServiceHBaseConfFileURL); + timelineServiceHBaseConfFilePath); // create a clone so that we don't mess with out input one hbaseConf = new Configuration(conf); Configuration plainHBaseConf = new Configuration(false); - URL hbaseSiteXML = new URL(timelineServiceHBaseConfFileURL); - plainHBaseConf.addResource(hbaseSiteXML); - HBaseConfiguration.merge(hbaseConf, plainHBaseConf); + FileSystem fs = null; + FSDataInputStream in = null; + try { + Path hbaseConfigPath = new Path(timelineServiceHBaseConfFilePath); + fs = FileSystem.newInstance(hbaseConfigPath.toUri(), conf); + in = fs.open(hbaseConfigPath); + plainHBaseConf.addResource(in); + HBaseConfiguration.merge(hbaseConf, plainHBaseConf); + } finally { + if (in != null) { + in.close(); + } + if (fs != null) { + fs.close(); + } + } } else { // default to what is on the classpath hbaseConf = HBaseConfiguration.create(conf); -- 2.7.4 (Apple Git-66)