public CacheEvictionStats clearRegionBlockCache(Region region) { long evictedBlocks = 0; for(Store store : region.getStores()) { for(StoreFile hFile : store.getStorefiles()) { evictedBlocks += blockCache.evictBlocksByHfileName(hFile.getPath().getName()); } } return CacheEvictionStats.builder() .withEvictedBlocks(evictedBlocks) .build(); }
/** * {@inheritDoc} */ @Override public CacheEvictionStats clearBlockCache(final TableName tableName) throws IOException { checkTableExists(tableName); CacheEvictionStatsBuilder cacheEvictionStats = CacheEvictionStats.builder(); List<Pair<RegionInfo, ServerName>> pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName); Map<ServerName, List<RegionInfo>> regionInfoByServerName = pairs.stream() .filter(pair -> !(pair.getFirst().isOffline())) .filter(pair -> pair.getSecond() != null) .collect(Collectors.groupingBy(pair -> pair.getSecond(), Collectors.mapping(pair -> pair.getFirst(), Collectors.toList()))); for (Map.Entry<ServerName, List<RegionInfo>> entry : regionInfoByServerName.entrySet()) { CacheEvictionStats stats = clearBlockCache(entry.getKey(), entry.getValue()); cacheEvictionStats = cacheEvictionStats.append(stats); if (stats.getExceptionCount() > 0) { for (Map.Entry<byte[], Throwable> exception : stats.getExceptions().entrySet()) { LOG.debug("Failed to clear block cache for " + Bytes.toStringBinary(exception.getKey()) + " on " + entry.getKey() + ": ", exception.getValue()); } } } return cacheEvictionStats.build(); }
@Override public ClearRegionBlockCacheResponse clearRegionBlockCache(RpcController controller, ClearRegionBlockCacheRequest request) { ClearRegionBlockCacheResponse.Builder builder = ClearRegionBlockCacheResponse.newBuilder(); CacheEvictionStatsBuilder stats = CacheEvictionStats.builder(); List<HRegion> regions = getRegions(request.getRegionList(), stats); for (HRegion region : regions) { try { stats = stats.append(this.regionServer.clearRegionBlockCache(region)); } catch (Exception e) { stats.addException(region.getRegionInfo().getRegionName(), e); } } stats.withMaxCacheSize(regionServer.getBlockCache().map(BlockCache::getMaxSize).orElse(0L)); return builder.setStats(ProtobufUtil.toCacheEvictionStats(stats.build())).build(); }
public static CacheEvictionStats toCacheEvictionStats( HBaseProtos.CacheEvictionStats stats) throws IOException{ CacheEvictionStatsBuilder builder = CacheEvictionStats.builder(); builder.withEvictedBlocks(stats.getEvictedBlocks()) .withMaxCacheSize(stats.getMaxCacheSize()); if (stats.getExceptionCount() > 0) { for (HBaseProtos.RegionExceptionMessage exception : stats.getExceptionList()) { HBaseProtos.RegionSpecifier rs = exception.getRegion(); byte[] regionName = rs.getValue().toByteArray(); builder.addException(regionName, ProtobufUtil.toException(exception.getException())); } } return builder.build(); }
/** * {@inheritDoc} */ @Override public CacheEvictionStats clearBlockCache(final TableName tableName) throws IOException { checkTableExists(tableName); CacheEvictionStatsBuilder cacheEvictionStats = CacheEvictionStats.builder(); List<Pair<RegionInfo, ServerName>> pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName); Map<ServerName, List<RegionInfo>> regionInfoByServerName = pairs.stream() .filter(pair -> !(pair.getFirst().isOffline())) .filter(pair -> pair.getSecond() != null) .collect(Collectors.groupingBy(pair -> pair.getSecond(), Collectors.mapping(pair -> pair.getFirst(), Collectors.toList()))); for (Map.Entry<ServerName, List<RegionInfo>> entry : regionInfoByServerName.entrySet()) { CacheEvictionStats stats = clearBlockCache(entry.getKey(), entry.getValue()); cacheEvictionStats = cacheEvictionStats.append(stats); if (stats.getExceptionCount() > 0) { for (Map.Entry<byte[], Throwable> exception : stats.getExceptions().entrySet()) { LOG.debug("Failed to clear block cache for " + Bytes.toStringBinary(exception.getKey()) + " on " + entry.getKey() + ": ", exception.getValue()); } } } return cacheEvictionStats.build(); }
public static CacheEvictionStats toCacheEvictionStats( HBaseProtos.CacheEvictionStats stats) throws IOException{ CacheEvictionStatsBuilder builder = CacheEvictionStats.builder(); builder.withEvictedBlocks(stats.getEvictedBlocks()) .withMaxCacheSize(stats.getMaxCacheSize()); if (stats.getExceptionCount() > 0) { for (HBaseProtos.RegionExceptionMessage exception : stats.getExceptionList()) { HBaseProtos.RegionSpecifier rs = exception.getRegion(); byte[] regionName = rs.getValue().toByteArray(); builder.addException(regionName, ProtobufUtil.toException(exception.getException())); } } return builder.build(); }
/** * {@inheritDoc} */ @Override public CacheEvictionStats clearBlockCache(final TableName tableName) throws IOException { checkTableExists(tableName); CacheEvictionStatsBuilder cacheEvictionStats = CacheEvictionStats.builder(); List<Pair<RegionInfo, ServerName>> pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName); Map<ServerName, List<RegionInfo>> regionInfoByServerName = pairs.stream() .filter(pair -> !(pair.getFirst().isOffline())) .filter(pair -> pair.getSecond() != null) .collect(Collectors.groupingBy(pair -> pair.getSecond(), Collectors.mapping(pair -> pair.getFirst(), Collectors.toList()))); for (Map.Entry<ServerName, List<RegionInfo>> entry : regionInfoByServerName.entrySet()) { CacheEvictionStats stats = clearBlockCache(entry.getKey(), entry.getValue()); cacheEvictionStats = cacheEvictionStats.append(stats); if (stats.getExceptionCount() > 0) { for (Map.Entry<byte[], Throwable> exception : stats.getExceptions().entrySet()) { LOG.debug("Failed to clear block cache for " + Bytes.toStringBinary(exception.getKey()) + " on " + entry.getKey() + ": ", exception.getValue()); } } } return cacheEvictionStats.build(); }
public static CacheEvictionStats toCacheEvictionStats( HBaseProtos.CacheEvictionStats stats) throws IOException{ CacheEvictionStatsBuilder builder = CacheEvictionStats.builder(); builder.withEvictedBlocks(stats.getEvictedBlocks()) .withMaxCacheSize(stats.getMaxCacheSize()); if (stats.getExceptionCount() > 0) { for (HBaseProtos.RegionExceptionMessage exception : stats.getExceptionList()) { HBaseProtos.RegionSpecifier rs = exception.getRegion(); byte[] regionName = rs.getValue().toByteArray(); builder.addException(regionName, ProtobufUtil.toException(exception.getException())); } } return builder.build(); }