/** * 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); }
store.getHRegion().getCoprocessorHost().preCompact(store, scanner, request);
/** * Ensure we get expected exception when we try to return null from a preCompact call. * @throws IOException We expect it to throw {@link CoprocessorException} */ @Test (expected = CoprocessorException.class) public void testPreCompactReturningNull() throws IOException { RegionCoprocessorHost rch = getRegionCoprocessorHost(); rch.preCompact(null, null, null, null, null, null); }
@Override public InternalScanner run() throws Exception { return store.getCoprocessorHost().preCompact(store, scanner, scanType, request); } });
/** * 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. */ protected InternalScanner postCreateCoprocScanner(final CompactionRequest request, final ScanType scanType, final InternalScanner scanner, User user) throws IOException { if (store.getCoprocessorHost() == null) return scanner; if (user == null) { return store.getCoprocessorHost().preCompact(store, scanner, scanType, request); } else { try { return user.getUGI().doAs(new PrivilegedExceptionAction<InternalScanner>() { @Override public InternalScanner run() throws Exception { return store.getCoprocessorHost().preCompact(store, scanner, scanType, request); } }); } catch (InterruptedException ie) { InterruptedIOException iioe = new InterruptedIOException(); iioe.initCause(ie); throw iioe; } } }
/** * Ensure we get expected exception when we try to return null from a preCompact call. * @throws IOException We expect it to throw {@link CoprocessorException} */ @Test (expected = CoprocessorException.class) public void testPreCompactReturningNull() throws IOException { RegionCoprocessorHost rch = getRegionCoprocessorHost(); rch.preCompact(null, null, null, null, null, null); }