@@ -107,6 +107,23 @@ public List<NormalizationPlan> computePlanForTable(TableName table) throws HBase
107107      LOG .debug ("Normalization of system table "  + table  + " isn't allowed" );
108108      return  null ;
109109    }
110+     boolean  splitEnabled  = true , mergeEnabled  = true ;
111+     try  {
112+       splitEnabled  = masterRpcServices .isSplitOrMergeEnabled (null ,
113+         RequestConverter .buildIsSplitOrMergeEnabledRequest (MasterSwitchType .SPLIT )).getEnabled ();
114+     } catch  (ServiceException  se ) {
115+       LOG .debug ("Unable to determine whether split is enabled" , se );
116+     }
117+     try  {
118+       mergeEnabled  = masterRpcServices .isSplitOrMergeEnabled (null ,
119+         RequestConverter .buildIsSplitOrMergeEnabledRequest (MasterSwitchType .MERGE )).getEnabled ();
120+     } catch  (ServiceException  se ) {
121+       LOG .debug ("Unable to determine whether split is enabled" , se );
122+     }
123+     if  (!splitEnabled  && !mergeEnabled ) {
124+       LOG .debug ("Both split and merge are disabled for table: "  + table );
125+       return  null ;
126+     }
110127
111128    List <NormalizationPlan > plans  = new  ArrayList <NormalizationPlan >();
112129    List <HRegionInfo > tableRegions  = masterServices .getAssignmentManager ().getRegionStates ().
@@ -141,19 +158,6 @@ public List<NormalizationPlan> computePlanForTable(TableName table) throws HBase
141158    LOG .debug ("Table "  + table  + ", average region size: "  + avgRegionSize );
142159
143160    int  candidateIdx  = 0 ;
144-     boolean  splitEnabled  = true , mergeEnabled  = true ;
145-     try  {
146-       splitEnabled  = masterRpcServices .isSplitOrMergeEnabled (null ,
147-         RequestConverter .buildIsSplitOrMergeEnabledRequest (MasterSwitchType .SPLIT )).getEnabled ();
148-     } catch  (ServiceException  se ) {
149-       LOG .debug ("Unable to determine whether split is enabled" , se );
150-     }
151-     try  {
152-       mergeEnabled  = masterRpcServices .isSplitOrMergeEnabled (null ,
153-         RequestConverter .buildIsSplitOrMergeEnabledRequest (MasterSwitchType .MERGE )).getEnabled ();
154-     } catch  (ServiceException  se ) {
155-       LOG .debug ("Unable to determine whether split is enabled" , se );
156-     }
157161    while  (candidateIdx  < tableRegions .size ()) {
158162      HRegionInfo  hri  = tableRegions .get (candidateIdx );
159163      long  regionSize  = getRegionSize (hri );
0 commit comments