huaxiangsun commented on a change in pull request #4078:
URL: https://github.com/apache/hbase/pull/4078#discussion_r795935211
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
##########
@@ -567,19 +569,55 @@ public static Scan getScanForTableName(Configuration
conf, TableName tableName)
// Stop key appends the smallest possible char to the table name
byte[] stopKey = getTableStopRowForMeta(tableName, QueryType.REGION);
- Scan scan = getMetaScan(conf, -1);
+ Scan scan = getMetaScan(null, conf, -1);
scan.setStartRow(startKey);
scan.setStopRow(stopKey);
return scan;
}
- private static Scan getMetaScan(Configuration conf, int rowUpperLimit) {
+ private static Scan getMetaScan(Connection conn, Configuration conf, int
rowUpperLimit) {
Scan scan = new Scan();
int scannerCaching = conf.getInt(HConstants.HBASE_META_SCANNER_CACHING,
HConstants.DEFAULT_HBASE_META_SCANNER_CACHING);
- if (conf.getBoolean(HConstants.USE_META_REPLICAS,
HConstants.DEFAULT_USE_META_REPLICAS)) {
- scan.setConsistency(Consistency.TIMELINE);
+
+ // Get the region locator's meta replica mode.
+ CatalogReplicaMode metaReplicaMode = CatalogReplicaMode.fromString(
+ conf.get(LOCATOR_META_REPLICAS_MODE,
CatalogReplicaMode.NONE.toString()));
+
+ switch (metaReplicaMode) {
+ case LOAD_BALANCE:
+ int numOfReplicas = 1;
+ if (conn != null) {
+ try {
+ try (Table metaTable = getMetaHTable(conn)) {
+ numOfReplicas = metaTable.getDescriptor().getRegionReplication();
Review comment:
I reverted the commit to the master. You are right, the network call is
bad. How about changing getMetaScan from a static method to a non-static one,
so it can use a cached meta Replica count? Need to handle the case that meta
replica count is changed dynamically.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]