From bc56b2ebc53f32c22beb1874d50b6e5ec29aeb98 Mon Sep 17 00:00:00 2001 From: Jason <181276056@qq.com> Date: Fri, 25 Dec 2015 18:34:53 +0800 Subject: [PATCH] shuffle the metastore uris, so the request can be balanced to metastores Currently, HiveMetaStoreClient connect to the first metastore uri defaultly If we have multi metastore uris. So the client only send request to the first metastore, the metastore will be the bottleneck to process the client request. I add the logic to shuffle metastore uris, so that the request can be balanced to all of the metastores. Signed-off-by: xgliao --- .../src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 09a6aea..808159b 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -239,6 +239,9 @@ public HiveMetaStoreClient(HiveConf conf, HiveMetaHookLoader hookLoader) if (conf.getVar(HiveConf.ConfVars.METASTOREURIS) != null) { String metastoreUrisString[] = conf.getVar( HiveConf.ConfVars.METASTOREURIS).split(","); + // shuffle the metastore uris, so the request can be balanced to metastores + Collections.shuffle(Arrays.asList(metastoreUrisString)); + metastoreUris = new URI[metastoreUrisString.length]; try { int i = 0; -- 1.8.3.msysgit.0