HBASE-25877 Add access check for compactionSwitch (#3253)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
bda7afe97d
commit
2ae69a883c
|
@ -1707,22 +1707,18 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
|||
@Override
|
||||
public CompactionSwitchResponse compactionSwitch(RpcController controller,
|
||||
CompactionSwitchRequest request) throws ServiceException {
|
||||
rpcPreCheck("compactionSwitch");
|
||||
final CompactSplit compactSplitThread = regionServer.getCompactSplitThread();
|
||||
try {
|
||||
checkOpen();
|
||||
requestCount.increment();
|
||||
boolean prevState = compactSplitThread.isCompactionsEnabled();
|
||||
CompactionSwitchResponse response =
|
||||
CompactionSwitchResponse.newBuilder().setPrevState(prevState).build();
|
||||
if (prevState == request.getEnabled()) {
|
||||
// passed in requested state is same as current state. No action required
|
||||
return response;
|
||||
}
|
||||
compactSplitThread.switchCompaction(request.getEnabled());
|
||||
requestCount.increment();
|
||||
boolean prevState = compactSplitThread.isCompactionsEnabled();
|
||||
CompactionSwitchResponse response =
|
||||
CompactionSwitchResponse.newBuilder().setPrevState(prevState).build();
|
||||
if (prevState == request.getEnabled()) {
|
||||
// passed in requested state is same as current state. No action required
|
||||
return response;
|
||||
} catch (IOException ie) {
|
||||
throw new ServiceException(ie);
|
||||
}
|
||||
compactSplitThread.switchCompaction(request.getEnabled());
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue