diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index c9ee423cf73706feb2774dacca9fc7b94fe80617..1946a466e31c851a2c51655baea558bcd8227cf3 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -115,6 +115,7 @@ public void setSparkConfigUpdated(boolean isSparkConfigUpdated) { public static final HiveConf.ConfVars[] metaVars = { HiveConf.ConfVars.METASTOREWAREHOUSE, HiveConf.ConfVars.METASTOREURIS, + HiveConf.ConfVars.METASTORE_SERVER_PORT, HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, HiveConf.ConfVars.METASTORETHRIFTFAILURERETRIES, HiveConf.ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY, @@ -381,7 +382,7 @@ public void setSparkConfigUpdated(boolean isSparkConfigUpdated) { "Number of retries while opening a connection to metastore"), METASTORETHRIFTFAILURERETRIES("hive.metastore.failure.retries", 1, "Number of retries upon failure of Thrift metastore calls"), - + METASTORE_SERVER_PORT("hive.metastore.port", 9083, "Hive Metastore listener port"), METASTORE_CLIENT_CONNECT_RETRY_DELAY("hive.metastore.client.connect.retry.delay", "1s", new TimeValidator(TimeUnit.SECONDS), "Number of seconds for the client to wait between consecutive connection attempts"), diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 3f267ff0eb20560c36a19b74353f9d6749c8b333..ba4d1409f33b33ab5dc12071a83ddae9e9539046 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -5775,18 +5775,19 @@ public static long renewDelegationToken(String tokenStrForm * */ static public class HiveMetastoreCli extends CommonCliOptions { - int port = DEFAULT_HIVE_METASTORE_PORT; + private int port; @SuppressWarnings("static-access") - public HiveMetastoreCli() { + public HiveMetastoreCli(Configuration configuration) { super("hivemetastore", true); + this.port = HiveConf.getIntVar(configuration, HiveConf.ConfVars.METASTORE_SERVER_PORT); // -p port OPTIONS.addOption(OptionBuilder .hasArg() .withArgName("port") .withDescription("Hive Metastore port number, default:" - + DEFAULT_HIVE_METASTORE_PORT) + + this.port) .create('p')); } @@ -5803,19 +5804,13 @@ public void parse(String[] args) { "This usage has been deprecated, consider using the new command " + "line syntax (run with -h to see usage information)"); - port = new Integer(args[0]); + this.port = new Integer(args[0]); } // notice that command line options take precedence over the // deprecated (old style) naked args... if (commandLine.hasOption('p')) { - port = Integer.parseInt(commandLine.getOptionValue('p')); - } else { - // legacy handling - String metastorePort = System.getenv("METASTORE_PORT"); - if (metastorePort != null) { - port = Integer.parseInt(metastorePort); - } + this.port = Integer.parseInt(commandLine.getOptionValue('p')); } } } @@ -5825,7 +5820,9 @@ public void parse(String[] args) { */ public static void main(String[] args) throws Throwable { HiveConf.setLoadMetastoreConfig(true); - HiveMetastoreCli cli = new HiveMetastoreCli(); + HiveConf conf = new HiveConf(HMSHandler.class); + + HiveMetastoreCli cli = new HiveMetastoreCli(conf); cli.parse(args); final boolean isCliVerbose = cli.isVerbose(); // NOTE: It is critical to do this prior to initializing log4j, otherwise @@ -5851,7 +5848,6 @@ public static void main(String[] args) throws Throwable { System.err.println(msg); } - HiveConf conf = new HiveConf(HMSHandler.class); // set all properties specified on the command line for (Map.Entry item : hiveconf.entrySet()) { @@ -5870,6 +5866,7 @@ public void run() { } }); + Lock startLock = new ReentrantLock(); Condition startCondition = startLock.newCondition(); AtomicBoolean startedServing = new AtomicBoolean();