/** * Check the region cache to see whether a region is cached yet or not. * @param tableName tableName * @param row row * @return Region cached or not. */ public boolean isRegionCached(TableName tableName, final byte[] row) { RegionLocations location = getCachedLocation(tableName, row); return location != null; }
/** * Search the cache for a location that fits our table and row key. * Return null if no suitable region is located. * @return Null or region location found in cache. */ RegionLocations getCachedLocation(final TableName tableName, final byte [] row) { return metaCache.getCachedLocation(tableName, row); }
/** * Delete a cached location, no matter what it is. Called when we were told to not use cache. * @param tableName tableName * @param row */ public void clearCache(final TableName tableName, final byte [] row) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { byte[] startKey = regionLocations.getRegionLocation().getRegion().getStartKey(); boolean removed = tableLocations.remove(startKey, regionLocations); if (removed) { if (metrics != null) { metrics.incrMetaCacheNumClearRegion(); } if (LOG.isTraceEnabled()) { LOG.trace("Removed " + regionLocations + " from cache"); } } } }
/** * Delete a cached location for a table, row and server */ public void clearCache(final TableName tableName, final byte [] row, ServerName serverName) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { RegionLocations updatedLocations = regionLocations.removeByServer(serverName); if (updatedLocations != regionLocations) { byte[] startKey = regionLocations.getRegionLocation().getRegion().getStartKey(); boolean removed = false; if (updatedLocations.isEmpty()) { removed = tableLocations.remove(startKey, regionLocations); } else { removed = tableLocations.replace(startKey, regionLocations, updatedLocations); } if (removed) { if (metrics != null) { metrics.incrMetaCacheNumClearRegion(); } if (LOG.isTraceEnabled()) { LOG.trace("Removed locations of table: " + tableName + " ,row: " + Bytes.toString(row) + " mapping to server: " + serverName + " from cache"); } } } } }
ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { HRegionLocation toBeRemoved = regionLocations.getRegionLocation(replicaId);
/** * Search the cache for a location that fits our table and row key. * Return null if no suitable region is located. * @return Null or region location found in cache. */ RegionLocations getCachedLocation(final TableName tableName, final byte [] row) { return metaCache.getCachedLocation(tableName, row); }
/** * Check the region cache to see whether a region is cached yet or not. * @param tableName tableName * @param row row * @return Region cached or not. */ public boolean isRegionCached(TableName tableName, final byte[] row) { RegionLocations location = getCachedLocation(tableName, row); return location != null; }
/** * Delete a cached location, no matter what it is. Called when we were told to not use cache. * @param tableName tableName * @param row */ public void clearCache(final TableName tableName, final byte [] row) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { byte[] startKey = regionLocations.getRegionLocation().getRegion().getStartKey(); boolean removed = tableLocations.remove(startKey, regionLocations); if (removed) { if (metrics != null) { metrics.incrMetaCacheNumClearRegion(); } if (LOG.isTraceEnabled()) { LOG.trace("Removed " + regionLocations + " from cache"); } } } }
/** * Delete a cached location for a table, row and server */ public void clearCache(final TableName tableName, final byte [] row, ServerName serverName) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { RegionLocations updatedLocations = regionLocations.removeByServer(serverName); if (updatedLocations != regionLocations) { byte[] startKey = regionLocations.getRegionLocation().getRegion().getStartKey(); boolean removed = false; if (updatedLocations.isEmpty()) { removed = tableLocations.remove(startKey, regionLocations); } else { removed = tableLocations.replace(startKey, regionLocations, updatedLocations); } if (removed) { if (metrics != null) { metrics.incrMetaCacheNumClearRegion(); } if (LOG.isTraceEnabled()) { LOG.trace("Removed locations of table: " + tableName + " ,row: " + Bytes.toString(row) + " mapping to server: " + serverName + " from cache"); } } } } }
ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { HRegionLocation toBeRemoved = regionLocations.getRegionLocation(replicaId);
/** * Check the region cache to see whether a region is cached yet or not. * @param tableName tableName * @param row row * @return Region cached or not. */ public boolean isRegionCached(TableName tableName, final byte[] row) { RegionLocations location = getCachedLocation(tableName, row); return location != null; }
/** * Search the cache for a location that fits our table and row key. * Return null if no suitable region is located. * * @param tableName * @param row * @return Null or region location found in cache. */ RegionLocations getCachedLocation(final TableName tableName, final byte [] row) { return metaCache.getCachedLocation(tableName, row); }
/** * Search the cache for a location that fits our table and row key. * Return null if no suitable region is located. * @return Null or region location found in cache. */ RegionLocations getCachedLocation(final TableName tableName, final byte [] row) { return metaCache.getCachedLocation(tableName, row); }
/** * Check the region cache to see whether a region is cached yet or not. * @param tableName tableName * @param row row * @return Region cached or not. */ public boolean isRegionCached(TableName tableName, final byte[] row) { RegionLocations location = getCachedLocation(tableName, row); return location != null; }
/** * Delete a cached location, no matter what it is. Called when we were told to not use cache. * @param tableName tableName * @param row */ public void clearCache(final TableName tableName, final byte [] row) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { byte[] startKey = regionLocations.getRegionLocation().getRegion().getStartKey(); boolean removed = tableLocations.remove(startKey, regionLocations); if (removed) { if (metrics != null) { metrics.incrMetaCacheNumClearRegion(); } if (LOG.isTraceEnabled()) { LOG.trace("Removed " + regionLocations + " from cache"); } } } }
/** * Delete a cached location for a table, row and server */ public void clearCache(final TableName tableName, final byte [] row, ServerName serverName) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { RegionLocations updatedLocations = regionLocations.removeByServer(serverName); if (updatedLocations != regionLocations) { byte[] startKey = regionLocations.getRegionLocation().getRegion().getStartKey(); boolean removed = false; if (updatedLocations.isEmpty()) { removed = tableLocations.remove(startKey, regionLocations); } else { removed = tableLocations.replace(startKey, regionLocations, updatedLocations); } if (removed) { if (metrics != null) { metrics.incrMetaCacheNumClearRegion(); } if (LOG.isTraceEnabled()) { LOG.trace("Removed locations of table: " + tableName + " ,row: " + Bytes.toString(row) + " mapping to server: " + serverName + " from cache"); } } } } }
/** * Delete a cached location, no matter what it is. Called when we were told to not use cache. * @param tableName tableName * @param row */ public void clearCache(final TableName tableName, final byte [] row) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { byte[] startKey = regionLocations.getRegionLocation().getRegionInfo().getStartKey(); boolean removed = tableLocations.remove(startKey, regionLocations); if (removed && LOG.isTraceEnabled()) { LOG.trace("Removed " + regionLocations + " from cache"); } } }
ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { HRegionLocation toBeRemoved = regionLocations.getRegionLocation(replicaId);
/** * Delete a cached location for a table, row and server */ public void clearCache(final TableName tableName, final byte [] row, ServerName serverName) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { RegionLocations updatedLocations = regionLocations.removeByServer(serverName); if (updatedLocations != regionLocations) { byte[] startKey = regionLocations.getRegionLocation().getRegionInfo().getStartKey(); boolean removed = false; if (updatedLocations.isEmpty()) { removed = tableLocations.remove(startKey, regionLocations); } else { removed = tableLocations.replace(startKey, regionLocations, updatedLocations); } if (removed && LOG.isTraceEnabled()) { LOG.trace("Removed locations of table: " + tableName + " ,row: " + Bytes.toString(row) + " mapping to server: " + serverName + " from cache"); } } } }
/** * Delete a cached location, no matter what it is. Called when we were told to not use cache. * @param tableName tableName * @param row */ public void clearCache(final TableName tableName, final byte [] row, int replicaId) { ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName); boolean removed = false; RegionLocations regionLocations = getCachedLocation(tableName, row); if (regionLocations != null) { HRegionLocation toBeRemoved = regionLocations.getRegionLocation(replicaId); RegionLocations updatedLocations = regionLocations.remove(replicaId); if (updatedLocations != regionLocations) { byte[] startKey = regionLocations.getRegionLocation().getRegionInfo().getStartKey(); if (updatedLocations.isEmpty()) { removed = tableLocations.remove(startKey, regionLocations); } else { removed = tableLocations.replace(startKey, regionLocations, updatedLocations); } } if (removed && LOG.isTraceEnabled() && toBeRemoved != null) { LOG.trace("Removed " + toBeRemoved + " from cache"); } } }