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 @@ -34,6 +34,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -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;