@Override public String toString() { return "CacheEvictionStats{" + "evictedBlocks=" + evictedBlocks + ", maxCacheSize=" + maxCacheSize + ", failedRegionsSize=" + getExceptionCount() + ", failedRegions=" + getFailedRegions() + '}'; } }
/** * {@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 String toString() { return "CacheEvictionStats{" + "evictedBlocks=" + evictedBlocks + ", maxCacheSize=" + maxCacheSize + ", failedRegionsSize=" + getExceptionCount() + ", failedRegions=" + getFailedRegions() + '}'; } }
/** * {@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 String toString() { return "CacheEvictionStats{" + "evictedBlocks=" + evictedBlocks + ", maxCacheSize=" + maxCacheSize + ", failedRegionsSize=" + getExceptionCount() + ", failedRegions=" + getFailedRegions() + '}'; } }
/** * {@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(); }