HBASE-15759 RegionObserver.preStoreScannerOpen() doesn't have acces to current readpoint
This commit is contained in:
parent
c716a75416
commit
532b914f08
|
@ -400,6 +400,13 @@ public class BaseRegionObserver implements RegionObserver {
|
|||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
|
||||
final KeyValueScanner s, final long readPt) throws IOException {
|
||||
return preStoreScannerOpen(c, store, scan, targetCols, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Scan scan, final RegionScanner s) throws IOException {
|
||||
|
|
|
@ -1036,11 +1036,43 @@ public interface RegionObserver extends Coprocessor {
|
|||
* @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
|
||||
* @return a KeyValueScanner instance to use or {@code null} to use the default implementation
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
* @deprecated use {@link #preStoreScannerOpen(ObserverContext, Store, Scan, NavigableSet,
|
||||
* KeyValueScanner, long)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
|
||||
final KeyValueScanner s) throws IOException;
|
||||
|
||||
/**
|
||||
* Called before a store opens a new scanner.
|
||||
* This hook is called when a "user" scanner is opened.
|
||||
* <p>
|
||||
* See {@link #preFlushScannerOpen(ObserverContext, Store, KeyValueScanner, InternalScanner)}
|
||||
* and {@link #preCompactScannerOpen(ObserverContext,
|
||||
* Store, List, ScanType, long, InternalScanner)}
|
||||
* to override scanners created for flushes or compactions, resp.
|
||||
* <p>
|
||||
* Call CoprocessorEnvironment#complete to skip any subsequent chained
|
||||
* coprocessors.
|
||||
* Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
|
||||
* effect in this hook.
|
||||
* <p>
|
||||
* Note: Do not retain references to any Cells returned by scanner, beyond the life of this
|
||||
* invocation. If need a Cell reference for later use, copy the cell and use that.
|
||||
* @param c the environment provided by the region server
|
||||
* @param store the store being scanned
|
||||
* @param scan the Scan specification
|
||||
* @param targetCols columns to be used in the scanner
|
||||
* @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
|
||||
* @param readPt the read point
|
||||
* @return a KeyValueScanner instance to use or {@code null} to use the default implementation
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
*/
|
||||
KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
|
||||
final KeyValueScanner s, final long readPt) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the client opens a new scanner.
|
||||
* <p>
|
||||
|
|
|
@ -1868,7 +1868,7 @@ public class HStore implements Store {
|
|||
try {
|
||||
KeyValueScanner scanner = null;
|
||||
if (this.getCoprocessorHost() != null) {
|
||||
scanner = this.getCoprocessorHost().preStoreScannerOpen(this, scan, targetCols);
|
||||
scanner = this.getCoprocessorHost().preStoreScannerOpen(this, scan, targetCols, readPt);
|
||||
}
|
||||
scanner = createScanner(scan, targetCols, readPt, scanner);
|
||||
return scanner;
|
||||
|
|
|
@ -1282,13 +1282,13 @@ public class RegionCoprocessorHost
|
|||
* Store, Scan, NavigableSet, KeyValueScanner)}
|
||||
*/
|
||||
public KeyValueScanner preStoreScannerOpen(final Store store, final Scan scan,
|
||||
final NavigableSet<byte[]> targetCols) throws IOException {
|
||||
final NavigableSet<byte[]> targetCols, final long readPt) throws IOException {
|
||||
return execOperationWithResult(null,
|
||||
coprocessors.isEmpty() ? null : new RegionOperationWithResult<KeyValueScanner>() {
|
||||
@Override
|
||||
public void call(RegionObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
|
||||
throws IOException {
|
||||
setResult(oserver.preStoreScannerOpen(ctx, store, scan, targetCols, getResult()));
|
||||
setResult(oserver.preStoreScannerOpen(ctx, store, scan, targetCols, getResult(), readPt));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -105,11 +105,10 @@ public class TestRegionObserverScannerOpenHook {
|
|||
public static class NoDataFromScan extends BaseRegionObserver {
|
||||
@Override
|
||||
public KeyValueScanner preStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
Store store, Scan scan, NavigableSet<byte[]> targetCols, KeyValueScanner s)
|
||||
Store store, Scan scan, NavigableSet<byte[]> targetCols, KeyValueScanner s, long readPt)
|
||||
throws IOException {
|
||||
scan.setFilter(new NoDataFilter());
|
||||
return new StoreScanner(store, store.getScanInfo(), scan, targetCols,
|
||||
((HStore)store).getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED));
|
||||
return new StoreScanner(store, store.getScanInfo(), scan, targetCols, readPt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ public class TestCoprocessorScanPolicy {
|
|||
@Override
|
||||
public KeyValueScanner preStoreScannerOpen(
|
||||
final ObserverContext<RegionCoprocessorEnvironment> c, Store store, final Scan scan,
|
||||
final NavigableSet<byte[]> targetCols, KeyValueScanner s) throws IOException {
|
||||
final NavigableSet<byte[]> targetCols, KeyValueScanner s, long readPt) throws IOException {
|
||||
TableName tn = store.getTableName();
|
||||
if (!tn.isSystemTable()) {
|
||||
Long newTtl = ttls.get(store.getTableName());
|
||||
|
@ -297,8 +297,7 @@ public class TestCoprocessorScanPolicy {
|
|||
newVersions == null ? family.getMaxVersions() : newVersions,
|
||||
newTtl == null ? oldSI.getTtl() : newTtl, family.getKeepDeletedCells(),
|
||||
oldSI.getTimeToPurgeDeletes(), oldSI.getComparator());
|
||||
return new StoreScanner(store, scanInfo, scan, targetCols,
|
||||
((HStore) store).getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED));
|
||||
return new StoreScanner(store, scanInfo, scan, targetCols, readPt);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue