Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private boolean tryComplete(LocateRequest req, CompletableFuture<RegionLocations

this.metaReplicaSelector = CatalogReplicaLoadBalanceSelectorFactory.createSelector(
replicaSelectorClass, META_TABLE_NAME, conn, () -> {
int numOfReplicas = CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS;
int numOfReplicas = 1;
try {
RegionLocations metaLocations = conn.registry.getMetaRegionLocations().get(
conn.connConf.getReadRpcTimeoutNs(), TimeUnit.NANOSECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
@InterfaceAudience.Private
interface CatalogReplicaLoadBalanceSelector {

int UNINITIALIZED_NUM_OF_REPLICAS = -1;

/**
* This method is called when input location is stale, i.e, when clients run into
* org.apache.hadoop.hbase.NotServingRegionException.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public String toString() {
private final TableName tableName;
private final IntSupplier getNumOfReplicas;
private volatile boolean isStopped = false;
private final static int UNINITIALIZED_NUM_OF_REPLICAS = -1;

CatalogReplicaLoadBalanceSimpleSelector(TableName tableName, AsyncConnectionImpl conn,
IntSupplier getNumOfReplicas) {
Expand All @@ -116,7 +117,7 @@ public String toString() {
this.getNumOfReplicas = getNumOfReplicas;

// This numOfReplicas is going to be lazy initialized.
this.numOfReplicas = CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS;
this.numOfReplicas = UNINITIALIZED_NUM_OF_REPLICAS;
// Start chores
this.conn.getChoreService().scheduleChore(getCacheCleanupChore(this));
this.conn.getChoreService().scheduleChore(getRefreshReplicaCountChore(this));
Expand Down Expand Up @@ -145,7 +146,7 @@ public void onError(HRegionLocation loc) {
*/
private int getRandomReplicaId() {
int cachedNumOfReplicas = this.numOfReplicas;
if (cachedNumOfReplicas == CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS) {
if (cachedNumOfReplicas == UNINITIALIZED_NUM_OF_REPLICAS) {
cachedNumOfReplicas = refreshCatalogReplicaCount();
this.numOfReplicas = cachedNumOfReplicas;
}
Expand Down Expand Up @@ -261,16 +262,16 @@ private void cleanupReplicaReplicaStaleCache() {
private int refreshCatalogReplicaCount() {
int newNumOfReplicas = this.getNumOfReplicas.getAsInt();
LOG.debug("Refreshed replica count {}", newNumOfReplicas);
// If the returned number of replicas is -1, it is caused by failure to fetch the
// replica count. Do not update the numOfReplicas in this case.
if (newNumOfReplicas == CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS) {
LOG.error("Failed to fetch Table {}'s region replica count", tableName);
return this.numOfReplicas;
if (newNumOfReplicas == 1) {
LOG.warn("Table {}'s region replica count is 1, maybe a misconfiguration or failure to "
+ "fetch the replica count", tableName);
}

int cachedNumOfReplicas = this.numOfReplicas;

// If the returned number of replicas is 1, it is mostly caused by failure to fetch the
// replica count. Do not update the numOfReplicas in this case.
if ((cachedNumOfReplicas == UNINITIALIZED_NUM_OF_REPLICAS) ||
(cachedNumOfReplicas != newNumOfReplicas)) {
((cachedNumOfReplicas != newNumOfReplicas) && (newNumOfReplicas != 1))) {
this.numOfReplicas = newNumOfReplicas;
}
return newNumOfReplicas;
Expand Down

This file was deleted.