MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / invalidateRegionCache

Method invalidateRegionCache

src/HBaseClient.java:3333–3381  ·  view source on GitHub ↗

Invalidates any cached knowledge about the given region. This is typically used when a region migrates because of a split or a migration done by the region load balancer, which causes a NotServingRegionException. This is package-private so that the low-level RegionClient can

(final byte[] region_name,
                                     final boolean mark_as_nsred,
                                     final String reason)

Source from the content-addressed store, hash-verified

3331 * about the cache invalidation done.
3332 */
3333 private void invalidateRegionCache(final byte[] region_name,
3334 final boolean mark_as_nsred,
3335 final String reason) {
3336 if ((region_name == META_REGION_NAME && !has_root) // HBase 0.95+
3337 || region_name == ROOT_REGION // HBase <= 0.94
3338 || region_name == HBASE98_ROOT_REGION) { // Split meta
3339 if (reason != null) {
3340 LOG.info("Invalidated cache for "
3341 + (has_root ? (region_name == ROOT_REGION ?
3342 new String(ROOT_REGION) : new String(HBASE98_ROOT_REGION)) :
3343 (split_meta ? new String(HBASE96_META) : new String(META)))
3344 + " as " + rootregion + ' ' + reason);
3345 }
3346 rootregion = null;
3347 return;
3348 }
3349 final RegionInfo oldregion = mark_as_nsred
3350 ? regions_cache.put(region_name, new RegionInfo(EMPTY_ARRAY, region_name,
3351 EMPTY_ARRAY))
3352 : regions_cache.remove(region_name);
3353 final RegionInfo region = (oldregion != null ? oldregion
3354 : new RegionInfo(EMPTY_ARRAY, region_name,
3355 EMPTY_ARRAY));
3356 final RegionClient client = region2client.remove(region);
3357
3358 if (oldregion != null && !Bytes.equals(oldregion.name(), region_name)) {
3359 // XXX do we want to just re-add oldregion back? This exposes another
3360 // race condition (we re-add it and overwrite yet another region change).
3361 LOG.warn("Oops, invalidated the wrong regions cache entry."
3362 + " Meant to remove " + Bytes.pretty(region_name)
3363 + " but instead removed " + oldregion);
3364 }
3365
3366 if (client == null) {
3367 return;
3368 }
3369 final ArrayList<RegionInfo> regions = client2regions.get(client);
3370 if (regions != null) {
3371 // `remove()' on an ArrayList causes an array copy. Should we switch
3372 // to a LinkedList instead?
3373 synchronized (regions) {
3374 regions.remove(region);
3375 }
3376 }
3377 if (reason != null) {
3378 LOG.info("Invalidated cache for " + region + " as " + client
3379 + ' ' + reason);
3380 }
3381 }
3382
3383 /**
3384 * Returns true if this region is known to be NSRE'd and shouldn't be used.

Callers 3

discoverRegionMethod · 0.95
handleNSREMethod · 0.95
runMethod · 0.80

Calls 6

equalsMethod · 0.95
nameMethod · 0.95
prettyMethod · 0.95
putMethod · 0.80
removeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected