Skip to content

HBASE-28862 Change the generic type for ObserverContext from 'RegionC… #6272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void postBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
public void postBulkLoadHFile(ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
List<Pair<byte[], String>> stagingFamilyPaths, Map<byte[], List<Path>> finalPaths)
throws IOException {
Configuration cfg = ctx.getEnvironment().getConfiguration();
Expand Down Expand Up @@ -82,7 +82,7 @@ public void postBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
}

@Override
public void preCommitStoreFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
public void preCommitStoreFile(final ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
final byte[] family, final List<Pair<Path, Path>> pairs) throws IOException {
Configuration cfg = ctx.getEnvironment().getConfiguration();
if (pairs == null || pairs.isEmpty() || !BackupManager.isBackupEnabled(cfg)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
public void preGetOp(ObserverContext<? extends RegionCoprocessorEnvironment> e, Get get,
List<Cell> results) throws IOException {
// Increment the Counter whenever the coprocessor is called
preGetCounter.increment();
}

@Override
public void postGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
public void postGetOp(ObserverContext<? extends RegionCoprocessorEnvironment> e, Get get,
List<Cell> results) throws IOException {
// do a costly (high latency) operation which we want to measure how long it takes by
// using a Timer (which is a Meter and a Histogram).
Expand All @@ -84,20 +84,20 @@ public void postGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
}

@Override
public void postFlush(ObserverContext<RegionCoprocessorEnvironment> c,
public void postFlush(ObserverContext<? extends RegionCoprocessorEnvironment> c,
FlushLifeCycleTracker tracker) throws IOException {
flushCounter.increment();
}

@Override
public void postFlush(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
public void postFlush(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store,
StoreFile resultFile, FlushLifeCycleTracker tracker) throws IOException {
flushCounter.increment();
}

@Override
public void postCompactSelection(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends StoreFile> selected, CompactionLifeCycleTracker tracker,
public void postCompactSelection(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, List<? extends StoreFile> selected, CompactionLifeCycleTracker tracker,
CompactionRequest request) {
if (selected != null) {
filesCompactedCounter.increment(selected.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Scan scan)
public void preScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c, Scan scan)
throws IOException {
// Add another family:qualifier
scan.addColumn(FAMILY_TO_ADD, QUALIFIER_TO_ADD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public void start(@SuppressWarnings("rawtypes") CoprocessorEnvironment env) thro
}

@Override
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
final InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker,
CompactionRequest request) {
public InternalScanner preCompact(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, final InternalScanner scanner, ScanType scanType,
CompactionLifeCycleTracker tracker, CompactionRequest request) {
InternalScanner modifyingScanner = new InternalScanner() {
@Override
public boolean next(List<? super ExtendedCell> result, ScannerContext scannerContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
ScanOptions options, FlushLifeCycleTracker tracker) throws IOException {
public void preFlushScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, ScanOptions options, FlushLifeCycleTracker tracker) throws IOException {
options.readAllVersions();
}

Expand Down Expand Up @@ -154,42 +154,42 @@ public void close() throws IOException {
}

@Override
public InternalScanner preFlush(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
InternalScanner scanner, FlushLifeCycleTracker tracker) throws IOException {
public InternalScanner preFlush(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, InternalScanner scanner, FlushLifeCycleTracker tracker) throws IOException {
return wrap(store.getColumnFamilyDescriptor().getName(), scanner);
}

@Override
public void preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker,
public void preCompactScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
options.readAllVersions();
}

@Override
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker,
public InternalScanner preCompact(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
return wrap(store.getColumnFamilyDescriptor().getName(), scanner);
}

@Override
public void preMemStoreCompactionCompactScannerOpen(
ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options)
ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanOptions options)
throws IOException {
options.readAllVersions();
}

@Override
public InternalScanner preMemStoreCompactionCompact(
ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner)
ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner)
throws IOException {
return wrap(store.getColumnFamilyDescriptor().getName(), scanner);
}

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get, List<Cell> result)
throws IOException {
public void preGetOp(ObserverContext<? extends RegionCoprocessorEnvironment> c, Get get,
List<Cell> result) throws IOException {
Scan scan =
new Scan().withStartRow(get.getRow()).withStopRow(get.getRow(), true).readAllVersions();
NavigableMap<byte[], NavigableMap<byte[], MutableLong>> sums =
Expand Down Expand Up @@ -249,8 +249,8 @@ private long getUniqueTimestamp(byte[] row) {
}

@Override
public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment)
throws IOException {
public Result preIncrement(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Increment increment) throws IOException {
byte[] row = increment.getRow();
Put put = new Put(row);
long ts = getUniqueTimestamp(row);
Expand All @@ -270,8 +270,8 @@ public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Incr
}

@Override
public void preStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> ctx, Store store,
ScanOptions options) throws IOException {
public void preStoreScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
Store store, ScanOptions options) throws IOException {
options.readAllVersions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ private void resetTTL(ScanOptions options) {
}

@Override
public void preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
ScanOptions options, FlushLifeCycleTracker tracker) throws IOException {
public void preFlushScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, ScanOptions options, FlushLifeCycleTracker tracker) throws IOException {
resetTTL(options);
}

@Override
public void preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker,
public void preCompactScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c,
Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
resetTTL(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> e,
public void preScannerOpen(final ObserverContext<? extends RegionCoprocessorEnvironment> e,
final Scan scan) throws IOException {
if (countOfOpen.incrementAndGet() == 2) { // slowdown openScanner randomly
slowdownCode(e);
}
}

@Override
public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> e,
public boolean preScannerNext(final ObserverContext<? extends RegionCoprocessorEnvironment> e,
final InternalScanner s, final List<Result> results, final int limit, final boolean hasMore)
throws IOException {
// this will slow down a certain next operation if the conditions are met. The slowness
Expand All @@ -165,7 +165,7 @@ public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment
return true;
}

protected void slowdownCode(final ObserverContext<RegionCoprocessorEnvironment> e) {
protected void slowdownCode(final ObserverContext<? extends RegionCoprocessorEnvironment> e) {
if (e.getEnvironment().getRegion().getRegionInfo().getReplicaId() == 0) {
try {
if (sleepTime.get() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
public void preBatchMutate(ObserverContext<? extends RegionCoprocessorEnvironment> c,
MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
if (c.getEnvironment().getRegion().getRegionInfo().getTable().isSystemTable()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
Durability durability) throws IOException {
public void prePut(ObserverContext<? extends RegionCoprocessorEnvironment> e, Put put,
WALEdit edit, Durability durability) throws IOException {
Region region = e.getEnvironment().getRegion();
if (
!region.getRegionInfo().isMetaRegion() && !region.getRegionInfo().getTable().isSystemTable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
Durability durability) throws IOException {
public void prePut(ObserverContext<? extends RegionCoprocessorEnvironment> e, Put put,
WALEdit edit, Durability durability) throws IOException {
Region region = e.getEnvironment().getRegion();
if (
!region.getRegionInfo().isMetaRegion() && !region.getRegionInfo().getTable().isSystemTable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public void start(CoprocessorEnvironment environment) {
}

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
Durability durability) throws IOException {
public void prePut(ObserverContext<? extends RegionCoprocessorEnvironment> e, Put put,
WALEdit edit, Durability durability) throws IOException {
// check the put against the stored constraints
for (Constraint c : constraints) {
c.check(put);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public interface EndpointObserver {
* @param methodName the invoked service method
* @return the possibly modified message
*/
default Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx,
default Message preEndpointInvocation(ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
Service service, String methodName, Message request) throws IOException {
return request;
}
Expand All @@ -74,7 +74,7 @@ default Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironme
* @param responseBuilder Builder for final response to the client, with original response from
* Service's method merged into it.
*/
default void postEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx,
default void postEndpointInvocation(ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
Service service, String methodName, Message request, Message.Builder responseBuilder)
throws IOException {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,25 @@ public Optional<RegionObserver> getRegionObserver() {
}

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
public void preGetOp(ObserverContext<? extends RegionCoprocessorEnvironment> e, Get get,
List<Cell> results) throws IOException {
registerAndMarkMetrics(e, get);
}

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
Durability durability) throws IOException {
public void prePut(ObserverContext<? extends RegionCoprocessorEnvironment> e, Put put,
WALEdit edit, Durability durability) throws IOException {
registerAndMarkMetrics(e, put);
}

@Override
public void preDelete(ObserverContext<RegionCoprocessorEnvironment> e, Delete delete,
public void preDelete(ObserverContext<? extends RegionCoprocessorEnvironment> e, Delete delete,
WALEdit edit, Durability durability) {
registerAndMarkMetrics(e, delete);
}

private void registerAndMarkMetrics(ObserverContext<RegionCoprocessorEnvironment> e, Row row) {
private void registerAndMarkMetrics(ObserverContext<? extends RegionCoprocessorEnvironment> e,
Row row) {
if (!active || !isMetaTableOp(e)) {
return;
}
Expand Down Expand Up @@ -131,7 +132,7 @@ private String getRegionIdFromOp(Row op) {
return splits.length > 2 ? splits[2] : null;
}

private boolean isMetaTableOp(ObserverContext<RegionCoprocessorEnvironment> e) {
private boolean isMetaTableOp(ObserverContext<? extends RegionCoprocessorEnvironment> e) {
return TableName.META_TABLE_NAME.equals(e.getEnvironment().getRegionInfo().getTable());
}

Expand Down
Loading