/** * Calls coprocessor, if any, to create scanners - after normal scanner creation. * @param request Compaction request. * @param scanType Scan type. * @param scanner The default scanner created for compaction. * @return Scanner scanner to use (usually the default); null if compaction should not proceed. */ private InternalScanner postCompactScannerOpen(CompactionRequestImpl request, ScanType scanType, InternalScanner scanner, User user) throws IOException { if (store.getCoprocessorHost() == null) { return scanner; } return store.getCoprocessorHost().preCompact(store, scanner, scanType, request.getTracker(), request, user); }
private List<HStoreFile> moveCompactedFilesIntoPlace(CompactionRequestImpl cr, List<Path> newFiles, User user) throws IOException { List<HStoreFile> sfs = new ArrayList<>(newFiles.size()); for (Path newFile : newFiles) { assert newFile != null; HStoreFile sf = moveFileIntoPlace(newFile); if (this.getCoprocessorHost() != null) { getCoprocessorHost().postCompact(this, sf, cr.getTracker(), cr, user); } assert sf != null; sfs.add(sf); } return sfs; }
private ScanInfo preCompactScannerOpen(CompactionRequestImpl request, ScanType scanType, User user) throws IOException { if (store.getCoprocessorHost() == null) { return store.getScanInfo(); } return store.getCoprocessorHost().preCompactScannerOpen(store, scanType, request.getTracker(), request, user); }
/** * Return a scanner for both the memstore and the HStore files. Assumes we are not in a * compaction. * @param scan Scan to apply when scanning the stores * @param targetCols columns to scan * @return a scanner over the current key values * @throws IOException on failure */ public KeyValueScanner getScanner(Scan scan, final NavigableSet<byte[]> targetCols, long readPt) throws IOException { lock.readLock().lock(); try { ScanInfo scanInfo; if (this.getCoprocessorHost() != null) { scanInfo = this.getCoprocessorHost().preStoreScannerOpen(this); } else { scanInfo = getScanInfo(); } return createScanner(scan, scanInfo, targetCols, readPt); } finally { lock.readLock().unlock(); } }
/** * Creates the scanner for flushing snapshot. Also calls coprocessors. * @param snapshotScanners * @param smallestReadPoint * @return The scanner; null if coprocessor is canceling the flush. */ protected final InternalScanner createScanner(List<KeyValueScanner> snapshotScanners, long smallestReadPoint, FlushLifeCycleTracker tracker) throws IOException { ScanInfo scanInfo; if (store.getCoprocessorHost() != null) { scanInfo = store.getCoprocessorHost().preFlushScannerOpen(store, tracker); } else { scanInfo = store.getScanInfo(); } InternalScanner scanner = new StoreScanner(store, scanInfo, snapshotScanners, ScanType.COMPACT_RETAIN_DELETES, smallestReadPoint, HConstants.OLDEST_TIMESTAMP); assert scanner != null; if (store.getCoprocessorHost() != null) { try { return store.getCoprocessorHost().preFlush(store, scanner, tracker); } catch (IOException ioe) { scanner.close(); throw ioe; } } return scanner; }
public Path bulkLoadHFile(byte[] family, String srcPathStr, Path dstPath) throws IOException { Path srcPath = new Path(srcPathStr); try { fs.commitStoreFile(srcPath, dstPath); } finally { if (this.getCoprocessorHost() != null) { this.getCoprocessorHost().postCommitStoreFile(family, srcPath, dstPath); } } LOG.info("Loaded HFile " + srcPath + " into store '" + getColumnFamilyName() + "' as " + dstPath + " - updating store file list."); HStoreFile sf = createStoreFileAndReader(dstPath); bulkLoadHFile(sf); LOG.info("Successfully loaded store file {} into store {} (new location: {})", srcPath, this, dstPath); return dstPath; }
if (HStore.this.getCoprocessorHost() != null) { HStore.this.getCoprocessorHost().postFlush(HStore.this, sf, tracker);
if (this.getCoprocessorHost() != null) { this.getCoprocessorHost().postCompact(this, sf, null, null, null);
synchronized (filesCompacting) { if (this.getCoprocessorHost() != null) { final List<HStoreFile> candidatesForCoproc = compaction.preSelect(this.filesCompacting); boolean override = getCoprocessorHost().preCompactSelection(this, candidatesForCoproc, tracker, user); if (override) { if (this.getCoprocessorHost() != null) { this.getCoprocessorHost().postCompactSelection( this, ImmutableList.copyOf(compaction.getRequest().getFiles()), tracker, compaction.getRequest(), user);
boolean success = false; try { RegionCoprocessorHost cpHost = store.getCoprocessorHost(); ScanInfo scanInfo; if (cpHost != null) {
private StoreScanner(HStore store, ScanInfo scanInfo, List<? extends KeyValueScanner> scanners, ScanType scanType, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow) throws IOException { this(store, SCAN_FOR_COMPACTION, scanInfo, 0, store.getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED), false, scanType); assert scanType != ScanType.USER_SCAN; matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, smallestReadPoint, earliestPutTs, oldestUnexpiredTS, now, dropDeletesFromRow, dropDeletesToRow, store.getCoprocessorHost()); // Filter the list of scanners using Bloom filters, time range, TTL, etc. scanners = selectScannersFrom(store, scanners); // Seek all scanners to the initial key seekScanners(scanners, matcher.getStartKey(), false, parallelSeekEnabled); addCurrentScanners(scanners); // Combine all seeked scanners with a heap resetKVHeap(scanners, comparator); }
/**---------------------------------------------------------------------- * The request to dispatch the compaction asynchronous task. * The method returns true if compaction was successfully dispatched, or false if there * is already an ongoing compaction or no segments to compact. */ public boolean start() throws IOException { if (!compactingMemStore.hasImmutableSegments()) { // no compaction on empty pipeline return false; } // get a snapshot of the list of the segments from the pipeline, // this local copy of the list is marked with specific version versionedList = compactingMemStore.getImmutableSegments(); LOG.trace("Speculative compaction starting on {}/{}", compactingMemStore.getStore().getHRegion().getRegionInfo().getEncodedName(), compactingMemStore.getStore().getColumnFamilyName()); HStore store = compactingMemStore.getStore(); RegionCoprocessorHost cpHost = store.getCoprocessorHost(); if (cpHost != null) { cpHost.preMemStoreCompaction(store); } try { doCompaction(); } finally { if (cpHost != null) { cpHost.postMemStoreCompaction(store); } } return true; }
store.getCoprocessorHost());
@Override public Void run() throws Exception { getCoprocessorHost().postCompact(thisStore, sf, cr); return null; } });
@Override public Boolean run() throws Exception { return getCoprocessorHost().preCompactSelection(thisStore, candidatesForCoproc, baseRequest); } });
assert newFile != null; final StoreFile sf = moveFileIntoPlace(newFile); if (this.getCoprocessorHost() != null) { final Store thisStore = this; if (user == null) { getCoprocessorHost().postCompact(thisStore, sf, cr); } else { try {
@Override public KeyValueScanner getScanner(Scan scan, final NavigableSet<byte []> targetCols, long readPt) throws IOException { lock.readLock().lock(); try { KeyValueScanner scanner = null; if (this.getCoprocessorHost() != null) { scanner = this.getCoprocessorHost().preStoreScannerOpen(this, scan, targetCols); } if (scanner == null) { scanner = scan.isReversed() ? new ReversedStoreScanner(this, getScanInfo(), scan, targetCols, readPt) : new StoreScanner(this, getScanInfo(), scan, targetCols, readPt); } return scanner; } finally { lock.readLock().unlock(); } }
if (HStore.this.getCoprocessorHost() != null) { HStore.this.getCoprocessorHost().postFlush(HStore.this, sf);
if (this.getCoprocessorHost() != null) { this.getCoprocessorHost().postCompact(this, sf, null);
@Override public Void run() throws Exception { getCoprocessorHost().postCompactSelection( thisStore,ImmutableList.copyOf(compaction.getRequest().getFiles()),baseRequest); return null; } });