HBASE-21568 Use CacheConfig.DISABLED where we don't expect to have blockcache running

This includes removing the "old way" of disabling blockcache in favor of the
new API.

Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
Josh Elser 2018-12-07 17:18:49 -05:00
parent f88224ee34
commit 67d6d5084c
7 changed files with 11 additions and 16 deletions

View File

@ -414,8 +414,6 @@ public class HFileOutputFormat2
DataBlockEncoding encoding = overriddenEncoding; DataBlockEncoding encoding = overriddenEncoding;
encoding = encoding == null ? datablockEncodingMap.get(tableAndFamily) : encoding; encoding = encoding == null ? datablockEncodingMap.get(tableAndFamily) : encoding;
encoding = encoding == null ? DataBlockEncoding.NONE : encoding; encoding = encoding == null ? DataBlockEncoding.NONE : encoding;
Configuration tempConf = new Configuration(conf);
tempConf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
HFileContextBuilder contextBuilder = new HFileContextBuilder() HFileContextBuilder contextBuilder = new HFileContextBuilder()
.withCompression(compression) .withCompression(compression)
.withChecksumType(HStore.getChecksumType(conf)) .withChecksumType(HStore.getChecksumType(conf))
@ -430,12 +428,12 @@ public class HFileOutputFormat2
HFileContext hFileContext = contextBuilder.build(); HFileContext hFileContext = contextBuilder.build();
if (null == favoredNodes) { if (null == favoredNodes) {
wl.writer = wl.writer =
new StoreFileWriter.Builder(conf, new CacheConfig(tempConf), fs) new StoreFileWriter.Builder(conf, CacheConfig.DISABLED, fs)
.withOutputDir(familydir).withBloomType(bloomType) .withOutputDir(familydir).withBloomType(bloomType)
.withComparator(CellComparator.getInstance()).withFileContext(hFileContext).build(); .withComparator(CellComparator.getInstance()).withFileContext(hFileContext).build();
} else { } else {
wl.writer = wl.writer =
new StoreFileWriter.Builder(conf, new CacheConfig(tempConf), new HFileSystem(fs)) new StoreFileWriter.Builder(conf, CacheConfig.DISABLED, new HFileSystem(fs))
.withOutputDir(familydir).withBloomType(bloomType) .withOutputDir(familydir).withBloomType(bloomType)
.withComparator(CellComparator.getInstance()).withFileContext(hFileContext) .withComparator(CellComparator.getInstance()).withFileContext(hFileContext)
.withFavoredNodes(favoredNodes).build(); .withFavoredNodes(favoredNodes).build();

View File

@ -356,9 +356,7 @@ public class HFile {
*/ */
public static final WriterFactory getWriterFactoryNoCache(Configuration public static final WriterFactory getWriterFactoryNoCache(Configuration
conf) { conf) {
Configuration tempConf = new Configuration(conf); return HFile.getWriterFactory(conf, CacheConfig.DISABLED);
tempConf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
return HFile.getWriterFactory(conf, new CacheConfig(tempConf));
} }
/** /**

View File

@ -309,7 +309,7 @@ public class HFilePrettyPrinter extends Configured implements Tool {
return -2; return -2;
} }
HFile.Reader reader = HFile.createReader(fs, file, new CacheConfig(getConf()), true, getConf()); HFile.Reader reader = HFile.createReader(fs, file, CacheConfig.DISABLED, true, getConf());
Map<byte[], byte[]> fileInfo = reader.loadFileInfo(); Map<byte[], byte[]> fileInfo = reader.loadFileInfo();

View File

@ -710,7 +710,7 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
Path hfilePath = item.getFilePath(); Path hfilePath = item.getFilePath();
Optional<byte[]> first, last; Optional<byte[]> first, last;
try (HFile.Reader hfr = HFile.createReader(hfilePath.getFileSystem(getConf()), hfilePath, try (HFile.Reader hfr = HFile.createReader(hfilePath.getFileSystem(getConf()), hfilePath,
new CacheConfig(getConf()), true, getConf())) { CacheConfig.DISABLED, true, getConf())) {
hfr.loadFileInfo(); hfr.loadFileInfo();
first = hfr.getFirstRowKey(); first = hfr.getFirstRowKey();
last = hfr.getLastRowKey(); last = hfr.getLastRowKey();
@ -847,7 +847,7 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
throws IOException { throws IOException {
Path hfile = hfileStatus.getPath(); Path hfile = hfileStatus.getPath();
try (HFile.Reader reader = try (HFile.Reader reader =
HFile.createReader(fs, hfile, new CacheConfig(getConf()), true, getConf())) { HFile.createReader(fs, hfile, CacheConfig.DISABLED, true, getConf())) {
if (builder.getCompressionType() != reader.getFileContext().getCompression()) { if (builder.getCompressionType() != reader.getFileContext().getCompression()) {
builder.setCompressionType(reader.getFileContext().getCompression()); builder.setCompressionType(reader.getFileContext().getCompression());
LOG.info("Setting compression " + reader.getFileContext().getCompression().name() + LOG.info("Setting compression " + reader.getFileContext().getCompression().name() +
@ -1083,7 +1083,7 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
private static void copyHFileHalf(Configuration conf, Path inFile, Path outFile, private static void copyHFileHalf(Configuration conf, Path inFile, Path outFile,
Reference reference, ColumnFamilyDescriptor familyDescriptor) throws IOException { Reference reference, ColumnFamilyDescriptor familyDescriptor) throws IOException {
FileSystem fs = inFile.getFileSystem(conf); FileSystem fs = inFile.getFileSystem(conf);
CacheConfig cacheConf = new CacheConfig(conf); CacheConfig cacheConf = CacheConfig.DISABLED;
HalfStoreFileReader halfReader = null; HalfStoreFileReader halfReader = null;
StoreFileWriter halfWriter = null; StoreFileWriter halfWriter = null;
try { try {

View File

@ -134,7 +134,7 @@ public class CompressionTest {
writer.appendFileInfo(Bytes.toBytes("compressioninfokey"), Bytes.toBytes("compressioninfoval")); writer.appendFileInfo(Bytes.toBytes("compressioninfokey"), Bytes.toBytes("compressioninfoval"));
writer.close(); writer.close();
Cell cc = null; Cell cc = null;
HFile.Reader reader = HFile.createReader(fs, path, new CacheConfig(conf), true, conf); HFile.Reader reader = HFile.createReader(fs, path, CacheConfig.DISABLED, true, conf);
try { try {
reader.loadFileInfo(); reader.loadFileInfo();
HFileScanner scanner = reader.getScanner(false, true); HFileScanner scanner = reader.getScanner(false, true);

View File

@ -922,7 +922,7 @@ public class HBaseFsck extends Configured implements Closeable {
// For all the stores in this column family. // For all the stores in this column family.
for (FileStatus storeFile : storeFiles) { for (FileStatus storeFile : storeFiles) {
HFile.Reader reader = HFile.createReader(fs, storeFile.getPath(), HFile.Reader reader = HFile.createReader(fs, storeFile.getPath(),
new CacheConfig(getConf()), true, getConf()); CacheConfig.DISABLED, true, getConf());
if ((reader.getFirstKey() != null) if ((reader.getFirstKey() != null)
&& ((storeFirstKey == null) || (comparator.compare(storeFirstKey, && ((storeFirstKey == null) || (comparator.compare(storeFirstKey,
((KeyValue.KeyOnlyKeyValue) reader.getFirstKey().get()).getKey()) > 0))) { ((KeyValue.KeyOnlyKeyValue) reader.getFirstKey().get()).getKey()) > 0))) {
@ -1025,8 +1025,7 @@ public class HBaseFsck extends Configured implements Closeable {
byte[] start, end; byte[] start, end;
HFile.Reader hf = null; HFile.Reader hf = null;
try { try {
CacheConfig cacheConf = new CacheConfig(getConf()); hf = HFile.createReader(fs, hfile.getPath(), CacheConfig.DISABLED, true, getConf());
hf = HFile.createReader(fs, hfile.getPath(), cacheConf, true, getConf());
hf.loadFileInfo(); hf.loadFileInfo();
Optional<Cell> startKv = hf.getFirstKey(); Optional<Cell> startKv = hf.getFirstKey();
start = CellUtil.cloneRow(startKv.get()); start = CellUtil.cloneRow(startKv.get());

View File

@ -82,7 +82,7 @@ public class HFileCorruptionChecker {
boolean quarantine) throws IOException { boolean quarantine) throws IOException {
this.conf = conf; this.conf = conf;
this.fs = FileSystem.get(conf); this.fs = FileSystem.get(conf);
this.cacheConf = new CacheConfig(conf); this.cacheConf = CacheConfig.DISABLED;
this.executor = executor; this.executor = executor;
this.inQuarantineMode = quarantine; this.inQuarantineMode = quarantine;
} }