From f09924b650dae6672e2297a488420699bb0c59c8 Mon Sep 17 00:00:00 2001 From: lujiefsi Date: Tue, 22 Jun 2021 23:37:36 +0800 Subject: [PATCH] HBASE-25877 Add access check for compactionSwitch (#3253) Signed-off-by: Duo Zhang --- .../hbase/regionserver/RSRpcServices.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index f7249d57baa..eeb99c625d5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -1708,21 +1708,18 @@ public class RSRpcServices implements HBaseRPCErrorHandler, @Override public CompactionSwitchResponse compactionSwitch(RpcController controller, CompactionSwitchRequest request) throws ServiceException { - try { - checkOpen(); - requestCount.increment(); - boolean prevState = regionServer.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; - } - regionServer.compactSplitThread.switchCompaction(request.getEnabled()); + rpcPreCheck("compactionSwitch"); + final CompactSplit compactSplitThread = regionServer.getCompactSplitThread(); + 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; } /**