Skip to content

Commit

Permalink
remove callback
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeaudreault committed Feb 18, 2023
1 parent 2728882 commit 1a88094
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ private void recordClearRegionCache() {
private void removeLocationFromCache(HRegionLocation loc) {
TableCache tableCache = cache.get(loc.getRegion().getTable());
if (tableCache != null) {
if (tableCache.regionLocationCache.remove(loc, this::updateMetaReplicaSelector)) {
if (tableCache.regionLocationCache.remove(loc)) {
recordClearRegionCache();
updateMetaReplicaSelector(loc);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,10 @@ public RegionLocations findForBeforeRow(byte[] row, int replicaId) {
}

/**
* Removes the location from the cache if it exists and can be removed. Once a change is deemed
* possible, calls beforeUpdate callback prior to making a change. Calls afterUpdate callback
* after making a change.
* Removes the location from the cache if it exists and can be removed.
* @return true if entry was removed
*/
public synchronized boolean remove(HRegionLocation loc, Consumer<HRegionLocation> beforeUpdate) {
public synchronized boolean remove(HRegionLocation loc) {
byte[] startKey = loc.getRegion().getStartKey();
RegionLocations oldLocs = cache.get(startKey);
if (oldLocs == null) {
Expand All @@ -265,8 +263,6 @@ public synchronized boolean remove(HRegionLocation loc, Consumer<HRegionLocation
return false;
}

beforeUpdate.accept(loc);

RegionLocations newLocs = removeRegionLocation(oldLocs, loc.getRegion().getReplicaId());
if (newLocs == null) {
if (cache.remove(startKey, oldLocs)) {
Expand Down

0 comments on commit 1a88094

Please sign in to comment.