Skip to content
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 @@ -216,6 +216,12 @@ default InternalScanner preMemStoreCompactionCompact(
default void postMemStoreCompaction(ObserverContext<RegionCoprocessorEnvironment> c, Store store)
throws IOException {}

/**
* Add for AccessController after HBASE-26089
*/
default void preRequestCompaction(ObserverContext<RegionCoprocessorEnvironment> c)
throws IOException {}

/**
* Called prior to selecting the {@link StoreFile StoreFiles} to compact from the list of
* available candidates. To alter the files used for compaction, you may mutate the passed in list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ private void requestCompactionInternal(HRegion region, HStore store, String why,
!region.getTableDescriptor().isCompactionEnabled())) {
return;
}
if (region.getCoprocessorHost() != null) {
region.getCoprocessorHost().preRequestCompaction();
}
RegionServerSpaceQuotaManager spaceQuotaManager =
this.server.getRegionServerSpaceQuotaManager();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,18 @@ public void postEnvCall() {
}
}

void preRequestCompaction() throws IOException {
if (coprocEnvironments.isEmpty()) {
return;
}
execOperation(new RegionObserverOperationWithoutResult() {
@Override
public void call(RegionObserver observer) throws IOException {
observer.preRequestCompaction(this);
}
});
}

/**
* Called prior to selecting the {@link HStoreFile}s for compaction from the list of currently
* available candidates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
import org.apache.hadoop.hbase.regionserver.ScanType;
import org.apache.hadoop.hbase.regionserver.ScannerContext;
import org.apache.hadoop.hbase.regionserver.Store;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
import org.apache.hadoop.hbase.replication.ReplicationEndpoint;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.replication.SyncReplicationState;
Expand Down Expand Up @@ -1288,12 +1284,10 @@ public void preFlush(ObserverContext<RegionCoprocessorEnvironment> c,
}

@Override
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
requirePermission(c, "compact", getTableName(c.getEnvironment()),
null, null, Action.ADMIN, Action.CREATE);
return scanner;
public void preRequestCompaction(ObserverContext<RegionCoprocessorEnvironment> c)
throws IOException {
requirePermission(c, "compact", getTableName(c.getEnvironment()), null, null, Action.ADMIN,
Action.CREATE);
}

private void internalPreRead(final ObserverContext<RegionCoprocessorEnvironment> c,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.ScanType;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.replication.SyncReplicationState;
import org.apache.hadoop.hbase.security.Superusers;
Expand Down Expand Up @@ -890,8 +889,7 @@ public void testCompact() throws Exception {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCompact(ObserverContextImpl.createAndPrepare(RCP_ENV), null, null,
ScanType.COMPACT_RETAIN_DELETES, null, null);
ACCESS_CONTROLLER.preRequestCompaction(ObserverContextImpl.createAndPrepare(RCP_ENV));
return null;
}
};
Expand Down