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 860f566
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 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 @@ -27,7 +27,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.Consumer;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.RegionLocations;
import org.apache.hadoop.hbase.ServerName;
Expand Down Expand Up @@ -248,12 +247,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 +262,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 860f566

Please sign in to comment.