/** * Closes the underlying reader, but do no evict blocks belonging to this file. * It's not thread-safe. Use MobFileCache.closeFile() instead. * @throws IOException */ public void close() throws IOException { if (sf != null) { sf.closeStoreFile(false); sf = null; } }
@Override public void close() throws IOException { file.closeStoreFile(true); }
@Override public Void call() throws IOException { boolean evictOnClose = cacheConf != null? cacheConf.shouldEvictOnClose(): true; f.closeStoreFile(evictOnClose); return null; } });
/** * Closes the readers of store files. * @param storeFiles The store files to be closed. */ private void closeStoreFileReaders(List<HStoreFile> storeFiles) { for (HStoreFile storeFile : storeFiles) { try { storeFile.closeStoreFile(true); } catch (IOException e) { LOG.warn("Failed to close the reader on store file " + storeFile.getPath(), e); } } }
/** * Validates a store file by opening and closing it. In HFileV2 this should not be an expensive * operation. * @param path the path to the store file */ private void validateStoreFile(Path path) throws IOException { HStoreFile storeFile = null; try { storeFile = createStoreFileAndReader(path); } catch (IOException e) { LOG.error("Failed to open store file : {}, keeping it in tmp location", path, e); throw e; } finally { if (storeFile != null) { storeFile.closeStoreFile(false); } } }
/** * Delete this file * @throws IOException */ public void deleteStoreFile() throws IOException { boolean evictOnClose = cacheConf != null ? cacheConf.shouldEvictOnClose() : true; closeStoreFile(evictOnClose); this.fs.delete(getPath(), true); }
/** * Initialize the reader used for pread. */ public void initReader() throws IOException { if (reader == null) { try { open(); } catch (Exception e) { try { boolean evictOnClose = cacheConf != null ? cacheConf.shouldEvictOnClose() : true; this.closeStoreFile(evictOnClose); } catch (IOException ee) { LOG.warn("failed to close reader", ee); } throw e; } } }
/** * Validates a mob file by opening and closing it. * @param conf The current configuration. * @param fs The current file system. * @param path The path where the mob file is saved. * @param cacheConfig The current cache config. */ private static void validateMobFile(Configuration conf, FileSystem fs, Path path, CacheConfig cacheConfig, boolean primaryReplica) throws IOException { HStoreFile storeFile = null; try { storeFile = new HStoreFile(fs, path, conf, cacheConfig, BloomType.NONE, primaryReplica); storeFile.initReader(); } catch (IOException e) { LOG.error("Failed to open mob file[" + path + "], keep it in temp directory.", e); throw e; } finally { if (storeFile != null) { storeFile.closeStoreFile(false); } } }
try { if (file != null) { file.closeStoreFile(evictOnClose);
/** * Validates a mob file by opening and closing it. * * @param path the path to the mob file */ private void validateMobFile(Path path) throws IOException { HStoreFile storeFile = null; try { storeFile = new HStoreFile(region.getFilesystem(), path, conf, this.cacheConf, BloomType.NONE, isPrimaryReplicaStore()); storeFile.initReader(); } catch (IOException e) { LOG.error("Fail to open mob file[" + path + "], keep it in temp directory.", e); throw e; } finally { if (storeFile != null) { storeFile.closeStoreFile(false); } } }
/** * Computes the length of a store file without succumbing to any errors along the way. If an * error is encountered, the implementation returns {@code 0} instead of the actual size. * * @param file The file to compute the size of. * @return The size in bytes of the provided {@code file}. */ long getStoreFileSize(HStoreFile file) { long length = 0; try { file.initReader(); length = file.getReader().length(); } catch (IOException e) { LOG.trace("Failed to open reader when trying to compute store file size, ignoring", e); } finally { try { file.closeStoreFile( file.getCacheConf() != null ? file.getCacheConf().shouldEvictOnClose() : true); } catch (IOException e) { LOG.trace("Failed to close reader after computing store file size, ignoring", e); } } return length; }
@Override protected List<HStoreFile> doCompaction(CompactionRequestImpl cr, Collection<HStoreFile> filesToCompact, User user, long compactionStartTime, List<Path> newFiles) throws IOException { // let compaction incomplete. if (!this.conf.getBoolean("hbase.hstore.compaction.complete", true)) { LOG.warn("hbase.hstore.compaction.complete is set to false"); List<HStoreFile> sfs = new ArrayList<>(newFiles.size()); final boolean evictOnClose = cacheConf != null? cacheConf.shouldEvictOnClose(): true; for (Path newFile : newFiles) { // Create storefile around what we wrote with a reader on it. HStoreFile sf = createStoreFileAndReader(newFile); sf.closeStoreFile(evictOnClose); sfs.add(sf); } return sfs; } return super.doCompaction(cr, filesToCompact, user, compactionStartTime, newFiles); } }
private List<Cell> prepareListOfTestSeeks(Path path) throws IOException { List<Cell> allKeyValues = new ArrayList<>(); // read all of the key values HStoreFile storeFile = new HStoreFile(testingUtility.getTestFileSystem(), path, configuration, cacheConf, BloomType.NONE, true); storeFile.initReader(); StoreFileReader reader = storeFile.getReader(); StoreFileScanner scanner = reader.getStoreFileScanner(true, false, false, 0, 0, false); Cell current; scanner.seek(KeyValue.LOWESTKEY); while (null != (current = scanner.next())) { allKeyValues.add(current); } storeFile.closeStoreFile(cacheConf.shouldEvictOnClose()); // pick seeks by random List<Cell> seeks = new ArrayList<>(); for (int i = 0; i < numberOfSeeks; ++i) { Cell keyValue = allKeyValues.get( randomizer.nextInt(allKeyValues.size())); seeks.add(keyValue); } clearBlockCache(); return seeks; }
private void closeCompactedFile(int index) throws IOException { Collection<HStoreFile> files = this.store.getStoreEngine().getStoreFileManager().getCompactedfiles(); HStoreFile sf = null; Iterator<HStoreFile> it = files.iterator(); for (int i = 0; i <= index; i++) { sf = it.next(); } sf.closeStoreFile(true); store.getStoreEngine().getStoreFileManager().removeCompactedFiles(Lists.newArrayList(sf)); }
f.closeStoreFile(f.getCacheConf() != null ? f.getCacheConf().shouldEvictOnClose() : true);
(finishSeeksTime - startSeeksTime); storeFile.closeStoreFile(cacheConf.shouldEvictOnClose()); clearBlockCache();
sf.closeStoreFile(true);
for (HStoreFile storeFile : delPartition.getStoreFiles()) { try { storeFile.closeStoreFile(true); } catch (IOException e) { LOG.warn("Failed to close the reader on store file " + storeFile.getPath(), e);
Path pathA = splitStoreFile(cloneRegionFs, splitHriA, TEST_FAMILY, f, SPLITKEY, true); // top Path pathB = splitStoreFile(cloneRegionFs, splitHriB, TEST_FAMILY, f, SPLITKEY, false);// bottom f.closeStoreFile(true);
hsf.closeStoreFile(true);