[
https://issues.apache.org/jira/browse/HIVE-10815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14587743#comment-14587743
]
Nemon Lou commented on HIVE-10815:
----------------------------------
The mechanism in promoteRandomMetaStoreURI() has some limitations:
if there's only two metastores,then the second one will always promote ,making
if fixed order again.
Changing position of the first metastore with a random one is reasonable when
need retry,and is better than changing positions of all the metastores randomly
before reconnect .
That why i keep it and adding a new random mechanism in the constructor.
Here is a piece of code that do the promote:
{code:java}
/**
* Swaps the first element of the metastoreUris array with a random element
from the
* remainder of the array.
*/
private void promoteRandomMetaStoreURI() {
if (metastoreUris.length <= 1) {
return;
}
Random rng = new Random();
int index = rng.nextInt(metastoreUris.length - 1) + 1;
URI tmp = metastoreUris[0];
metastoreUris[0] = metastoreUris[index];
metastoreUris[index] = tmp;
}
{code}
> Let HiveMetaStoreClient Choose MetaStore Randomly
> -------------------------------------------------
>
> Key: HIVE-10815
> URL: https://issues.apache.org/jira/browse/HIVE-10815
> Project: Hive
> Issue Type: Improvement
> Components: HiveServer2, Metastore
> Affects Versions: 1.2.0
> Reporter: Nemon Lou
> Assignee: Nemon Lou
> Attachments: HIVE-10815.patch
>
>
> Currently HiveMetaStoreClient using a fixed order to choose MetaStore URIs
> when multiple metastores configured.
> Choosing MetaStore Randomly will be good for load balance.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)