LOG.trace(traceMessage); return needsCompaction();
} while (store.needsCompaction() && !compactOnce);
continue; if (s.needsCompaction()) {
@Override public void postOpenDeployTasks(final PostOpenDeployContext context) throws IOException { HRegion r = context.getRegion(); long masterSystemTime = context.getMasterSystemTime(); rpcServices.checkOpen(); LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString()); // Do checks to see if we need to compact (references or too many files) for (HStore s : r.stores.values()) { if (s.hasReferences() || s.needsCompaction()) { this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region"); } } long openSeqNum = r.getOpenSeqNum(); if (openSeqNum == HConstants.NO_SEQNUM) { // If we opened a region, we should have read some sequence number from it. LOG.error( "No sequence number found when opening " + r.getRegionInfo().getRegionNameAsString()); openSeqNum = 0; } // Notify master if (!reportRegionStateTransition(new RegionStateTransitionContext(TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) { throw new IOException( "Failed to report opened region to master: " + r.getRegionInfo().getRegionNameAsString()); } triggerFlushInPrimaryRegion(r); LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString()); }
} while (store.needsCompaction() && !compactOnce);
} while (store.needsCompaction() && !compactOnce);
private boolean updateStorefiles(final List<StoreFile> sfs, final long snapshotId) throws IOException { this.lock.writeLock().lock(); try { this.storeEngine.getStoreFileManager().insertNewFiles(sfs); if (snapshotId > 0) { this.memstore.clearSnapshot(snapshotId); } } finally { // We need the lock, as long as we are updating the storeFiles // or changing the memstore. Let us release it before calling // notifyChangeReadersObservers. See HBASE-4485 for a possible // deadlock scenario that could have happened if continue to hold // the lock. this.lock.writeLock().unlock(); } // Tell listeners of the change in readers. notifyChangedReadersObservers(); if (LOG.isTraceEnabled()) { long totalSize = 0; for (StoreFile sf : sfs) { totalSize += sf.getReader().length(); } String traceMessage = "FLUSH time,count,size,store size,store files [" + EnvironmentEdgeManager.currentTime() + "," + sfs.size() + "," + totalSize + "," + storeSize + "," + storeEngine.getStoreFileManager().getStorefileCount() + "]"; LOG.trace(traceMessage); } return needsCompaction(); }
/** * Execute the actual compaction job. * If the compact once flag is not specified, execute the compaction until * no more compactions are needed. Uses the Configuration settings provided. */ private void compactStoreFiles(final Path tableDir, final HTableDescriptor htd, final HRegionInfo hri, final String familyName, final boolean compactOnce, final boolean major) throws IOException { HStore store = getStore(conf, fs, tableDir, htd, hri, familyName, tmpDir); LOG.info("Compact table=" + htd.getTableName() + " region=" + hri.getRegionNameAsString() + " family=" + familyName); if (major) { store.triggerMajorCompaction(); } do { CompactionContext compaction = store.requestCompaction(Store.PRIORITY_USER, null); if (compaction == null) break; List<StoreFile> storeFiles = store.compact(compaction, NoLimitCompactionThroughputController.INSTANCE); if (storeFiles != null && !storeFiles.isEmpty()) { if (keepCompactedFiles && deleteCompacted) { for (StoreFile storeFile: storeFiles) { fs.delete(storeFile.getPath(), false); } } } } while (store.needsCompaction() && !compactOnce); }